This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
import envoy | |
def main(): | |
r = envoy.run('top -l 2 -n 1 -o cpu -stats pid,command,cpu') | |
top_app = r.std_out.split('\n')[25].split() | |
pid = top_app[0] | |
process_name = ' '.join(top_app[1:-1]).strip() # Process names can can contain spaces | |
cpu = float(top_app[-1]) | |
if cpu > 90: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function gpt | |
set before_gems (md5 Gemfile) | |
set before_migrations (ls -l ./db/migrate | wc -l) | |
git pull tapjoy master | |
set after_gems (md5 Gemfile) | |
set after_migrations (ls -l ./db/migrate | wc -l) | |
if [ $before_gems != $after_gems ] | |
bundle install | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[49] pry(main)> a = Time.zone.now | |
=> Wed, 21 Nov 2012 04:28:07 UTC +00:00 | |
[50] pry(main)> b = a.to_s | |
=> "2012-11-21 04:28:07 UTC" | |
[51] pry(main)> c = Time.zone.parse(b) | |
=> Wed, 21 Nov 2012 04:28:07 UTC +00:00 | |
[52] pry(main)> a == c | |
=> false | |
[57] pry(main)> a.class | |
=> ActiveSupport::TimeWithZone |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = nil | |
def foobar | |
a = 'meh' | |
end | |
foobar | |
puts a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os, sys, random, time, math | |
import pygame | |
from pygame.locals import * | |
pygame.init() | |
screen = pygame.display.set_mode((510, 510)) | |
pygame.display.set_caption('Drawing') | |
background = pygame.Surface(screen.get_size()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dependencies (swiped from RVM) | |
sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev | |
# rbenv | |
cd | |
git clone git@github.com:sstephenson/rbenv.git ~/.rbenv | |
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc | |
# ruby-build | |
mkdir -p ~/.rbenv/plugins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Public: Split an address string into structured data | |
# If you want structured data, don't let the user enter it unstructured! | |
# This function won't work for everything | |
# | |
# Returns a Hash containing :address, :name, :street, :zip, :state, and :city | |
def split_address(address_string) | |
result = {} | |
address = address_string.split("\n") | |
result[:name] = address[0] | |
result[:street] = address[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PS C:\Users\denton\code\portal> jruby --1.9 .\app.rb | |
[2012-05-16 12:15:15] INFO WEBrick 1.3.1 | |
[2012-05-16 12:15:15] INFO ruby 1.9.2 (2012-02-22) [java] | |
== Sinatra/1.3.2 has taken the stage on 4567 for development with backup from WEBrick | |
[2012-05-16 12:15:15] INFO WEBrick::HTTPServer#start: pid=6820 port=4567 | |
JRuby limited openssl loaded. http://jruby.org/openssl | |
gem install jruby-openssl for full support. | |
I, [2012-05-16T12:15:16.489000 #6820] INFO -- : (0.057000s) SELECT CAST(SERVERPROPERTY('ProductVers | |
ion') AS varchar) | |
I, [2012-05-16T12:15:16.560000 #6820] INFO -- : (0.057000s) SELECT TOP (1) * FROM [POLICYS] WHERE ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PS C:\Users\denton\code\portal> jruby --1.9 .\app.rb | |
[2012-05-16 12:24:12] INFO WEBrick 1.3.1 | |
[2012-05-16 12:24:12] INFO ruby 1.9.2 (2012-02-22) [java] | |
== Sinatra/1.3.2 has taken the stage on 4567 for development with backup from WEBrick | |
[2012-05-16 12:24:12] INFO WEBrick::HTTPServer#start: pid=7092 port=4567 | |
JRuby limited openssl loaded. http://jruby.org/openssl | |
gem install jruby-openssl for full support. | |
I, [2012-05-16T12:24:14.318000 #7092] INFO -- : (0.057000s) SELECT CAST(SERVERPROPERTY('ProductVers | |
ion') AS varchar) | |
I, [2012-05-16T12:24:14.389000 #7092] INFO -- : (0.058000s) SELECT TOP (1) * FROM [POLICYS] WHERE ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -r f5875cdc7efe Gemfile | |
--- a/Gemfile Mon May 07 10:42:22 2012 -0500 | |
+++ b/Gemfile Mon May 07 10:45:09 2012 -0500 | |
@@ -5,4 +5,4 @@ | |
gem 'sequel' | |
gem 'coffee-script' | |
-gem 'therubyrhino' | |
\ No newline at end of file | |
+gem 'therubyrhino' |