Skip to content

Instantly share code, notes, and snippets.

View bradleyd's full-sized avatar
🏠
Working from home

Bradley D Smith bradleyd

🏠
Working from home
View GitHub Profile
@bradleyd
bradleyd / trace two-audio
Created December 10, 2012 00:45
adhearsion.log
[2012-12-09 19:37:52] TRACE Adhearsion::Initializer: OS: linux-gnu - RUBY: ruby 1.9.3
[2012-12-09 19:37:52] TRACE Adhearsion::Initializer: Environment: {"TERM"=>"screen", "SHELL"=>"/bin/bash", "SSH_CLIENT"=>"192.168.1.20 34758 22", "SSH_TTY"=>"/dev/pts/2", "USER"=>"bradleyd", "TMUX"=>"/tmp/shareds,6579,0", "PATH"=>"/var/lib/gems/1.9.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games", "MAIL"=>"/var/mail/bradleyd", "LC_MESSAGES"=>"en_US.UTF-8", "LC_COLLATE"=>"en_US.UTF-8", "PWD"=>"/home/bradleyd/vcs", "LANG"=>"C", "TMUX_PANE"=>"%5", "SHLVL"=>"2", "HOME"=>"/home/bradleyd", "LOGNAME"=>"bradleyd", "SSH_CONNECTION"=>"192.168.1.20 35357 192.168.1.21 22", "LC_CTYPE"=>"en_US.UTF-8", "OLDPWD"=>"/home/bradleyd/vcom", "_"=>"/usr/local/bin/ahn", "GEM_PATH"=>"/var/lib/gems/1.9.1:/home/bradleyd/.gem/ruby/1.9.1", "GEM_HOME"=>"/var/lib/gems/1.9.1", "BUNDLE_BIN_PATH"=>"/var/lib/gems/1.9.1/gems/bundler-1.2.1/bin/bundle", "BUNDLE_GEMFILE"=>"/home/bradleyd/vcs/Gemfile", "RUBYOPT"=>"-I/var/lib/gems/1.9.
class SuperSecretProjectCallController < Adhearsion::CallController
def run
answer
menu "tt-weasels", timeout: 8.seconds, tries: 3 do
foo.each do |k,v|
match k, v
end
timeout { do_this_on_timeout }
@bradleyd
bradleyd / open
Created March 6, 2013 16:07
launch scripts in new gnome-terminal
#!/bin/bash
# open files in vim in a spawned gnome-terminal
# This is a alternative to using gvim
# filename
file=$1
# check whether arg is populated
if [ -n "$file" ]
then
class Shopper
def initialize(list)
@list = list
end
attr_accessor :list
end
string = "foo"
a = Shopper.new(string)
[2013-04-06 01:16:36] ERROR Celluloid: Punchblock::Translator::Asterisk::Call crashed!
Celluloid::DeadActorError: attempted to call a dead actor
/var/lib/gems/1.9.1/gems/celluloid-0.13.0/lib/celluloid/actor.rb:66:in `rescue in call'
/var/lib/gems/1.9.1/gems/celluloid-0.13.0/lib/celluloid/actor.rb:63:in `call'
/var/lib/gems/1.9.1/gems/celluloid-0.13.0/lib/celluloid/legacy.rb:14:in `method_missing'
/home/bradleyd/.bundler/ruby/1.9.1/punchblock-9111e71fe8df/lib/punchblock/translator/asterisk/component/re
cord.rb:28:in `block in execute'
/var/lib/gems/1.9.1/gems/has-guarded-handlers-1.5.0/lib/has_guarded_handlers.rb:105:in `call'
/var/lib/gems/1.9.1/gems/has-guarded-handlers-1.5.0/lib/has_guarded_handlers.rb:105:in `call_handler'
/var/lib/gems/1.9.1/gems/has-guarded-handlers-1.5.0/lib/has_guarded_handlers.rb:91:in `block (3 levels) in
@bradleyd
bradleyd / quiz-1.md
Last active December 16, 2015 10:28 — forked from ahoward/quiz-1.md
So you think you wanna be a web developer...

Fork this, update your copy with answers.

They don't need to be precise - pseudo-code is fine in most cases.

Some questions don't have correct answers.

@bradleyd
bradleyd / gist:5700975
Created June 3, 2013 20:11
ruby-talk list example
module FooModule
Foo = :foo
end
=> :foo
>> FooModule.constants
=> [:Foo]
module BarModule
@bradleyd
bradleyd / message
Last active August 29, 2015 14:05
Pattern matching on many parameters
defmodule Message do
defstruct to: nil, subject: nil, text: nil, html: nil, from: nil, bcc: nil
# this is the minimum needed to send an email
def new(%{to: to, subject: subject, text: text, from: from}) do
{:ok, %Message{to: to, subject: subject, text: text, from: from} }
end
def new(%{to: to, subject: subject, html: html, from: from}) do
{:ok, %Message{to: to, subject: subject, html: html, from: from} }
defmodule SecureRandom do
@moduledoc """
Ruby-like SecureRandom module.
## Examples
iex> SecureRandom.base64
"xhTcitKZI8YiLGzUNLD+HQ=="
iex> SecureRandom.urlsafe_base64(4)
#!/usr/bin/env bash
# Small wrapper around the actual command used to start the daemon. This
# wrapper allows us to set various environment variables before Ruby is
# started.
#
# See the following URLs for more information on these options and their
# values:
#
# http://samsaffron.com/archive/2014/04/08/ruby-2-1-garbage-collection-ready-for-production