This file contains 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
//https://www.npmjs.com/package/json-stringify-safe | |
var stringify = require("json-stringify-safe"); | |
var a = { | |
type: "Son", | |
name: "John" | |
}; | |
var b = { | |
type: "father", |
This file contains 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 sift = require("sift"); | |
// var torender = [ { keypath: 'employee', | |
// template: '{{first_name}} {{ last_name }}' }, | |
// { keypath: 'employee.division', template: '{{division}}' }, | |
// { keypath: 'certificate_type', | |
// template: '{{#peoplesoft_id}}{{peoplesoft_id}}: {{/peoplesoft_id}}{{title}}' } ]; | |
var objects = [ | |
{n: 3}, |
This file contains 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
[ | |
{ | |
"caption": "Reg Replace: Google Docs to Ractive", | |
"command": "reg_replace", | |
"args": {"replacements": [ | |
"google_docs_remove_html", | |
"google_docs_remove_ractive_rows", | |
"unescape_html_tags_for_markup_open", | |
"unescape_html_tags_for_markup_close" | |
]} |
This file contains 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
{ | |
"replacements": { | |
// Example replacements | |
"google_docs_remove_html": { | |
"find": "(.|\\n)*<body((?!>).)*>(((?!<\\/body>).|\\n)+)<\\/body>(.|\\n)*", | |
"replace": "\\3", | |
"greedy": false, | |
"case": false | |
}, | |
"google_docs_remove_ractive_rows": { |
This file contains 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
$ cd /usr/local | |
$ git fetch origin | |
$ git reset --hard origin/master | |
This file contains 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
//in SQL | |
update mydoc set word = replace(word, 'some_undesired_word', '') | |
//in mongodb | |
db.mydoc.find().forEach(function(doc){ | |
if (!doc.word) return; | |
doc.word = doc.word.replace('some_undesired_word', ''); | |
db.mydoc.update({_id : doc._id}, {"$set":{"word":doc.word}}); | |
}); |
This file contains 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
// Configuration for removing html tags enclosing ractive conditionals, and also for removing html tags | |
// Defualt.sublime-commands | |
// To configure the commands that will be available in the command palette (Cmd + shift + P) | |
[ | |
{ | |
"caption": "Reg Replace: Google Docs delete garbage", | |
"command": "reg_replace", |
This file contains 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
# add these aliases to your BASH profile ~/.profile | |
alias mongodb-start="mongod run --config /usr/local/etc/mongod.conf" | |
alias redis-start="redis-server /usr/local/etc/redis.conf" | |
alias mongodb-stop="mongod --shutdown" | |
alias redis-stop="redis-cli shutdown" | |
# TODO fix mongod shutdown |
This file contains 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
//how to replace all single quotes by double quotes: | |
//search/replace, check regex. | |
//search: | |
'([^\']*)' | |
//replace: | |
"$1" |
This file contains 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 ChaiJS = require("chai"); | |
// make ChaiJS + SinonJS available to all tests | |
GLOBAL.should = ChaiJS.should; | |
GLOBAL.expect = ChaiJS.expect; | |
GLOBAL.assert = ChaiJS.assert; |