Skip to content

Instantly share code, notes, and snippets.

@chrismdp
chrismdp / Jenkins build script
Created August 5, 2014 12:08
Jenkins script to force push Jekyll to Github Pages each day, for scheduled blog posts. Run this as a Jenkins Job on your blog git repository, and set to 'build periodically'. My cron job reads 'H 7 * * *'.
git ci --amend -m "`git show -s --format=%s`
Force updated by Jenkins build $BUILD_ID"
git push -f origin HEAD:master
@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)
@chrismdp
chrismdp / http
Last active May 5, 2021 18:54
Simple http server in ruby, that ensures there's no browser caching. For serving static files in development. I copy this into my ~/bin directory.
#!/usr/bin/env ruby
require 'webrick'
class NonCachingFileHandler < WEBrick::HTTPServlet::FileHandler
def prevent_caching(res)
res['ETag'] = nil
res['Last-Modified'] = Time.now + 100**4
res['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0'
res['Pragma'] = 'no-cache'
res['Expires'] = Time.now - 100**4
#!/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 / 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";
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