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.
| app.directive('ngFocus', ['$parse', function($parse) { | |
| return function(scope, element, attr) { | |
| var fn = $parse(attr['ngFocus']); | |
| element.bind('focus', function(event) { | |
| scope.$apply(function() { | |
| fn(scope, {$event:event}); | |
| }); | |
| }); | |
| } | |
| }]); |
| function addLoadEventListener (listener) { | |
| var done, oldonload; | |
| if(typeof addEventListener !== "undefined") { | |
| return addEventListener("load", listener, false); | |
| } | |
| if(typeof attachEvent !== "undefined") { | |
| return attachEvent("onload", listener); | |
| } |
| /*global module:false*/ | |
| module.exports = function(grunt) { | |
| // Project configuration. | |
| grunt.initConfig({ | |
| // Metadata. | |
| pkg: grunt.file.readJSON('package.json'), | |
| aws: grunt.file.readJSON('config/grunt-aws.json'), | |
| datetime: Date.now(), | |
| jshint: { |
| // Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc | |
| // jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/ | |
| // author: Pawel Kozlowski | |
| var myApp = angular.module('myApp', []); | |
| //service style, probably the simplest one | |
| myApp.service('helloWorldFromService', function() { | |
| this.sayHello = function() { | |
| return "Hello, World!" |
| -- show running queries (pre 9.2) | |
| SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
| FROM pg_stat_activity | |
| WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
| ORDER BY query_start desc; | |
| -- show running queries (9.2) | |
| SELECT pid, age(clock_timestamp(), query_start), usename, query | |
| FROM pg_stat_activity | |
| WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
| /** | |
| * 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 | |
| * | |
| */ |
| // ---------------------------------------------------------- | |
| // 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) {} |
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.
| 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 |
| 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'); |