Skip to content

Instantly share code, notes, and snippets.

View levicole's full-sized avatar

Levi Cole levicole

  • Kolide
  • Nashville, TN
View GitHub Profile
" freakin sweet iterpolation
let g:surround_{char2nr("#")} = "#{\r}"
Proc.new { |env|
status, headers, body =
begin
@app.call(env)
rescue => boom
raise
end
[status, headers, body]
}
def get_input
print ">>"
STDOUT.flush
response = STDIN.gets.chomp
case response
when "exit"
puts "bye!"
@running = false
when "time"
puts "The Time is:#{Time.now}"
@levicole
levicole / hack
Created September 14, 2009 03:22 — forked from ymendel/hack
#!/bin/sh
BRANCHES=`git branch`
if [ $? != 0 ]; then
exit
fi
GIT_SVN=0
git branch -r | grep 'git-svn' > /dev/null
if [ $? = 0 ]; then
GIT_SVN=1
#include <stdio.h>
//usage cat javascript.js | minifier > javascript.mini.js
int main(int argc, char const* argv[])
{
int c;
while ((c=getchar()) != EOF) {
if (c!= '\n' && c!='\t' && c!='\r')
putchar(c);
}
return 0;
def hexlify(msg)
msg.split("").collect { |c| c[0].to_s(16) }.join
end
def unhexlify(msg)
msg.scan(/../).collect { |c| c.to_i(16).chr }.join
end
puts hexlify("Hello World")
require 'rubygems'
require 'json'
require 'mash'
file = File.read("./widget.json")
mash = Mash.new(JSON.parse(file))
mash.tracks.each do |track|
`curl #{track.stream_url} > "~/immi/#{track.permalink}"`
end
Factory.define :hot_model do |f|
f.sequence(:unique_attr) {|i| "heidi_klum#{i}" }
end
@levicole
levicole / gist:114967
Created May 20, 2009 17:31
twillio api
# be sure to gem install httparty, its a GREAT gem for
# working with these types of RESTful This is just a starting point.
# You will probably want to add a few more methods to the class that
# sets the account_sid, and account_token.
require "httparty"
class TwilioCall
include HTTParty
base_uri "https://api.twilio.com/"
#this is just your account credentials, replace them with your credentials
basic_auth ACCOUNT_SID, ACCOUNT_TOKEN
it "should be ok" do
get "/api/fakeguid/events"
Rails.logger.info "#{response.inspect}"
response.should be_ok
end
# results of response.inspect
#<Rack::MockResponse:0x36a6898 @headers={"Content-Type"=>"text/html", "Content-Length"=>"414"}, @errors="", @original_headers={"Content-Type"=>"text/html", "Content-Length"=>"414"}, @body="<!DOCTYPE html>\n<html>\n<head>\n <style type=\"text/css\">\n body { text-align:center;font-family:helvetica,arial;font-size:22px;\n color:#888;margin:20px}\n #c {margin:0 auto;width:500px;text-align:left}\n </style>\n</head>\n<body>\n <h2>Sinatra doesn't know this ditty.</h2>\n <img src='/__sinatra__/404.png'>\n <div id=\"c\">\n Try this:\n <pre>get '/hello' do\n \"Hello World\"\nend</pre>\n </div>\n</body>\n</html>\n", @status=404>