Skip to content

Instantly share code, notes, and snippets.

View domgetter's full-sized avatar

Dominic Muller domgetter

View GitHub Profile
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.
require 'gosu'
class MyGame < Gosu::Window
def initialize
super 800, 600, false
end
end
require_relative 'syntax'
Sentence = Struct.new(:syntax)
def initialize
self.syntax = Syntax.new
end
def to_s
# 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
<% sites.each do |site| %>
<% ServerBlock.new(site) %>
<% end %>
<% site_urls.each do |su| %>
server {
listen 443 ssl;
server_name <%= su %>;
location /app {
alias /opt/greendale/www/app;
}
class Bird
def fly
puts "flap fla"
end
end
class Pterodactyl
module Flying
def fly
puts "flap flap"
end
end
class Bird
include Flying
end
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
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 }