This file contains 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
# Shows all the possibilities of a set of coins throwing | |
# You could as well change "heads" and "tails" for true and false. | |
def possibilities(a) | |
results = [] | |
if(a==1) | |
results << ["heads"] | |
results << ["tails"] | |
else |
This file contains 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
source :rubygems | |
# We are not loading Active Record, nor Active Resources etc. | |
# We can do this in any app by simply replacing the rails gem | |
# by the parts we want to use. | |
gem "actionpack", "~> 3.2" | |
gem "railties", "~> 3.2" | |
gem "tzinfo" | |
# Let's use thin |
This file contains 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/env ruby | |
arr = [] | |
$stdin.each_line do |n| | |
n.chop! | |
break if %w(exit quit).include?(n) | |
arr << (/[[:digit:]]+/ === n ? n.to_f : n.to_sym) | |
if arr.last.is_a?(Symbol) | |
if arr.length < 3 | |
puts 'Not enough numbers in stack.' |
This file contains 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/env ruby | |
require 'RMagick' | |
include Magick | |
dir = ARGV[0].dup | |
dir << '/' unless dir.match(/\/$/) | |
thumbnails = Dir.pwd+"/"+dir+"thumbnails" | |
Dir.chdir(Dir.pwd+"/"+dir) | |
puts Dir.pwd | |
puts thumbnails |
This file contains 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
When starting a project that includes refinerycms-blog: | |
$ rake refinery:override view=refinery/pages/* | |
$ rake refinery:override view=layouts/* | |
$ rake refinery:override view=refinery/blog/shared/* | |
$ rake refinery:override view=refinery/blog/posts/* | |
$ rake refinery:override view=refinery/* | |
$ rake refinery:override controller=refinery/blog/* | |
$ rake refinery:override controller=refinery/* |
This file contains 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
function testeClosure(x) { | |
return umaLista.filter( | |
function(y) { return x == y; } | |
); | |
} |
This file contains 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
x = 5 | |
[1, 2, 3, 4].map { |y| y + x } # returns [6, 7, 8, 9] |
This file contains 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
x = 0 | |
[4, 2, 6, 7].each do |y| | |
x += y | |
end | |
puts x # writes 19 on the screen |
This file contains 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
import java.util.concurrent.atomic.AtomicReference; | |
public abstract class TestClosure { | |
public abstract int execute(int a); | |
} | |
public class MainClass { | |
public static void main(String[] args) { | |
final AtomicReference<Integer> x = new AtomicReference<Integer>(4); | |
TestClosure testClosure = new TestClosure() { |
This file contains 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
(defun byte-array-to-ui-32-bit-array (octet-array) | |
(declare (optimize (speed 3)) | |
(type (simple-array (unsigned-byte 8) (*)) octet-array)) | |
(if (/= (mod (length octet-array) 4) 0) | |
(make-array 0 :element-type '(unsigned-byte 32)) | |
(make-array (/ (length octet-array) 4) | |
:element-type '(unsigned-byte 32) | |
:initial-contents | |
(loop for i from 0 below (length octet-array) by 4 | |
for j = 0 then (1+ j) |
OlderNewer