Skip to content

Instantly share code, notes, and snippets.

@cimm
cimm / gist:1359553
Created November 11, 2011 22:44
Imports a folder in iPhoto
-- debugging
on log_event(themessage)
set theLine to (do shell script "date +'%Y-%m-%d %H:%M:%S'" as string) & " " & themessage
do shell script "echo " & theLine & " >> ~/Library/Logs/AppleScript-events.log"
end log_event
-- Extract the album name from the session file
on extractAlbumName(sessionContents)
set albumName to ""
set allLines to every paragraph of sessionContents
@cimm
cimm / localized_ruby.rb
Created November 23, 2012 15:50 — forked from jimeh/__readme.md
Let's not localize programming languages. Please >_<
# Let's not localize programming languages. Please >_<
#
# Feel free to fork and expand and/or add more languages as an example
# to why this would be horrible, and I'll add them here :)
# Ruby in English
if user.is_alive?
# send spam mail
@cimm
cimm / vpn-warning.sh
Created March 26, 2018 21:19
Intended to run in cron, a little nudge to warn me to turn on my VPN
#!/bin/sh
eval "export $(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u $LOGNAME gnome-session)/environ)";
if /sbin/ifconfig tun0; then
echo "VPN is active";
else
DISPLAY=:0 notify-send "VPN is not active"
fi
@cimm
cimm / image_width.js
Created February 2, 2015 19:48
Get the image width in client side JavaScript
var file = ... // a File web API interface: https://developer.mozilla.org/en-US/docs/Web/API/File
img = new Image();
img.src = URL.createObjectURL(file);
img.onload = function() {
alert(this.naturalWidth);
};