Open ~/.bash_profile in your favorite editor and add the following content to the bottom.
# Git branch in prompt.
parse_git_branch() {| exports.handler = (event, context, callback) => { | |
| var csd = new AWS.CloudSearchDomain({ | |
| endpoint: CS_NAME+'.'+SERVICES_REGION+'.cloudsearch.amazonaws.com', | |
| apiVersion: '2013-01-01' | |
| }); | |
| var params = { | |
| query: event.query, | |
| sort: '_score desc', |
| { | |
| "body" : $input.json('$'), | |
| "headers": { | |
| #foreach($header in $input.params().header.keySet()) | |
| "$header": "$util.escapeJavaScript($input.params().header.get($header))" #if($foreach.hasNext),#end | |
| #end | |
| }, | |
| "method": "$context.httpMethod", | |
| "params": { |
| { | |
| "vars": { | |
| "@gray-base": "#363b42", | |
| "@gray-darker": "lighten(@gray-base, 13.5%)", | |
| "@gray-dark": "lighten(@gray-base, 19.4%)", | |
| "@gray": "lighten(@gray-base, 33.5%)", | |
| "@gray-light": "lighten(@gray-base, 40%)", | |
| "@gray-lighter": "lighten(@gray-base, 69.9%)", | |
| "@brand-primary": "#359ce8", | |
| "@brand-success": "#00aeef", |
| <?php | |
| namespace Vendor\Bundle\Twig; | |
| /* | |
| services.yml: | |
| twig.base64: | |
| class: Vendor\Bundle\Twig\Base64 | |
| tags : | |
| - { name: twig.extension } |
| /* | |
| * Taken from http://stackoverflow.com/questions/5867534/how-to-save-canvas-data-to-file/5971674#5971674 | |
| */ | |
| var fs = require('fs'); | |
| // string generated by canvas.toDataURL() | |
| var img = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0" | |
| + "NAAAAKElEQVQ4jWNgYGD4Twzu6FhFFGYYNXDUwGFpIAk2E4dHDRw1cDgaCAASFOffhEIO" | |
| + "3gAAAABJRU5ErkJggg=="; | |
| // strip off the data: url prefix to get just the base64-encoded bytes |
| # post_loc.txt contains the json you want to post | |
| # -p means to POST it | |
| # -H adds an Auth header (could be Basic or Token) | |
| # -T sets the Content-Type | |
| # -c is concurrent clients | |
| # -n is the number of requests to run in the test | |
| ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/ |
| <?php | |
| public function all() | |
| { | |
| if (Request::ajax()) { | |
| $encoded_html = gzencode(Model::all(), 9); | |
| header('Content-Length: ' . strlen($encoded_html)); | |
| header('Content-Encoding: gzip'); | |
| return $encoded_html; | |
| } |
| var crypto = require('crypto'); | |
| var key = 'MySecretKey12345'; | |
| var iv = '1234567890123456'; | |
| var cipher = crypto.createCipheriv('aes-128-cbc', key, iv); | |
| var decipher = crypto.createDecipheriv('aes-128-cbc', key, iv); | |
| var text = 'plain text'; | |
| var encrypted = cipher.update(text, 'utf8', 'binary'); | |
| encrypted += cipher.final('binary'); | |
| hexVal = new Buffer(encrypted, 'binary'); |
| ## Slow requests grouped by function call | |
| cat /var/log/php-fpm/www-slow.log | grep -A 1 script_filename | \ | |
| grep -v script_filename | grep -v -e "--" | cut -c 22- | sort | uniq -c | sort -nr | |
| ## Slow requests grouped by minute | |
| cat /var/log/php-fpm/www-slow.log | grep 'pool www' | \ | |
| cut -d' ' -f2 | sort | cut -d: -f1,2 | uniq -c | |
| ## Top 25 1 minute groups of slow requests | |
| cat /var/log/php-fpm/www-slow.log | grep 'pool www' | cut -d' ' -f2 | \ |