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 / git_move_dir_to_another_repo
Last active December 17, 2015 18:59
Moving a directory from one repo to another.
git filter-branch --subdirectory-filter xxxx HEAD
git reset --hard
git remote rm origin
rm -r .git/refs/original/
git reflog expire --expire=now --all
git gc --aggressive
git prune
git remote add origin https://github.com/xxx/xxxx.git
git push -u origin master
@swmcc
swmcc / start_development
Created May 27, 2013 14:56
A boilerplate tmux shell script I use for including in my projects to aid development. This one isn't specific to any tech other than it uses guard. I might include others that are for node/ruby or even go as far as to specific frameworks express/sinatra/rails.
#!/bin/sh
BASE=`pwd`
PROJECT='xxxxx'
tmux start-server
# new-session creates first window named 'console'
tmux new-session -d -s $PROJECT -n console
@swmcc
swmcc / README.md
Last active December 17, 2015 20:39
A boiler plate/skeleton README that I use

app

app·name /ˈappˌname/

Noun:
Description.

Synonyms: Something.

@swmcc
swmcc / blog_skeleton.html
Created May 30, 2013 15:26
I am not that big a fan of thor - and this is dead handy. A skeleton blog post I use for my blog...
---
type: post
tags:
published: true
title:
layout: post
status: publish
---
@swmcc
swmcc / build_recommendations_list
Last active December 18, 2015 01:38
Old code from a previous employer that has since moved on (no longer uses this code) - Builds the "suggestions" list for a video; i.e. the most common videos bought by people who also bought this. This is here for a talk I am giving..
#!/usr/bin/perl -w
#------------------------------------------------------------------------------
#
# Copyright (c) BlackStar 1999 - 2003
#
#------------------------------------------------------------------------------
#
# Modification History
#
@swmcc
swmcc / post-commit
Last active December 21, 2015 01:58
Take a shot on every git commit I do
#!/usr/bin/env ruby
file="~/.gitshots/#{Time.now.to_i}.jpg"
puts "Taking capture into #{file}!"
system "imagesnap -q -w 3 #{file}"
exit 0
@swmcc
swmcc / csv_to_json.py
Created October 25, 2013 16:09
Simple script to convert a csv file into json. Assumes first line is headers.
#!/usr/bin/env python
import json
import csv
import sys
## assumes first row is headers
def csv_to_json(filename):
rows = []
with open(filename, 'rb') as csvfile:
@swmcc
swmcc / gist:7725425
Created November 30, 2013 22:29
Export several charts out to a .pdf format using - Highcharts (http://www.highcharts.com/) and jspdf (http://parall.ax/products/jspdf). Big thanks to Colm Dougan for this.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Basic Report</title>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js'></script>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/jquery-ui.js'></script>
<!--
@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 {