Skip to content

Instantly share code, notes, and snippets.

View Jared-Prime's full-sized avatar
📚

Jared Davis Jared-Prime

📚
View GitHub Profile
module SidekiqThreadSafetyDemo
class Threadsafe
include Sidekiq::Worker
include Sidetiq::Schedulable
sidekiq_options :queue => :default
recurrence{ secondly }
SAFETY = Mutex.new
@@count = 0
@Jared-Prime
Jared-Prime / 0_reuse_code.js
Last active August 29, 2015 14:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
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 */
#!/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
#! /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)
$ 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 -------------------------------------
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
}
#!/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
#! /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
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 */