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. |
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 |
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 | |
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 |
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 %> |
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; | |
} | |
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 |
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 |
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 |
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 } |
OlderNewer