Skip to content

Instantly share code, notes, and snippets.

View brainsatwork's full-sized avatar

Jens Tegelaers brainsatwork

View GitHub Profile
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.brainsatwork.sync</string>
<key>ProgramArguments</key>
<array>
<string>~/.sync/sync.sh</string>
</array>
@brainsatwork
brainsatwork / CopyPathToClipboard.applescript
Created April 13, 2011 21:32
applescript which copies current Finder path to clipboard.
-- click on icon
try
tell application "Finder"
set currentPath to (POSIX path of (target of front window as alias))
set the clipboard to currentPath
end tell
on error
my finderErrorMsg()
end try
-- drop folder on icon
@brainsatwork
brainsatwork / GWT calendar week
Created April 13, 2011 21:10
Calculating calendar weeks in GWT
public static Long calendarWeekIso (Date inputDate) {
Date thisThursday = new Date(inputDate.getYear(), inputDate.getMonth(), inputDate.getDate() - weekday(inputDate) + 4);
Date firstOfJan = new Date(thisThursday.getYear(), 0, 1);
Date firstThursdayOfYear = new Date(thisThursday.getYear(), 0, 1);
while(weekday(firstThursdayOfYear) != 4){
firstThursdayOfYear.setDate(firstThursdayOfYear.getDate() + 1);
}
Date firstMondayOfYear = new Date(firstThursdayOfYear.getYear(), 0, firstThursdayOfYear.getDate() - 3);
Long cw = (thisThursday.getTime() - firstMondayOfYear.getTime())/1000/60/60/24/7 + 1;
return cw;