Skip to content

Instantly share code, notes, and snippets.

View swmcc's full-sized avatar
👷‍♂️
Building things

Stephen McCullough swmcc

👷‍♂️
Building things
View GitHub Profile
@swmcc
swmcc / date_handler.py
Created February 10, 2014 17:30
Simple python date handling using timedelta
#!/usr/bin/env python
import datetime
date_object = datetime.datetime(2014, 1, 20, 12)
one_day = datetime.timedelta(days=1)
next_day = date_object + one_day
@swmcc
swmcc / date_ranges.php
Created May 13, 2014 12:13
Handy wee function to give you back an array of date ranges.
<?php
function createRange($start, $end) {
$range = array();
if (is_string($start) === true) $start = strtotime($start);
if (is_string($end) === true ) $end = strtotime($end);
if ($start > $end) return createRange($end, $start);
do {
@swmcc
swmcc / TODO .aliases
Last active August 29, 2015 14:04
Simple wrapper to a todo application I have.
# my todo thingie
alias tdm='todos | grep MIQ' # work
alias sdm='todos | grep SG' # startup
alias pdm='todos | grep swmcc' # personal
@swmcc
swmcc / Gemfile
Last active August 29, 2015 14:04
Gemfile - seketon
source 'https://rubygems.org'
@swmcc
swmcc / xmltv_parse.py
Created July 18, 2014 23:32
Quick XMLTV (http://wiki.xmltv.org) Parser written in python. Does nothing fancy and just outputs the basic info to the screen.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import datetime, xmltv
from operator import itemgetter
from collections import namedtuple
filename = "tv.xml"
@swmcc
swmcc / nestoria.py
Created August 10, 2014 21:39
Initial API wrapper for Nestoria
#!/usr/bin/env python
import urllib2
import json
from collections import namedtuple
NESTORIA_API_URL = "http://api.nestoria.co.uk/api?country=uk&action=search_listings&place_name=glenavy&encoding=json&listing_type=buy&number_of_results='50'"
response = urllib2.urlopen(NESTORIA_API_URL)
@swmcc
swmcc / buses
Last active August 29, 2015 14:07
Handy place to hold bus time table info that is relevant to me
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json, sys, urllib2
URL = "https://gist.githubusercontent.com/swmcc/6e3f79ac59511da7b123/raw/4a56499cd71b8ac810e5b78ae8d1a2a2733886e8/translinktimes.json"
json = json.load(urllib2.urlopen(URL))
route = sys.argv[1]
#!/bin/sh
BASE=`pwd`
PROJECT='xxxxx'
tmux start-server
# new-session creates first window named 'console'
tmux new-session -d -s $PROJECT -n console
namespace :import_data do
desc "Import Data"
task :client => :environment do
require 'csv'
mappings = {
'cliClientID' => 'old_client_id',
'cliClientFirstName' => 'first_name',
@swmcc
swmcc / show_branches
Created December 2, 2015 14:23
Hacky script to display all the remote branches of a git repo
#!/usr/bin/env bash
for branch in `git branch -r | grep -v HEAD`;do
echo -e `git show --format="%Cred%ai,%Creset,%an,%Cgreen(%ar),%C(yellow)" $branch --date=short --date=relative |
head -n 1 ` $branch; done | sort -r | head -n 55 | column -ts','