Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:

Jared Davis Jared-Prime

:octocat:
View GitHub Profile
@Jared-Prime
Jared-Prime / 0_reuse_code.js
Last active Aug 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View asterisk_comments.txt
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 */
View parse_sipp_logfiles.rb
#!/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
View sample.rb
#! /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)
View jruby_1712.txt
$ 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 -------------------------------------
View balance.scala
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
}
View timestamp_it.sh
#!/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
View pi_digits.rb
#! /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
View handle_recordfile.c
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 */
@Jared-Prime
Jared-Prime / dictionary_kata.rb
Created Apr 30, 2013
edit (4/30/2013 3:23pm) add a few comments
View dictionary_kata.rb
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