Skip to content

Instantly share code, notes, and snippets.

View JustinAiken's full-sized avatar
💎
Rubyin'

Justin Aiken JustinAiken

💎
Rubyin'
View GitHub Profile
def problem001
total = 0
for i in 1..9
if i%3 == 0
puts "#{i} is divisible by 3"
total = total + i
puts total
end
if i%5 == 0
puts "#{i} is divisible by 5"
@JustinAiken
JustinAiken / api_class.php
Created August 7, 2012 21:34 — forked from libryder/api_class.php
LogMyCalls API PHP Sample
<?php
/* LogMyCalls public API
*
* PHP Sample
* Author: David Ryder
* dryder@contactpoint.com
* http://github.com/libryder
*
* The LmcApi is a JSON wrapper using CURL to send and receive data
@JustinAiken
JustinAiken / create_geo.rb
Created October 9, 2012 19:46
Logmycalls API methods for routes
get "http://dev.api.logmycalls.com/services/createRoute",
{
api_key: API_KEY,
api_secret: API_SECRET,
criteria:
{
tracking_number: 8013334646,
message: "blank",
default_ringto: 4358675309,
ouid: 1,
@JustinAiken
JustinAiken / ahn_api.rb
Created October 21, 2012 22:16
SinAhnTra
require 'sinatra'
require 'json'
require 'ahn_api_helpers'
class AhnApi < Sinatra::Base
set :port, 8080
set :environment, ENV['AHN_ENV']
helpers Helpers
@JustinAiken
JustinAiken / rbenv-howto.md
Created October 29, 2012 22:07 — forked from MicahElliott/rbenv-howto.md
Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

This guide enables you to install (ruby-build) and use (rbenv) multiple versions of ruby, isolate project gems (gemsets and/or bundler), and automatically use appropriate combinations of rubies and gems.

TL;DR Demo

# Not sure how much of this we need

aptitude install git zsh libssl-dev zlib1g-dev libreadline-dev libyaml-dev

@JustinAiken
JustinAiken / facebook_scrape.rb
Created December 4, 2012 22:49
facebook election scraper
require 'koala'
AUTH_TOKEN = ENV["AUTH_TOKEN"]
START_TIME = Date.new(2012,11,5).to_time.to_i
END_TIME = Date.new(2012,11,8).to_time.to_i
@facebook = Koala::Facebook::API.new(AUTH_TOKEN)
friends = @facebook.get_connections("me", "friends").sort_by {|friend| friend["name"]}
friends = friends[161..(friends.count - 1)]
1.9.2p320 :001 > @call_flow = CallFlow.find_by_id(7107)
=> #<CallFlow id: 7107, provisioned_route_id: 1147, dnis: "2162019670", message: "blank", default_ringto: "0000000000", ouid: 170, caller_to_sms: nil, email_to_notify: nil, play_disclaimer: "before", created_at: "2012-12-19 18:43:14", updated_at: "2012-12-20 16:11:38", country_code: "1", tx_boost: nil, rx_boost: nil, vm_enabled: nil, routable_type: "OutboundRoute", routable_id: 5, webhook_enabled: nil>
1.9.2p320 :002 > call_flow_params = {:country_code=>"1", :ouid=>"170", :dnis=>"2162019670", :message=>"blank", :play_disclaimer=>"before"}
=> {:country_code=>"1", :ouid=>"170", :dnis=>"2162019670", :message=>"blank", :play_disclaimer=>"before"}
1.9.2p320 :003 > @call_flow.update_attributes(call_flow_params)
NameError: undefined local variable or method `to_ary' for #<CallFlow:0xa968ef8>
from /home/jaiken/.rvm/gems/ruby-1.9.2-p320@callengine/gems/activemodel-3.0.8/lib/active_model/attribute_methods.rb:392:in `method_missing'
from /home/jaiken/.rvm/g
This file has been truncated, but you can view the full file.
[2013-01-22 11:14:46] DEBUG Adhearsion::Call: bc22d026-9854-4c87-a6e8-b894fb44e596: Receiving message: #<Punchblock::Event::Asterisk::AMI::Event name="VarSet", attributes_hash={:privilege=>"dialplan,all", :channel=>"SIP/4.55.12.163-00007e7d", :variable=>"PLAYBACKSTATUS", :value=>"SUCCESS", :uniqueid=>"1358871283.32381"}, target_call_id="bc22d026-9854-4c87-a6e8-b894fb44e596", component_id=nil, target_mixer_name=nil>
[2013-01-22 11:14:46] DEBUG Adhearsion::Call: bc22d026-9854-4c87-a6e8-b894fb44e596: Receiving message: #<Punchblock::Event::Asterisk::AMI::Event name="AGIExec", attributes_hash={:privilege=>"agi,all", :subevent=>"End", :channel=>"SIP/4.55.12.163-00007e7d", :commandid=>"1369246299", :command=>"EXEC Playback \"lmc/monitored-and-recorded\"", :resultcode=>"200", :result=>"Success"}, target_call_id="bc22d026-9854-4c87-a6e8-b894fb44e596", component_id=nil, target_mixer_name=nil>
[2013-01-22 11:14:46] DEBUG Adhearsion::Call: bc22d026-9854-4c87-a6e8-b894fb44e596: Receiving message: #<Punchblock::Event::Ast
@JustinAiken
JustinAiken / order.rb
Created February 21, 2013 19:06
refactoring
def order(n)
i=1, a=1, list=[]
until (i==61 or a==n) do
if (a^i).modulo(n)==1
[a,i]>>list
a+=1
i=1
else
i+=1
cookbook 'build-essential'
cookbook 'apt'
cookbook 'ruby_build'
cookbook 'rbenv', :git => 'https://github.com/fnichol/chef-rbenv'
cookbook 'unicorn'
cookbook 'nginx'
cookbook 'runit'
cookbook 'rails-lastmile', :git => 'git://github.com/DanThiffault/rails-lastmile.git'