Skip to content

Instantly share code, notes, and snippets.

View bytespider's full-sized avatar

Rob Griffiths bytespider

View GitHub Profile
@bytespider
bytespider / gist:4608821
Last active December 11, 2015 13:38
Electronics shopping list
@bytespider
bytespider / gist:4176493
Created November 30, 2012 15:38
PHP pre-commit hook
ROOT_DIR=$(git rev-parse --show-toplevel);
PHP="php -l"
for file in $(git diff-index --name-only --diff-filter=ACM --cached HEAD -- | grep -e '\.(php|phtml)$'); do
$OUTPUT = $PHP $file 2>&1
if $OUTPUT | grep 'No syntax errors detected'; then
exit 0
else
echo $OUTPUT
exit 1
@bytespider
bytespider / benchmark.sh
Created October 10, 2012 11:24 — forked from peterjmit/benchmark.sh
Bash Benchmark Script (using time)
#!/bin/bash
# REQUIRES SUDO
# Benchmark runner
repeats=20
output_file='benchmark_results.csv'
command_to_run='echo 1'
run_tests() {
# --------------------------------------------------------------------------
[alias]
share = "!URL=`git remote show origin | awk 'NR==2{print $3}' | sed 's/:/\\//;s/git@/http:\\/\\//g;s/\\.git//'`/commit/`git log -1 --format="%H" HEAD` && echo $URL && echo $URL | pbcopy"
@bytespider
bytespider / menu.sh
Created May 29, 2012 17:44
bash menu
#!/bin/sh
# Author: Rob Griffiths
# Based on work from http://www.unix.com/shell-programming-scripting/27099-drop-down-menu-bash-timezone-select.html
# Licence: MIT
# Copyright (c) 2012 Rob Griffiths
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
@bytespider
bytespider / gist:2568367
Created May 1, 2012 14:36
Automate updating iDevices
tell application "iTunes"
repeat with s in sources
if (kind of s is iPod) then
tell application "iTunes" to update s
end if
end repeat
end tell
function clone(object) {
var cloned = Object.create(object.prototype || null);
Object.keys(object).map(function (i) {
cloned[i] = object[i];
});
return cloned;
}
@bytespider
bytespider / gist:1816040
Created February 13, 2012 10:58 — forked from atsusy/gist:998503
Titanium Mobile sample code(podcast player)
/*
* ユーザーインタフェース
*/
var window = Titanium.UI.createWindow({});
var feedsTable = Titanium.UI.createTableView({});
var playingPanel = Titanium.UI.createView({
bottom:-65,
@bytespider
bytespider / gist:1579292
Created January 8, 2012 18:48
Titanium rotation bug?
var wnd = Ti.UI.createWindow({
title: "Title Bar",
modal: true,
backgroundColor: "#FFF",
orientationModes: [
Titanium.UI.PORTRAIT,
Titanium.UI.UPSIDE_PORTRAIT,
Titanium.UI.LANDSCAPE_LEFT,
Titanium.UI.LANDSCAPE_RIGHT
],
var tabGroup = Ti.UI.createTabGroup();
var tabsArray = tabGroup.tabs;
Object.defineProperty(
tabGroup,
"tabs",
{
get: function () {
alert(tabGroup.tabs.length + " tabs");