Skip to content

Instantly share code, notes, and snippets.

View mdp's full-sized avatar

Mark Percival mdp

View GitHub Profile
mturk.yml
Date.prototype.setISO8601 = function(dString){
var regexp = /(\d\d\d\d)(-)?(\d\d)(-)?(\d\d)(T)?(\d\d)(:)?(\d\d)(:)?(\d\d)(\.\d+)?(Z|([+-])(\d\d)(:)?(\d\d))/;
if (dString.toString().match(new RegExp(regexp))) {
var d = dString.match(new RegExp(regexp));
var offset = 0;
this.setUTCDate(1);
this.setUTCFullYear(parseInt(d[1],10));
@mdp
mdp / PrettyDate.js
Created July 10, 2009 21:47
Makes pretty dates in JS
Date.prototype.niceDate = function(){
var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July' , 'August', 'September', 'October', 'November', 'December');
var days = new Array('Sunday','Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
/* Monday, July 5th 2009*/
var text = '';
text += days[this.getDay()] + ', ';
text += months[this.getMonth()] + ' ';
text += this.getDate().toOrdinal() + ' ';
return text += this.getFullYear();
};
#!/usr/bin/ruby -w
# Time Taken
# A ridiculously simple way to track time in git using Google Spreadsheets
# Copyright: 2009 Mark Percival - SquarePush LLC - squarepush.com
# License: MIT
# Installation
# 1. Create Google spreadsheet and update configuration
# 2. Copy this file to .git/hooks/post-commit in your project
on run argv
tell application "System Events" to tell process "Terminal" to keystroke "t" using command down -- open a new tab
tell application "Terminal" to do script "cd " & item 1 of argv in front window -- change directory
end run
-- in your profile
-- alias newtab='osascript ~/.applescripts/newtab.applescript `pwd`'
@mdp
mdp / save-history.rb
Created November 9, 2009 20:03
The fix for irb history saving in post p83 of 1.8.7 Ruby
#!/usr/local/bin/ruby
#
# save-history.rb -
# $Release Version: 0.9.5$
# $Revision: 11708 $
# $Date: 2007-02-13 08:01:19 +0900 (Tue, 13 Feb 2007) $
# by Keiju ISHITSUKAkeiju@ruby-lang.org)
#
# --
#
// ==UserScript==
// @name HypeM Play-Pause
// @namespace http://fluidapp.com
// @description Adds Play/Pause button to the dock menu
// @include *
// @author Mark Percival
// ==/UserScript==
(function () {
if (window.fluid) {
// Gibberish wants all inputs on it's internal methods to be byte arrays.
// This simplifies things like UTF-8 support and it's just an easy way to dealing with binary data and calculations.
// But it's got utilities to help!
// a2h - Byte array to hex string
// s2a - String to byte array
// Most of this is hidden from you when you just use it for encryption.
GibberishAES.a2h(GibberishAES.Hash.MD5(GibberishAES.s2a("Hello, World!")));
ruby -e'include Math;(-10..10).each{|y|s="";\
(-14..14).each{|x| s << (x**2+y**2<11**2 \
&& atan2(y,x)<PI*0.8&&atan2(y,x)>-PI*0.8 \
&& x**2+(y+6)**2>1 ? "@":" ")*2};puts s}'
git status -s | grep '^.*[M|A]' | awk '{print $2}' | xargs -n1 sed -i '' 's/[[:space:]]*$//'