Skip to content

Instantly share code, notes, and snippets.

View jerodsanto's full-sized avatar
:shipit:
Always be shipping

Jerod Santo jerodsanto

:shipit:
Always be shipping
View GitHub Profile
require 'socket'
address = "192.168.1.80"
port = 12345
begin
t = TCPSocket.new(address, port)
rescue
puts "error: #{$!}"
else
@jerodsanto
jerodsanto / mongo_todo.rb
Created May 22, 2010 03:26
A Simple ToDo App Using Ruby and MongoDB
#!/usr/bin/env ruby
require 'rubygems'
require 'mongo'
class ToDo
def initialize(args)
@args = args
@mongo = Mongo::Connection.new.db("todo").collection("todos")
end
# determine current git branch
function parse_git_branch() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "["${ref#refs/heads/}"]"
}
function set_prompt() {
local GREEN='\[\033[0;32m\]'
local WHITE='\[\033[1;37m\]'
local NULL='\[\033k\033\\\]'
@jerodsanto
jerodsanto / poor_mans_ping_test.rb
Created June 15, 2010 20:06
A poor man's replacement for Ruby's Ping.pingecho method
# Ping.pingecho uses TCP echo requests, which sucks when you really want
# to know if the machine is pingable, ie - it answers ICMP requests
# Here's a poor man's replacement for use in a pinch:
def pingable?(host, timeout=5)
system "ping -c 1 -t #{timeout} #{host} >/dev/null"
end
#!/bin/bash
while :
do
echo "Checking for iOS 4.0..."
curl -s -L http://phobos.apple.com/version | grep -i Restore | grep -i iPhone | grep -i 4.0
if [ "$?" = "1" ]; then
echo "Nothing yet..."
else
say "FOUR POINT OH FIRMWARE IS NOW AVAILABLE"
fi
@import <Foundation/CPObject.j>
@implementation AppController : CPObject
{
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
admin = Role.create(:title => "admin")
mike = User.create(:name => "mike")
# either
mike.roles << admin
# or
mike.roles.push admin
# or you can also go the other way
admin.users << mike
def self.find_with_destroyed *args
self.with_exclusive_scope { find(*args) }
end
def destroy
return false if callback(:before_destroy) == false
self.deleted_at = current_time_from_proper_timezone
result = update_without_callbacks
callback(:after_destroy)
result
==> Build Environment
CC: /usr/bin/cc => /usr/bin/gcc-4.2
CXX: /usr/bin/c++ => /usr/bin/c++-4.2
LD: /usr/bin/cc => /usr/bin/gcc-4.2
CFLAGS: -O3 -march=core2 -msse4.1 -w -pipe
CXXFLAGS: -O3 -march=core2 -msse4.1 -w -pipe
MAKEFLAGS: -j2
==> Downloading http://kernel.org/pub/software/scm/git/git-1.7.2.1.tar.bz2
File already downloaded and cached to /Users/jerod/Library/Caches/Homebrew
/usr/bin/tar xf /Users/jerod/Library/Caches/Homebrew/git-1.7.2.1.tar.bz2
(function($) {
var thisIsPrivate = function(number) {
console.log("this can only be called from inside this scope", number);
}
var soIsThis = 4;
$.Model.extend('MyModel',
/* static */
{