This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Toggles character case | |
* | |
* e.g in: 'b' -> out: 'B' | |
* in: 'B' -> out: 'b' | |
* in: '5' -> out: '5' | |
* | |
* @param c ascii character to be toggled | |
* @return toggled ascii character if alphabetical, | |
* otherwise intact value of c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ENV | |
# RUBY_HEAP_MIN_SLOTS=1000000 | |
# RUBY_HEAP_SLOTS_INCREMENT=1000000 | |
# RUBY_HEAP_SLOTS_GROWTH_FACTOR=1 | |
# RUBY_GC_MALLOC_LIMIT=1000000000 | |
# RUBY_HEAP_FREE_MIN=1000000 | |
# str_gsub() using its regular form (regex, replacement) | |
[:before_string_build, 0] | |
[:after_string_build, 26420] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GC::Profiler.enable | |
vm_before = File.read("/proc/#{$$}/status").match(/^VmSize:\s*(\d*)/)[1].to_i | |
def vm_used(vm_before) | |
File.read("/proc/#{$$}/status").match(/^VmSize:\s*(\d*)/)[1].to_i - vm_before | |
end | |
# w/o block | |
def gsub_wo(s) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GC::Profiler.enable | |
vm_before = File.read("/proc/#{$$}/status").match(/^VmSize:\s*(\d*)/)[1].to_i | |
def vm_used(vm_before) | |
File.read("/proc/#{$$}/status").match(/^VmSize:\s*(\d*)/)[1].to_i - vm_before | |
end | |
# w block | |
def gsub_w(s) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Careful !! | |
# The following script requires ~40Mb of your virtual memory address space. | |
vm_before = File.read("/proc/#{$$}/status").match(/^VmSize:\s*(\d*)/)[1].to_i | |
def vm_used(vm_before) | |
File.read("/proc/#{$$}/status").match(/^VmSize:\s*(\d*)/)[1].to_i - vm_before | |
end | |
# w block |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Weighted Moving Average (WMA) | |
# http://en.wikipedia.org/wiki/Moving_average#Weighted_moving_average | |
# | |
# Given a hash, calculates the weighted moving averages of its values within | |
# a window size given. Modifies the original hash values. | |
# | |
# @param hash [Hash] the hash for whom values calculate the weighted moving | |
# averages. | |
# @param maws [Fixnum] the Moving Average Window Size. The greatest this | |
# number is the smoothest the calculated averages will be. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/osascript | |
tell application "VLC" | |
activate | |
OpenURL "<stream_url_goes_here>" | |
play | |
end tell |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calculate_worklist(bishops) | |
worklist = Array.new | |
bishops.each { |b| | |
worklist.unshift("#{b[0]}") && next if b[1] != [nil, nil] | |
worklist << b[0] | |
} | |
worklist.combination(2).to_a | |
end | |
def pick_position(positions) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% | |
% Authors: | |
% - Ioannis Gakos, 3634 | |
% - Alkis Livathinos, 3690 | |
%% | |
% Place disk on a pole | |
% | |
:- dynamic disk_state/2. |