Skip to content

Instantly share code, notes, and snippets.

@chrismdp
chrismdp / wunderlist2.sh
Last active June 18, 2016 18:50
Shell script to grab latest tasks from Wunderlist 2. The path for the DB file is the App Store version. Note that as well as passing the list you want (or "" for all tasks) you can pass a relative time as a second argument: eg "+7d" which will limit the view to only tasks due within that time. ("+7d" limits tasks shown to those due within the ne…
#!/bin/sh
set -e
LIST=$1;
DUE=$2;
WUNDERLISTDB="$HOME/Library/Containers/com.wunderkinder.wunderlistdesktop/Data/Library/Application Support/Wunderlist/WKModel.sqlite"
if [ "$LIST" == 'Inbox' ]; then
LID="AND ZTASKLIST is null";
@chrismdp
chrismdp / unsplash.sh
Last active December 28, 2015 17:17
Script to grab one of the 10 more recent images from Unsplash, and tint and blur it for use as an iTerm background using Solarized Dark
#!/bin/bash
# NOTE: requires ImageMagick
# NOTE: will tint to the Solarized Dark default background scheme, as the iTerm background blend option didn't lower the contrast enough for me
# NOTE: Optimised for a 1280x800 point screen (my 13" Retina MBP)
set -e
index=$[ 1 + $[ RANDOM % 10 ]]
img=`curl https://unsplash.com/rss/ | xmllint --xpath '/rss/channel/item['$index']/image/url/text()' -`
curl "$img" > ~/unsplash-latest.jpg &&
#!/bin/bash
if [ ! -z "$(find ~/.mail/*/INBOX -type f)" ]; then
printf '📥 '
for box in `ls ~/.mail | grep -v temp`; do
emails=$(find ~/.mail/$box/INBOX -type f | wc -l)
[ $emails -ne 0 ] && printf '%s:%d ' ${box:0:1} $emails
done
printf '~\n'
fi
@chrismdp
chrismdp / rss_git_info.rb
Last active November 9, 2015 14:57
Use this little script to serve an Atom feed about your git repo. I use it to show a rolling ticker on my Twitch.TV live dev streaming channel. See it in action here: http://twitch.tv/chrismdp_
#!/usr/bin/env ruby
require 'builder'
require 'sinatra'
require 'action_view'
include ActionView::Helpers::DateHelper
get '/' do
date = Time.parse(`git show -s --format=%ci`.chomp)
class CodePoint
def initialize(b)
@b = b
end
def hex
@b.to_s(16)
end
def char_windows
@chrismdp
chrismdp / run-changed-tests.sh
Created November 29, 2012 12:00
Handy little command to run all the tests that I've changed since the last commit
git status --porcelain | grep 'test' | grep -v 'factories' | cut -c4- | sort | uniq | xargs zeus test
@chrismdp
chrismdp / gist:2768532
Created May 22, 2012 11:40
Paypal IPN integration in about 30 lines of Sinatra.
diff --git a/app/account.rb b/app/account.rb
index a108685..c89ad34 100644
--- a/app/account.rb
+++ b/app/account.rb
@@ -1,4 +1,22 @@
+require 'open-uri'
+
module Sol
+ class Url
+ def self.get(url)
Given /^an employee called "([^"]+)"$/ do |employee_name|
create_employee(employee_name)
end
Then /^I should be able to pay "([^"]+)" his salary$/ do |employee_name|
pay_salary_to(employee_)
end
Given /^an employee called "([^"]+)"$/ do |employee_name|
create_employee(employee_name)
end
Then /^I should be able to pay "([^"]+)" his salary$/ do |employee_name|
pay_salary_to(employee_)
end
Feature: Paul pays employees
In order to retain staff
As Paul the Payroll Manager I want to pay my staff
Scenario:
Given an admin user called "Paul" with a password "password"
And a user called "Bob"
And "Bob" is an employee
And "Bob" gets paid "$2,000" a month
When I visit the homepage