This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
#! /usr/bin/env ruby | |
# see: https://en.wikipedia.org/wiki/BaileyBorwein-Plouffe_formula | |
require 'bigdecimal' | |
NUMERATOR = ->(k) do | |
BigDecimal.new('120')*(k**2) + BigDecimal.new('151')*k + BigDecimal.new('47') | |
end | |
DENOMINATOR_1 = ->(k) do |
This file contains hidden or 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
#!/bin/bash | |
# Adds a timestamp beside every line of data received on STDIN. | |
# Turns this -> Into that: | |
# -> Time Data | |
# [INFO] event 1 -> 04-03-2014 12:00:01 [INFO] event 1 | |
# [INFO] event 2 -> 04-03-2014 12:00:02 [INFO] event 2 | |
# example usage: tail -f some.log | timestamp_it > some-timed.log |
This file contains hidden or 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
def balanced(chars: List[Char]): Boolean = { | |
def innerBalance(thisChar: Char, rest: List[Char], center: Int): Int = { | |
def shift(thisChar: String, center: Int): Int = { | |
if (thisChar == "(") { | |
center << 1 | |
} else if (thisChar == ")") { | |
center >> 1 | |
} else { | |
center | |
} |
This file contains hidden or 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
$ bundle exec jruby -Xjit.threshold=0 -S benchmarks/survo/runner.rb | |
Calculating ------------------------------------- | |
run survo 4 i/100ms | |
------------------------------------------------- | |
run survo 115.8 (±14.7%) i/s - 564 in 5.004000s | |
Calculating ------------------------------------- | |
run survo 11 i/100ms | |
------------------------------------------------- | |
run survo 128.8 (±10.9%) i/s - 638 in 5.022000s | |
Calculating ------------------------------------- |
This file contains hidden or 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
#! /bin/ruby | |
File.open( 'scala/euler/problem_11.txt', 'r' ) do |f| | |
grid = [] | |
f.each_line do |line| | |
grid << line.split(' ').map(&:to_i) | |
end | |
products = [] | |
for row in (0..16) |
This file contains hidden or 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
#!/usr/bin/ruby | |
require 'csv' | |
class Parser | |
attr_reader :original_file, :run_id, :timestamp, :partition_table, :node_ip_address | |
attr_reader :peak_concurrency, :average_duration, :average_rate, :target_rate | |
attr_reader :total_calls, :success_rate, :error_rate | |
This file contains hidden or 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
addons/chan_mobile.c:1814:/* XXX this does not work with the do_sco_listen() thread (which also bind()s | |
addons/chan_mobile.c:3584: /* XXX this channel probably does not need to be associated with this pvt */ | |
addons/chan_mobile.c:3716: /* XXX gnu specific strerror_r is assummed here, this | |
addons/chan_mobile.c:3912: /* XXX volume change requested, we will just | |
addons/chan_ooh323.c:114: .bridge = ast_rtp_instance_bridge, /* XXX chan unlocked ? */ | |
addons/chan_ooh323.c:3919: /* XXX Deal with Video */ | |
agi/eagi-test.c:91: /* XXX Process the audio with sphinx here XXX */ | |
apps/app_dahdibarge.c:163: /* XXX Make sure we're not running on a pseudo channel XXX */ | |
apps/app_dahdibarge.c:291: /* XXX Should prompt user for pin if pin is required XXX */ | |
apps/app_dial.c:1370: /* XXX this should be saved like AST_CONTROL_CONNECTED_LINE for !single || caller_entertained */ |