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
static int handle_recordfile(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[]) | |
{ | |
struct ast_filestream *fs; | |
struct ast_frame *f; | |
struct timeval start; | |
long sample_offset = 0; | |
int res = 0; | |
int ms; | |
struct ast_dsp *sildet=NULL; /* silence detector dsp */ |
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 DictionaryKata < Array | |
# we cheat, knowing how many characters we have to match | |
def initialize(word_size) | |
File.open("/usr/share/dict/words","r") do |words| | |
words.each do |word| | |
word.gsub!(/\n/,'') | |
self << word if word.size == word_size | |
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
class DictionaryKata < Array | |
def initialize(word_size) | |
File.open("/usr/share/dict/words","r") do |words| | |
words.each do |word| | |
word.gsub!(/\n/,'') | |
self << word if word.size == word_size | |
end | |
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
// solution to Codeacademy.com project, "Taxi Fare" | |
// fare based upon miles traveled and the hour of the day | |
var taxiFare = function (milesTraveled, pickupTime) { | |
var baseFare = 2.50; | |
var costPerMile = 2.00; | |
var nightSurcharge = 0.50; // 8pm to 6am, every night | |
var cost = baseFare + (costPerMile * milesTraveled); | |
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
article h1, article p { | |
padding: 18px; } | |
article h1 { | |
font-size: 200%; } | |
article blockquote { | |
width: 80%; | |
margin: auto; } | |
article img { | |
margin: auto; } | |
.articles article { |
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
get '/webwork' do | |
haml :webwork | |
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
(ns my.namespace.core) | |
(if true 1) | |
(gensym) | |
(defn my-when [pred & body] | |
(let [x# pred] | |
`(if ~x# (do ~@body (println "done"))))) |
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 'chingu' | |
class Player < Chingu::GameObject | |
def initialize | |
super | |
self.x, self.y = 200, 200 | |
self.image = Gosu::Image["ship1.jpg"] | |
self.input = { | |
:holding_left => :move_left, | |
:holding_right => :move_right } |
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
# port of David Dalrymple's GNU C code | |
# the original C code can be found at http://davidad.net/colorviz/ | |
def lab_to_xyz(lab) | |
l = lab[0] | |
a = lab[1] | |
b = lab[2] | |
ill = [0.9643, 1.0, 0.8251] |
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
# finally, correctly rewrote the Python script "survey" in Think Stats to Ruby. | |
# burned the midnight candle to get this right. feels great to succeed | |
class Table < Hash | |
def initialize(name=nil) | |
self[:records] = [] | |
self[:name] = name | |
end |