This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get the latest version no. | |
version=$(wget --quiet --output-document - \ | |
http://nodejs.org/dist/latest/SHASUMS.txt | | |
head --lines 1 | | |
cut --fields 3 --delimiter " " | | |
cut --fields 2 --delimiter "-") | |
name=node-$version-linux-x64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
App::uses('ModelBehavior', 'Model'); | |
class SoftDeleteBehavior extends ModelBehavior { | |
public function setup(Model $Model, $settings = array()) { | |
$field = isset($settings['field']) ? $settings['field'] : 'is_deleted'; | |
$this->settings[$Model->alias]['field'] = $field; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove "actions" divs | |
find View/ -name "*.ctp" -exec sed -i ':a;N;$!ba;s/<div class="actions">\(.*\)<\/div>//g' '{}' \; | |
# Add "table" class to tables | |
find View/ -name "*.ctp" -exec sed -i "s/<table\(.*\)/<table class=\"table table-striped\">/g" '{}' \; | |
# Add btn classes to buttons | |
find View/ -name "*.ctp" -exec sed -i "s/view\(.*\))/view\1, array('class' => 'btn btn-default'))/g" '{}' \; | |
find View/ -name "*.ctp" -exec sed -i "s/edit\(.*\))/edit\1, array('class' => 'btn btn-info'))/g" '{}' \; | |
find View/ -name "*.ctp" -exec sed -i "s/delete\(.*\), null/delete\1, array('class' => 'btn btn-danger')/g" '{}' \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var session = express.session(); | |
// Slightly Invasive | |
app.get('/home', session, routes.home); | |
app.get('/about', routes.about); | |
app.get('/faq', routes.faq); | |
// or | |
// Crude |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
set -x | |
### How To Use | |
# | |
# sudo bash -c 'bash \ | |
# <(curl -sLB https://raw.github.com/gist/5080906/bootstrap_chef_server_rpm.sh) \ | |
# --hostname foo.example.com' | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Usage: ./gitclean.sh <branch> <path-to-match> | |
# Requires clean working tree (i.e. delete files in <path> and commit) | |
# | |
# Thom Seddon <thom@seddonmedia.co.uk> | |
git ls-tree --name-only -r $1 $2 | while read FILE; do | |
git filter-branch --index-filter "git rm --cached ${FILE}" HEAD | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sshs () { | |
case $1 in | |
vps) ssh name@domain.com ;; | |
aws) ssh ec2-user@really-long-aws-domain.com -p 2222 ;; | |
client) ssh client@clientdomain.com ;; | |
*) echo "Dont know '$1', sorry" ;; | |
esac | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var buggyAndroid = parseInt((/android (\d+)/.exec(window.navigator.userAgent.toLowerCase()) || [])[1], 10) < 4; | |
if (!history.pushState || buggyAndroid) { | |
if (window.location.hash) { | |
if(window.location.pathname !== '/') window.location.replace('/#!' + window.location.hash.substr(2)); //Hash and a path, just keep the hash (redirect) | |
} else { | |
window.location.replace('/#!' + window.location.pathname); //No hash, take path | |
} | |
} | |
//And then in app.config: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Test: | |
$ curl http://127.0.0.1:3000 | |
# With debug set to true | |
$ node test.js | |
OAuth2Error: The access token was not found | |
at OAuth2Error (/home/thom/Dev/node/t/node_modules/oauth2-server/lib/error.js:30:12) | |
at Authorise.getBearerToken (/home/thom/Dev/node/t/node_modules/oauth2-server/lib/authorise.js:70:17) | |
at run (/home/thom/Dev/node/t/node_modules/oauth2-server/lib/runner.js:15:14) | |
at runner (/home/thom/Dev/node/t/node_modules/oauth2-server/lib/runner.js:19:5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Copyright Thom Seddon 2015 | |
# MIT | |
# | |
if [ "$1" == "" ] || [ "$1" == "help" ]; then | |
echo "Usage: ~/.proxy <option>" | |
echo | |
echo " Options: " |