Skip to content

Instantly share code, notes, and snippets.

View sfgeorge's full-sized avatar

Stephen George sfgeorge

View GitHub Profile
@sfgeorge
sfgeorge / 0_reuse_code.js
Created March 13, 2014 12:23
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
@sfgeorge
sfgeorge / wat.rb
Last active August 29, 2015 13:57
WAT
def all_or_nothing_a(value)
if value.eql? :all
'You win!'
elsif
value
end
end
def all_or_nothing_b(value)
if value.eql? :all
@sfgeorge
sfgeorge / ahn-gc-log-afb3c6b.log
Created March 19, 2014 02:36
punchblock-issue-memleak test on afb3c6b
3.659: [GC 65600K->11278K(251264K), 0.0260710 secs]
5.690: [GC 76878K->15723K(251264K), 0.0238540 secs]
6.753: [GC 81323K->19927K(251264K), 0.0291840 secs]
8.108: [GC 85527K->29833K(251264K), 0.0323710 secs]
9.352: [GC 95433K->38990K(251264K), 0.0316450 secs]
14.642: [GC 104590K->46932K(225408K), 0.0429300 secs]
16.165: [GC 86676K->52624K(225280K), 0.0412700 secs]
34.404: [GC 92368K->53545K(237440K), 0.0196970 secs]
35.818: [GC 92005K->54583K(220864K), 0.0183110 secs]
38.803: [GC 93047K->54826K(235136K), 0.0178710 secs]
@sfgeorge
sfgeorge / adhearsion.log
Last active August 29, 2015 13:57
punchblock-issue-memleak test on Punchblock 2.1.1 (crash before able to test for mem leak)
[2014-03-19 02:03:25] INFO Adhearsion::PunchblockPlugin::Initializer: Starting connection to server
[2014-03-19 02:03:25] INFO Adhearsion::PunchblockPlugin::Initializer: Connected to Punchblock server
[2014-03-19 02:03:25] INFO Adhearsion::Process: Transitioning from booting to running with 0 active calls due to booted event.
[2014-03-19 02:03:25] INFO Adhearsion::Initializer: Adhearsion v2.4.0 initialized in "integration"!
[2014-03-19 02:03:38] INFO Adhearsion::Router: Call cb547d66-26c8-4e51-a768-7de42597a79b selected route "default" (LeakyController)
[2014-03-19 02:03:38] INFO Adhearsion::Call: cb547d66-26c8-4e51-a768-7de42597a79b@: Executing controller #<LeakyController call=cb547d66-26c8-4e51-a768-7de42597a79b, metadata={}>
[2014-03-19 02:03:41] INFO Adhearsion::Call: cb547d66-26c8-4e51-a768-7de42597a79b@: Call ended due to hangup
[2014-03-19 02:03:46] INFO Adhearsion::Router: Call b0e435eb-6d4f-4133-9a6d-6faca30afbfc selected route "default" (LeakyController)
[2014-03-19 02:03:46] INFO Adhearsi
@sfgeorge
sfgeorge / timestamp_it.sh
Created April 3, 2014 21:43
bash function for adding timestamps
#!/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
@sfgeorge
sfgeorge / adhearsion-jruby-startup.rb
Created April 12, 2014 20:11
Start Adhearsion in JRuby
# Start Adhearsion in JRuby, while building a pidfile as soon as possible.
def ahnctl_start
shell_command = "#{exec_ahn_async} && #{wait} && #{save_pid}"
%x{shell_command}
end
private
# Run start in the background, since it is not daemonized.
@sfgeorge
sfgeorge / README.md
Last active August 29, 2015 13:59
godrb watch file for Adhearsion under JRuby

Adhearsion-JRuby monitored by god

A sample godrb watch for Adhearsion JRuby.

Caveats

  • Note that godrb does not currently work under JRuby. You'll need a ruby manager like rvm or rbenv. That way, you can run your god under CRuby and your adhearsion app under JRuby.
  • This script is not perfect. It occasionally produces empty or corrupt PID files. -_-
  • This script makes a few assumptions.. tweak as necessary if any of this is inaccurate:
    • It assumes you use rvm
    • It assumes you use CentOS 6
@sfgeorge
sfgeorge / request-response-brief.txt
Last active August 29, 2015 14:03
ngrep ASR request/response example
$ nice sudo ngrep -W byline -qt 'grammar|RECOGNITION-COMPLETE|IN-PROGRESS'
interface: eth0 (192.168.10.0/255.255.254.0)
match: grammar|RECOGNITION-COMPLETE
T 2014/06/25 23:15:16.744457 192.168.11.229:41384 -> 192.168.10.208:20103 [AP]
MRCP/2.0 1058 DEFINE-GRAMMAR 1.
Channel-Identifier: bf085f14-f758-4ce2-b@speechrecog.
Content-Type: application/srgs+xml.
Content-Id: grammar-0.
Content-Length: 890.
@sfgeorge
sfgeorge / cats_and_dogs.rb
Created August 18, 2014 15:14
punchblock virtus test
# https://www.youtube.com/watch?v=JmzuRXLzqKk
class Output
include Virtus
attribute :render_documents, String
def render_document=(other)
puts "Reached render_document=(#{other.inspect})"
puts " render_documents before: #{render_documents.inspect}"
@sfgeorge
sfgeorge / molasses_server.rb
Last active August 29, 2015 14:07
A silly idle TCP Server
#!/usr/bin/env ruby
# encoding: utf-8
require 'socket'
port = ENV['PORT'] || 5678
idletime = ENV['IDLETIME'] || 20 # seconds
def log(message)
puts "#{Time.now} INFO #{message}"