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.
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.
// See: http://ejohn.org/blog/learning-from-twitter/ | |
(function($) { | |
$(document).ready(function() { | |
var resizeCallable = function() { | |
switch (true) | |
{ | |
case (window.innerWidth <= 768): | |
// Do some exciting device size specific magic here. | |
break; | |
} |
<?php | |
// See: https://gist.github.com/1942528 | |
trait Call_Dynamic_Methods | |
{ | |
public function __call($name, $arguments) | |
{ | |
if (isset($this->{$name}) && $this->{$name} instanceof Closure) { | |
$this->{$name} = $this->{$name}->bindTo($this, $this); | |
return call_user_func_array($this->{$name}, $arguments); | |
} |
#!/usr/bin/env php | |
<?php | |
function main($argv) { | |
$opts = getopt(null, array('min:', 'max:')); | |
$min = (int) isset($opts['min']) ? trim($opts['min']) : 0; | |
$max = (int) isset($opts['max']) ? trim($opts['max']) : 100; | |
puts("Guess The Number \n", 'green'); | |
puts("I'm thinking of a number between $min and $max \n\n"); |
#!/usr/bin/env python | |
import optparse, random, sys | |
def main(): | |
parser = optparse.OptionParser() | |
parser.add_option('--min', type="int", default=0, help="The minimum number limit.") | |
parser.add_option('--max', type="int", default=100, help="The maximum number limit.") | |
opts, args = parser.parse_args() | |
tries = 0 |
$('textarea.notes').on('focus blur keyup', function() { | |
var paddingTop = $(this).css('padding-top').replace('px', ''), | |
paddingBottom = $(this).css('padding-bottom').replace('px', ''); | |
$(this).css('height', '1px'); | |
$(this).css('height', (this.scrollHeight - paddingTop - paddingBottom) + 'px'); | |
}).blur(); |
# config/config.yml | |
defaults: &defaults | |
key: value | |
regexp: !ruby/regexp /pattern/ | |
development: | |
<<: *defaults | |
test: |
module ApplicationHelper | |
def build_page_title(*crumbs) | |
crumbs.map(&:to_s).reject(&:empty?).join(' - ') | |
end | |
end |
// Throttle / Debounce Plugin: http://benalman.com/projects/jquery-throttle-debounce-plugin/ | |
$(document).ready(function() { | |
var callback = function(event) { | |
event.preventDefault(); | |
// Do exciting things here. | |
}; | |
$('form.search').on({ | |
submit: callback, |
// Ensure iOS Safari fullscreen links don't open in external Safari. | |
$(document).ready(function() { | |
if (/(iPhone|iPod|iPad)/i.test(navigator.userAgent)) { | |
$('a').each(function() { | |
$(this).attr('href', 'javascript:window.location = "' + $(this).attr('href') + '"'); | |
}); | |
} | |
}); |