This file contains hidden or 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
require 'socket' | |
address = "192.168.1.80" | |
port = 12345 | |
begin | |
t = TCPSocket.new(address, port) | |
rescue | |
puts "error: #{$!}" | |
else |
This file contains hidden or 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 ruby | |
require 'rubygems' | |
require 'mongo' | |
class ToDo | |
def initialize(args) | |
@args = args | |
@mongo = Mongo::Connection.new.db("todo").collection("todos") | |
end |
This file contains hidden or 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
# 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\\\]' |
This file contains hidden or 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
# 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 |
This file contains hidden or 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
#!/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 |
This file contains hidden or 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
@import <Foundation/CPObject.j> | |
@implementation AppController : CPObject | |
{ | |
} | |
- (void)applicationDidFinishLaunching:(CPNotification)aNotification | |
{ | |
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask], |
This file contains hidden or 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
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 |
This file contains hidden or 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
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 |
This file contains hidden or 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
==> 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 |
This file contains hidden or 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($) { | |
var thisIsPrivate = function(number) { | |
console.log("this can only be called from inside this scope", number); | |
} | |
var soIsThis = 4; | |
$.Model.extend('MyModel', | |
/* static */ | |
{ |