Skip to content

Instantly share code, notes, and snippets.

@oskarhagberg
oskarhagberg / gitignore.sh
Created May 2, 2013 13:30
Get .gitignore from github
# In your .bash_profile or .profile add
# Github gitignore
function gitignore() {
curl -H "Accept:application/vnd.github.v3.raw+json" "https://api.github.com/gitignore/templates/$@"
}
# Example usage:
# $ git init
# $ gitignore > .gitignore
@oskarhagberg
oskarhagberg / gist:4953663
Created February 14, 2013 15:48
lib_mosquitto 1.1.3 issue
App(39964,0xb04fc000) malloc: *** error for object 0x55b09700: pointer being freed was not allocated
#0 0x932b9815 in malloc_error_break ()
#1 0x932bad51 in free ()
#2 0x0040f7c7 in _mosquitto_free at /Users/oskar/acme/app/Vendor/MqttKit/Vendor/libmosquitto/memory_mosq.c:73
#3 0x00412d72 in _mosquitto_packet_write at /Users/oskar/acme/app/Vendor/MqttKit/Vendor/libmosquitto/net_mosq.c:702
#4 0x00412b4e in _mosquitto_packet_queue at /Users/oskar/acme/app/Vendor/MqttKit/Vendor/libmosquitto/net_mosq.c:157
#5 0x004166ea in _mosquitto_send_real_publish at /Users/oskar/acme/app/Vendor/MqttKit/Vendor/libmosquitto/send_mosq.c:280
#6 0x0041645c in _mosquitto_send_publish at /Users/oskar/acme/app/Vendor/MqttKit/Vendor/libmosquitto/send_mosq.c:175
@oskarhagberg
oskarhagberg / MapViewOverlayAcitivity.java
Created July 14, 2011 14:22
Drawing path overlay on Android MapView
/** Called when the activity is first created. */
private List<Overlay> mapOverlays;
private Projection projection;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

Useful bash commands

If you wanna find files that includes any occurrence of some text

find . -name <filename> -exec grep -Hn <occurrence> '{}' \;

Extracting (untar) archives

Extract a *.tar file using option xvf

@oskarhagberg
oskarhagberg / gist:249610
Created December 5, 2009 07:37
AppleScript for toggling connection to a specific VPN network
tell application "System Events"
tell current location of network preferences
set VPNservice to service "VPN Service Name goes here"
if exists VPNservice then
set isConnected to connected of current configuration of VPNservice
if isConnected then
disconnect VPNservice
else
connect VPNservice
end if
@oskarhagberg
oskarhagberg / Sync iPhone.scpt
Created December 5, 2009 07:36
AppleScript that syncs connected iPods/iPhones
tell application "iTunes"
repeat with s in sources
if (kind of s is iPod) then update s
end repeat
end tell
@oskarhagberg
oskarhagberg / IPInternal.scpt
Created December 5, 2009 07:35
AppleScript that shows current internal IP as large text (from LaunchBar)
set theIP to do shell script "ifconfig | grep 'broadcast' | awk '{print $2}'"
tell application "LaunchBar" to display in large type theIP with title "Internal IP Address:"
return theIP
@oskarhagberg
oskarhagberg / IPExternal.scpt
Created December 5, 2009 07:33
AppleScript that shows current external IP as large text (from LaunchBar)
set theIP to do shell script "curl -sf http://checkip.dyndns.org/|cut -d ':' -f 2|cut -d '<' -f1|sed -e 's/ //g'"
tell application "LaunchBar"
display in large type theIP with title "External IP Address:"
end tell
return theIP
@oskarhagberg
oskarhagberg / Current Song.scpt
Created December 5, 2009 07:27
AppleScript to show current playing iTunes song using Growl notification
-- Register with Growl
tell application "GrowlHelperApp"
-- The notification types
set the allNotificationsList to {"Current Song"}
set the enabledNotificationList to allNotificationsList
-- Register script with growl
register as application ¬
"iTunes Current Song AppleScript" all notifications allNotificationsList ¬
default notifications enabledNotificationList ¬