This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Universal mongodb reduce function for complex objects | |
// | |
// Example: | |
// | |
// emit({ total_views: 3, page_type: {home: 1, product: 2}, site_id: [1] }) | |
// emit({total_views: 5, page_type: {home: 1, collection: 4}, site_id: [2]}) | |
// | |
// -> reduce | |
// | |
// { total_views: 8, page_type: { home: 2, product: 2, collection: 4 }, site_id: [1,2] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The code below shows example usage of the SecureHash class for | |
* encrypting a password. In terms of additional usage, you should | |
* store the resulting encrypted password in addition to the salt | |
* in your db. | |
*/ | |
// load the class | |
$secure = new SecureHash(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('itemServices', ['ngResource']) | |
.factory('Item', ['$resource', | |
function ($resource) { | |
return $resource('items/:id', | |
{id: '@id'}, | |
{ | |
query: { | |
isArray: true, | |
method: 'GET', | |
params: {}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function curl_json($base_url='',$query='',$json=true){ | |
//set the url to use | |
$target_url = 'http://www.mydomain.com/json_script.json'; | |
$url == ($base_url='' ? $target_url : $base_url) ; | |
//set default json | |
$default_json ='[you json string here]'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -L https://gist.github.com/westonruter/ea038141e46e017d280b/download | tar -xvz --strip-components=1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git config --global alias.tree 'log --graph --full-history --all --color --date=short --pretty=format:"%Cred%x09%h %Creset%ad%Cblue%d %Creset %s %C(bold)(%an)%Creset"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ---------------------- | |
# Status Bar | |
# ----------------------- | |
set-option -g status on # turn the status bar on | |
set -g status-utf8 on # set utf-8 for the status bar | |
set -g status-interval 5 # set update frequencey (default 15 seconds) | |
set -g status-justify centre # center window list for clarity | |
# set-option -g status-position top # position the status bar at top of screen | |
# visual notification of activity in other windows |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// npm install bcrypt | |
var bcrypt = require('bcrypt'); | |
var password = process.argv[2]; | |
bcrypt.genSalt(function(err, salt) { | |
if (err) { | |
console.log(err); | |
} | |
console.log('salt: ' + salt + ' (length: ' + salt.length + ')'); |
OlderNewer