View play_freqs_poc.rb
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 'ffi' | |
# POC: play multiple arbitrary signals to a sound device | |
# This code defines a play_freq method which takes a frequency and a time (in milliseconds) | |
# and uses the waveOut native windows multimedia functions to output the frequency to the | |
# chosen sound device (the default device in this example) | |
# The code here is a basis for arbitrary, multi-signal output from any source which can be | |
# encoded into a PCM format. |
View game.rb
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 'gosu' | |
class MyGame < Gosu::Window | |
def initialize | |
super 800, 600, false | |
end | |
end |
View gist:1fbcb607fa32d4e1dcfc
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_relative 'syntax' | |
Sentence = Struct.new(:syntax) | |
def initialize | |
self.syntax = Syntax.new | |
end | |
def to_s | |
View database_tasks.rb
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
# From activerecord/lib/active_record/tasks/database_tasks.rb ~line 199 | |
# ... | |
def load_seed | |
if seed_loader | |
ActiveRecord::Base.transaction do # <- Wrapped seeder in a transaction block | |
seed_loader.load_seed # | |
end # | |
else |
View something.erb
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
<% sites.each do |site| %> | |
<% ServerBlock.new(site) %> | |
<% end %> |
View gist:e6705d363f52508b620c
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
<% site_urls.each do |su| %> | |
server { | |
listen 443 ssl; | |
server_name <%= su %>; | |
location /app { | |
alias /opt/greendale/www/app; | |
} | |
View gist:7f5a2e4e8cf0d736d20f
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
module Flying | |
def fly | |
puts "flap flap" | |
end | |
end | |
class Bird | |
include Flying | |
end |
View gist:a25916750116492bdb5d
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 Bird | |
def fly | |
puts "flap fla" | |
end | |
end | |
class Pterodactyl |
View cards.rb
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 PokerHandRank | |
RANKS = %w(high pair tpair trip stright flush full four royal) | |
def initialize(hand) | |
@hand = hand | |
end | |
def flush? | |
@hand.suits.any? {|k, v| v >= 5 } |
View deck.rb
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 Deck | |
RANKS = %w(2 3 4 5 6 7 8 9 10 J Q K A) | |
SUITS = %w(s h c d) | |
def initialize | |
@cards = [] | |
RANKS.product(SUITS).each do |card| | |
@cards << {rank: card[0], suit: card[1]} | |
end |
OlderNewer