Skip to content

Instantly share code, notes, and snippets.

Avatar

Dominic Muller domgetter

  • Bakersfield, CA
View GitHub Profile
View play_freqs_poc.rb
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
require 'gosu'
class MyGame < Gosu::Window
def initialize
super 800, 600, false
end
end
View gist:1fbcb607fa32d4e1dcfc
require_relative 'syntax'
Sentence = Struct.new(:syntax)
def initialize
self.syntax = Syntax.new
end
def to_s
View database_tasks.rb
# 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
<% sites.each do |site| %>
<% ServerBlock.new(site) %>
<% end %>
View gist:e6705d363f52508b620c
<% site_urls.each do |su| %>
server {
listen 443 ssl;
server_name <%= su %>;
location /app {
alias /opt/greendale/www/app;
}
View gist:7f5a2e4e8cf0d736d20f
module Flying
def fly
puts "flap flap"
end
end
class Bird
include Flying
end
View gist:a25916750116492bdb5d
class Bird
def fly
puts "flap fla"
end
end
class Pterodactyl
View cards.rb
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
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
You can’t perform that action at this time.