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.
| =Navigating= | |
| visit('/projects') | |
| visit(post_comments_path(post)) | |
| =Clicking links and buttons= | |
| click_link('id-of-link') | |
| click_link('Link Text') | |
| click_button('Save') | |
| click('Link Text') # Click either a link or a button | |
| click('Button Value') |
| // see http://paulirish.com/2011/requestanimationframe-for-smart-animating/ | |
| // shim layer with setTimeout fallback | |
| window.requestAnimFrame = (function(){ | |
| return window.requestAnimationFrame || | |
| window.webkitRequestAnimationFrame || | |
| window.mozRequestAnimationFrame || | |
| window.oRequestAnimationFrame || | |
| window.msRequestAnimationFrame || |
| $ git branch -r --merged | | |
| grep origin | | |
| grep -v '>' | | |
| grep -v master | | |
| xargs -L1 | | |
| awk '{split($0,a,"/"); print a[2]}' | | |
| xargs git push origin --delete |
| @mixin box-shadow($top, $left, $blur, $color, $inset: false) { | |
| @if $inset { | |
| -webkit-box-shadow:inset $top $left $blur $color; | |
| -moz-box-shadow:inset $top $left $blur $color; | |
| box-shadow:inset $top $left $blur $color; | |
| } @else { | |
| -webkit-box-shadow: $top $left $blur $color; | |
| -moz-box-shadow: $top $left $blur $color; | |
| box-shadow: $top $left $blur $color; | |
| } |
| function encrypt(text){ | |
| var cipher = crypto.createCipher('aes-256-cbc','d6F3Efeq') | |
| var crypted = cipher.update(text,'utf8','hex') | |
| crypted += cipher.final('hex'); | |
| return crypted; | |
| } | |
| function decrypt(text){ | |
| var decipher = crypto.createDecipher('aes-256-cbc','d6F3Efeq') | |
| var dec = decipher.update(text,'hex','utf8') |
| var crypto = require('crypto') | |
| , key = 'salt_from_the_user_document' | |
| , plaintext = 'password' | |
| , cipher = crypto.createCipher('aes-256-cbc', key) | |
| , decipher = crypto.createDecipher('aes-256-cbc', key); | |
| cipher.update(plaintext, 'utf8', 'base64'); | |
| var encryptedPassword = cipher.final('base64') | |
| decipher.update(encryptedPassword, 'base64', 'utf8'); |
| gg_replace() { | |
| if [[ "$#" == "0" ]]; then | |
| echo 'Usage:' | |
| echo ' gg_replace term replacement file_mask' | |
| echo | |
| echo 'Example:' | |
| echo ' gg_replace cappuchino cappuccino *.html' | |
| echo | |
| else | |
| find=$1; shift |
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.
| // ---------------------------------------------------------- | |
| // A short snippet for detecting versions of IE in JavaScript | |
| // without resorting to user-agent sniffing | |
| // ---------------------------------------------------------- | |
| // If you're not in IE (or IE version is less than 5) then: | |
| // ie === undefined | |
| // If you're in IE (>=5) then you can determine which version: | |
| // ie === 7; // IE7 | |
| // Thus, to detect IE: | |
| // if (ie) {} |
| /** | |
| * RequireJS Plugin - CSS Loader | |
| * | |
| * [ex.] | |
| * define(['css!jquery-ui-css', 'jquery', 'jquery-ui'], { }); | |
| * | |
| * Its better to put 'css!' in front of other js dependencies to get | |
| * faster loading speed | |
| * | |
| */ |