This is a list of the various code style guides I've printed out and (try to) abide by. There are endless style guides on the internet, these are just the ones I use wherever possible.
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
function money_commands($dep) { | |
$total = 0; | |
$dep = str_replace(',', '', $dep); | |
preg_match_all('#[0-9]{1,}(m|M)#', $dep, $matches); | |
foreach($matches AS $v) { | |
foreach($v AS $val) { | |
$x = str_ireplace('m', '', $val); | |
$dep = str_replace($val, '', $dep); | |
$total += $x*1000000; |
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
var http = require('http'), | |
httpProxy = require('http-proxy'); | |
// | |
// Setup proxy server with forwarding | |
// | |
var options = { | |
router: { | |
'proxytest.randylubin.com': '127.0.0.1:7200', | |
'randylubin.com': '127.0.0.1:7200', |
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
//usage | |
withAdvice.call(targetObject); | |
//mixin augments target object with around, before and after methods | |
//method is the base method, advice is the augmenting function | |
withAdvice: function() { | |
['before', 'after', 'around'].forEach(function(m) { | |
this[m] = function(method, advice) { | |
if (typeof this[method] == 'function') { | |
return this[method] = fn[m](this[method], advice); |
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
//usage | |
withAdvice.call(targetObject); | |
//mixin augments target object with around, before and after methods | |
//method is the base method, advice is the augmenting function | |
withAdvice: function() { | |
['before', 'after', 'around'].forEach(function(m) { | |
this[m] = function(method, advice) { | |
if (typeof this[method] == 'function') { | |
return this[method] = fn[m](this[method], advice); |
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
var chainer = new Sequelize.Utils.QueryChainer() | |
Artist.find({ where: {name: name} }).success(function(artist) { | |
if (artist) { | |
// get all tracks | |
artist.getTracks().success(function (tracks) { | |
if (tracks.length > 0) { | |
tracks.forEach(function(track) { | |
chainer.add(track.getArtists()) | |
}) |
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
// This is in classMethods: | |
a_method: function(id, order_id) { | |
var query1 = s.Utils.format(['query goes here...']); | |
var query2 = s.Utils.format(['query goes here....']); | |
return new s.Utils.CustomEventEmitter(function(emitter) { | |
db.query(query1, null, {raw:true}).success(function(row1){ | |
db.query(query2, null, {raw:true}).success(function(row2){ | |
emitter.emit('success', {results1: row1, results2: row2}); | |
}); |
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
/* | |
* object.watch polyfill | |
* | |
* 2012-04-03 | |
* | |
* By Eli Grey, http://eligrey.com | |
* Public Domain. | |
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. | |
*/ |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Simple Stack</title> | |
<script src="http://d3js.org/d3.v2.js"></script> | |
<style> | |
svg { | |
border: solid 1px #ccc; | |
font: 10px sans-serif; | |
shape-rendering: crispEdges; |
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
# sample shortcuts | |
{ "keys": ["ctrl+super+]"], "command": "snap_lines_to_indent_level", "args": { "snap_direction": 1 } }, | |
{ "keys": ["ctrl+super+["], "command": "snap_lines_to_indent_level", "args": { "snap_direction": -1 } } |