Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
| #!/bin/bash | |
| #### | |
| # Split MySQL dump SQL file into one file per table | |
| # based on http://blog.tty.nl/2011/12/28/splitting-a-database-dump | |
| #### | |
| if [ $# -lt 1 ] ; then | |
| echo "USAGE $0 DUMP_FILE [TABLE]" | |
| exit |
Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
| #!/usr/bin/env ruby | |
| # This pre-commit hook will prevent any commit to forbidden branches | |
| # (by default, "staging" and "production"). | |
| # Put this file in your local repo, in the .git/hooks folder | |
| # and make sure it is executable. | |
| # The name of the file *must* be "pre-commit" for Git to pick it up. | |
| FORBIDDEN_BRANCHES = ["staging", "production"] |
As configured in my dotfiles.
start new:
tmux
start new with session name:
| <?php | |
| function get_ip_address() { | |
| $ip_keys = array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR'); | |
| foreach ($ip_keys as $key) { | |
| if (array_key_exists($key, $_SERVER) === true) { | |
| foreach (explode(',', $_SERVER[$key]) as $ip) { | |
| // trim for safety measures | |
| $ip = trim($ip); | |
| // attempt to validate IP | |
| if (validate_ip($ip)) { |
| # Copyright (C) 2011 Anurag Priyam - MIT License | |
| module Jekyll | |
| # Jekyll plugin to generate tag clouds. | |
| # | |
| # The plugin defines a `tag_cloud` tag that is rendered by Liquid into a tag | |
| # cloud: | |
| # | |
| # <div class='cloud'> |
| ### | |
| A meta-compilation of: | |
| https://raw.github.com/gist/1453705/d253733a56632a8d2c29321a75c18b627fa4dda8/reserved_usernames.rb | |
| http://blog.postbit.com/reserved-username-list.html | |
| http://www.quora.com/How-do-sites-prevent-vanity-URLs-from-colliding-with-future-features | |
| (Took out some company-specific terms at the top of the first one (e.g. imulus, stacks), added one term so far - 'edits'.) | |
| NOTE: Does not include profanities. You may or may not want to add a list of those. | |
| (See https://www.google.com/search?q=profanity+list, but don't try to apply regexp's here because Scunthorpe - http://en.wikipedia.org/wiki/Scunthorpe_problem) |
| # the following two lines give a two-line status, with the current window highlighted | |
| hardstatus alwayslastline | |
| hardstatus string '%{= kG}[%{G}%H%? %1`%?%{g}][%= %{= kw}%-w%{+b yk} %n*%t%?(%u)%? %{-}%+w %=%{g}][%{B}%m/%d %{W}%C%A%{g}]' | |
| # huge scrollback buffer | |
| defscrollback 5000 | |
| # no welcome message | |
| startup_message off |
| # | |
| # File compressor plugin for jekyll | |
| # ================================= | |
| # | |
| # By [mytharcher](https://github.com/mytharcher) | |
| # 2012-05-20 | |
| # | |
| # Updated by [nicoespeon](https://github.com/nicoespeon) | |
| # 2013-04-12 | |
| # |
| Latency Comparison Numbers (~2012) | |
| ---------------------------------- | |
| L1 cache reference 0.5 ns | |
| Branch mispredict 5 ns | |
| L2 cache reference 7 ns 14x L1 cache | |
| Mutex lock/unlock 25 ns | |
| Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
| Compress 1K bytes with Zippy 3,000 ns 3 us | |
| Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
| Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |