Skip to content

Instantly share code, notes, and snippets.

View AlexChittock's full-sized avatar

Alex Chittock AlexChittock

  • Cardboard Monsters
  • Essex / London
View GitHub Profile
@AlexChittock
AlexChittock / .gitconfig
Created April 12, 2012 08:17
Current branch
[alias]
current = !sh -c \"echo $(git branch | grep \"*\" | sed \"s/*//\")\"
@AlexChittock
AlexChittock / gist:2365597
Created April 12, 2012 08:22
Find any element with :before pseudo element
/**
* Requires jquery or sizzle
*
* Webkit compatible
* Firefox requires comparison of result of getComputedStyle to that of an
* unstyled element, since it's length is always non-zero 0
*/
$('*').filter(function(){return getComputedStyle(this, ':before').length != 0});
@AlexChittock
AlexChittock / hook_template.sh
Created April 12, 2012 14:00
Expands a git hook event to execute multiple scripts
#!/bin/sh
#
# Executes multiple scripts on a git event
#
# Expects scripts to be arranged like:
# some/directory/for/hooks/
# pre-commit/
# safe-debug.sh
# validate.sh
# update/
@AlexChittock
AlexChittock / BulkFBTestUsers.sh
Created April 26, 2012 16:25
Bulk create facebook test users
#!/bin/bash
if [ $# -le 2 ]; then
echo "Usage : `basename $0` id secret accounts";
exit 1;
fi
NAMES=( alice alex andy armin barry beatrix belle beaumont brody callie carl chris claire dan dave davis derek dwayne edward eric fifi ford georgina greg gordon holly imogen jeff kyle liz melanie november oscar paula quinn reese samantha tilly ullyses violet wanda xiang yuself zack )
SURNAMES=( abercrombie black chi dean edie fox gaant howes india juniper kent lemon middleton nice preston quirk reilly stevens tompsin unice viola wilkins xan yules zenith )
@AlexChittock
AlexChittock / findTabsInPHPFiles.sh
Created September 18, 2012 09:45
Find PHP files containing tabbed indents
find . -name "*.php" | xargs grep -c -P '^\t+' | grep -v ':0$'
@AlexChittock
AlexChittock / findPHPFilesWithTrailingWhitespace.sh
Created September 18, 2012 10:01
Find PHP files with trailing whitespace
find . -name "*.php" | xargs grep -c -P '\s+$' | grep -v ':0$'
@AlexChittock
AlexChittock / line-endings.sh
Created December 13, 2013 18:10
Tool for converting line-endings across a number of files. Requires dos2unix.
#!/bin/bash
if [[ $# -ne 1]]; then
echo "usage: line-endings.sh file-pattern"
echo "while file-pattern is a glob-like pattern to match files to"
echo
exit 1
fi
find . -path $1 | xargs dos2unix
<link rel="import" href="../chart-js/chart-js.html">
<link rel="import" href="../google-map/google-map-search.html">
<link rel="import" href="../core-animated-pages/core-animated-pages.html">
<link rel="import" href="../core-animated-pages/transitions/hero-transition.html">
<link rel="import" href="../core-animated-pages/transitions/cross-fade.html">
<link rel="import" href="../core-animated-pages/transitions/slide-down.html">
<link rel="import" href="../core-animated-pages/transitions/slide-up.html">
<link rel="import" href="../core-animated-pages/transitions/tile-cascade.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-item/core-item.html">
@AlexChittock
AlexChittock / distributed-state-index.js
Last active November 7, 2017 21:22
Middleware for Redux that routes actions to and from a server
import { createSocketMiddleware } from 'redux-socket-middleware'
const store = createStore(
reducer,
applyMiddleware(
createSocketMiddleware((action) => store.dispatch(action), 'http://localhost:3030')
)
)
@AlexChittock
AlexChittock / redux-socket-server.js
Last active November 7, 2017 21:21
Simple server distributes 'action' messages between all connected clients.
import SocketIO from 'socket.io'
const io = SocketIO(3030)
const history = []
io.on('connection', (socket) => {
// Replay actions on new clients
socket.on('init', (_) => history.forEach(action => socket.emit('action', action)))