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
# Opens the current folder or a given file/folder using Finder | |
# Usage: | |
# $ o -- opens the current folder | |
# $ o Desktop -- opens the Desktop-folder | |
# $ o .profile -- open the file ".profile" | |
o(){ | |
if [[ $1 ]]; then | |
open $1 | |
else | |
open . |
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
#!/bin/bash | |
# Clones the current tab in OS X Terminal | |
osascript -e 'tell application "Terminal"' -e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' -e "do script with command \"cd `pwd`;clear\" in selected tab of the front window" -e 'end tell' &> /dev/null |
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
# (to learn inject I am...) | |
# Using inject to create random strings | |
def code(size) | |
chars = ("a".."z").to_a+(0..9).to_a | |
Array.new(size).inject("") { |str, n| str += chars[rand(chars.size)].to_s } | |
end | |
50.times { |i| puts code(i) } |
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
# I use this in Sinatra/Webby/whatever to make Haml-links | |
# Examples: | |
# link("/") { "Go home" } | |
# link("#bang") do | |
# %img{:src => "image.jpg"} | |
# .caption Some image | |
def link(url, opts={}, &block) | |
opts.merge!(:href => url) | |
haml_tag(:a, opts) { yield } | |
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
source :gemcutter | |
gem 'hpricot' | |
gem 'dm-core' | |
gem 'dm-sqlite-adapter' | |
gem 'dm-migrations' |
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
# Most recent midnight in Ruby | |
midnight = ((Time.now.hour*60+Time.now.min)*60+Time.now.sec).seconds.ago |
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
# Toggles the hidden flag on the partition. I don't want it visible on my desktop | |
sudo /Developer/Tools/SetFile -a V /Volumes/BOOTCAMP # or whatever the partitions called |
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
class MessagesController < ApplicationController | |
# Send sms's | |
def send_sms | |
sms = { | |
:userid => 1516, | |
:username => "mikkelm", | |
:password => "kodeord123", | |
:keyword => "mmtest ruby", # your keyword (not subkeyword) | |
:mobile => "4520202020", # mobile number with country prefix |
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
brew update && brew upgrade && brew cleanup |
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
// | |
// NSManagedObjectWithTimestamps.h | |
// Brainbow Apps, 2011 | |
// | |
#import <Foundation/Foundation.h> | |
@interface NSManagedObjectWithTimestamps : NSManagedObject { | |
NSDate *createdAt; | |
NSDate *modifiedAt; |
OlderNewer