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
class MultikeyHash | |
include Enumerable | |
def initialize(initial_values = nil) | |
@outer_hash = {} | |
@inner_hash = {} | |
@next_inner_key = 1 |
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
require 'rmagick' | |
class Color | |
attr_accessor :red, :green, :blue | |
def initialize(red, green, blue) | |
@red = red | |
@green = green |
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 Data.Bits | |
numberOfSetBits :: Int -> Int | |
numberOfSetBits x | |
| x == 0 = 0 | |
| otherwise = 1 + (numberOfSetBits (x .&. (x - 1))) | |
hammingDistance :: [Char] -> [Char] -> Int | |
hammingDistance a b | |
| (length a) == (length b) = sum (map (\ (x, y) -> numberOfSetBits (xor (ord x) (ord y))) (zip a b)) |
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
# encoding: utf-8 | |
require 'zip' | |
require 'rmega' | |
require 'clipboard' | |
email_address = '' | |
password = '' |
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
Saving this for later. Because I'm too lazy to visit them all now and bookmark the good ones. | |
http://en.wikipedia.org/wiki/List_of_3D_graphics_libraries | |
>Tutorials | |
ClanLib | |
http://www.clanlib.org/examples.html | |
SDL | |
http://lazyfoo.net/SDL_tutorials/ | |
http://www.programmersranch.com/p/sdl2-tutorials.html | |
Allegro (4?) |
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
# http://programmingpraxis.com/2012/10/12/birthday-paradox/ | |
trials = 10000 | |
1..64.times do |number_of_people| | |
matches = 0 | |
trials.times do | |
people = Array.new(number_of_people) { rand(365) } |
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
require 'digest' | |
if ARGV.length != 2 | |
puts 'Error: expected two directories to compare.' | |
exit 1 | |
end | |
directory_a = ARGV[0] |
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
var text; | |
text = "This is a very long title. "; | |
setInterval(function() { | |
var letters; | |
letters = text.split(""); | |
letters = letters.concat([letters.shift()]); |
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
defmodule Fibonacci do | |
def fibonacci_numbers(n) do | |
fibonacci_numbers(n, [1, 0]) |> Enum.reverse | |
end | |
defp fibonacci_numbers(n, [h | t]) do | |
[a | _] = t | |
if length([h | t]) < n do | |
fibonacci_numbers(n, Enum.concat([a + h], [h | t])) |
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
require 'bunny' | |
number_of_messages = 10 | |
queue_name = 'contact' | |
connection = Bunny.new | |
connection.start |
OlderNewer