Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
set -e
dir=$(cd ${1:-.} && pwd)
if [ $? -ne 0 ] || [ ! -d "$dir" ] || [ ! -w "$dir" ]; then
echo "$dir can not writable directory, abort."
exit 1
fi
@jiskanulo
jiskanulo / pre-commit
Created June 16, 2015 12:23
Git pre-commit hook: detect file size over 100MB
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
# Redirect output to stderr.
@jiskanulo
jiskanulo / pre-commit
Last active August 29, 2015 14:17
Git pre-commit hook: php syntax check
#!/bin/bash
CURRENT_DIR="$(pwd)"
HAS_ERROR=""
for file in $(git status -s | grep -E '^[AMU].*\.php$' | awk '{print $2}' | sort | uniq); do
if [ "$(php -l $(pwd)/$file 2>&1 | grep 'Parse error')" != "" ]; then
HAS_ERROR="1"
echo "Syntax errors found: $file" >&2
fi
@jiskanulo
jiskanulo / phpinfo.php
Last active April 12, 2016 11:15
phpinfo
<?php
// validate client ip address
$allow_ips = [
'::1',
'10.0.2.2',
'127.0.0.1',
'192.168.33.1',
];
@jiskanulo
jiskanulo / gist:a11987953d743b44da1b
Created March 20, 2015 08:49
What will be displayed?
<?php
$key = 0;
switch($key) {
case 'one': echo 'one'; break;
case 'two': echo 'two'; break;
case 'three': echo 'tree'; break;
default: echo 'other'; break;
}
LANG=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
USER=vagrant
LOGNAME=vagrant
HOME=/home/vagrant
PATH=/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
MAIL=/var/mail/vagrant
SHELL=/usr/bin/zsh
SSH_CLIENT=10.0.2.2 50247 22
SSH_CONNECTION=10.0.2.2 50247 10.0.2.15 22
noaliases off
allexport off
noalwayslastprompt off
alwaystoend on
noappendhistory off
autocd on
autocontinue off
noautolist off
noautomenu off
autonamedirs on
1='cd +1'
2='cd +2'
3='cd +3'
4='cd +4'
5='cd +5'
6='cd +6'
7='cd +7'
8='cd +8'
9='cd +9'
_=sudo
@jiskanulo
jiskanulo / my-env.plugin.zsh
Created May 9, 2014 02:04
oh-my-zsh plugin for my env file loader
function import_setting()
{
[ -f $1 ] && . $1
}
for f in $HOME/.zsh.d/* ; do
import_setting $f
done
if [ $commands[brew] ]; then
@jiskanulo
jiskanulo / install_oh_my_zsh_plugins.sh
Last active August 29, 2015 13:59
install my custom oh-my-zsh plugins
#!/bin/bash
function git_clone()
{
[ -z "$ZSH" ] && return
url=https://gist.github.com/$1.git
name=$2
path=$ZSH/custom/plugins/$name