Skip to content

Instantly share code, notes, and snippets.

View mikker's full-sized avatar
👋

Mikkel Malmberg mikker

👋
View GitHub Profile
@mikker
mikker / open.sh
Created September 8, 2008 12:02
Shortcut for Mac OS X's `open`
# 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 .
@mikker
mikker / clone_tab.sh
Created October 22, 2008 10:27
Clone the current tab in OS X Terminal
#!/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
@mikker
mikker / inject.rb
Created December 14, 2008 14:17
Creating random code strings with Array#inject
# (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) }
@mikker
mikker / link_helper.rb
Created December 19, 2008 14:19
Haml block link helper
@mikker
mikker / Gemfile
Created December 28, 2008 12:01
Fetch the Queen's new-years speeches into a SQLite3 database... WHY WOULDN'T YOU?
source :gemcutter
gem 'hpricot'
gem 'dm-core'
gem 'dm-sqlite-adapter'
gem 'dm-migrations'
# Most recent midnight in Ruby
midnight = ((Time.now.hour*60+Time.now.min)*60+Time.now.sec).seconds.ago
@mikker
mikker / hide bootcamp partition.sh
Created December 29, 2008 21:47
Hide Bootcamp partition in Mac OS X
# 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
@mikker
mikker / messages_controller.rb
Created April 15, 2009 13:00
Ruby example for mobilemarketing.dk
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
@mikker
mikker / gist:631106
Created October 17, 2010 18:30
Update all packages installed with homebrew
brew update && brew upgrade && brew cleanup
@mikker
mikker / NSManagedObjectWithTimestamps.h
Created February 7, 2011 01:20
NSManagedObject with Rails-ish timestamps
//
// NSManagedObjectWithTimestamps.h
// Brainbow Apps, 2011
//
#import <Foundation/Foundation.h>
@interface NSManagedObjectWithTimestamps : NSManagedObject {
NSDate *createdAt;
NSDate *modifiedAt;