Skip to content

Instantly share code, notes, and snippets.

@webspectyler
webspectyler / post-commit
Last active October 11, 2015 05:08 — forked from brunohq/post-commit
git post-commit hook to update referenced task status in Asana amd FreshBooks with commit message
#!/bin/sh
apikey=$(git config user.asana-key)
if [ $apikey == '' ] ; then exit 0; fi
comment=$(git log --pretty=oneline -n1)
taskid_pattern='.*#([0-9]*).*'
if [[ $comment = ~$taskid_pattern ]]; then
taskid=${BASH_REMATCH[1]}
else
@webspectyler
webspectyler / gist:4348716
Last active December 10, 2015 00:08
Bash script to upload last committed files in git to FTP
for i in `git diff-tree -r --name-only HEAD^ HEAD`; do curl -T "$i" ftp://example.com/$i --user username:password --ftp-create-dirs; done
@webspectyler
webspectyler / gist:4980186
Last active December 13, 2015 21:49
Use Yii Models in custom PHP code
<?php
/**** Initialize Yii */
require_once($_SERVER['DOCUMENT_ROOT'].'/path/to/yii/framework/yii.php');
Yii::createWebApplication($_SERVER['DOCUMENT_ROOT'] . '/path/to/config/main.php');
// ...
$product = Product::model()->findByPk(3);
@webspectyler
webspectyler / import_utf8.sh
Created October 8, 2013 15:31
Specify file encoding in a mysql import
mysql -h host -u username -p password --default_character_set utf8 database < file.sql
@webspectyler
webspectyler / cp.sh
Created October 9, 2013 12:22
Copy all files including hidden directories
cp -a /mnt/sda8/john/. /mnt/sdb2/JOHN103
@webspectyler
webspectyler / fixperms.sh
Created October 9, 2013 13:00
Fix permissions in cPanel when getting 500 errors and Forbidden 403 errors
#! /bin/bash
#
# Date: Jan 26th 2012
# Author: Colin R.
# Revisions: Jacob "Boom Shadow" Tirey (boomshadow.net)
# Fixperms script for ServInt
#
# Fixperms script for cPanel servers running suPHP or FastCGI.
# Written for ServInt.net
# Copyright (C) 2012 Colin R.
@webspectyler
webspectyler / .gitconfig
Created November 14, 2013 19:40
Git aliases
s = status
a = add
co = checkout
cm = commit
unadd = reset HEAD
df = diff -w
ds = diff --staged
st = status -sb
amend = commit --amend -C HEAD
undo = reset --soft HEAD^
@webspectyler
webspectyler / queries.sql
Created December 9, 2013 19:05
Clicks and 90 day survey responses
# (Below are the queries that generated these files, for my reference)
SELECT `247_response`. * , `247_contract`.`title`
FROM `247_response`
LEFT JOIN `247_contract` ON `247_response`.`contract_id` = `247_contract`.`contract_id`
ORDER BY `response_id` DESC
# ^ Survey Responses
SELECT `247_click`. * , `247_contract`.`title`
@webspectyler
webspectyler / gist:167671d01fbdba80976d99d62bfc9eae
Created June 13, 2016 14:02 — forked from craiggists/gist:2268146
SublimeText: Tab to move cursor out of parentheses, quotes, brackets
// Original by C0D312
// I added the single quote and curly brace to the regex.
// http://www.sublimetext.com/forum/viewtopic.php?f=3&t=5174
//
// Add the following to your user keybindings:
[
{ "keys": ["tab"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
[
{ "key": "following_text", "operator": "regex_contains", "operand": "^[)}'\"\\]]", "match_all": true },
@webspectyler
webspectyler / show-varnish-hits-in-log.sh
Created June 22, 2016 21:25
Show varnish hits in log
varnishncsa -c -m "TxHeader:X-Varnish-Cache: HIT" | grep example.com