Skip to content

Instantly share code, notes, and snippets.

Alejandro Gomez alexserver

Block or report user

Report or block alexserver

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@alexserver
alexserver / circularref
Created Jan 27, 2015
Circular Reference in Javascript, and how to avoid it.
View circularref
//https://www.npmjs.com/package/json-stringify-safe
var stringify = require("json-stringify-safe");
var a = {
type: "Son",
name: "John"
};
var b = {
type: "father",
View siftjs
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},
@alexserver
alexserver / commands_user
Created Dec 23, 2014
Commands User RegReplace
View commands_user
[
{
"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"
]}
@alexserver
alexserver / settings_user
Created Dec 23, 2014
settings user regReplace
View settings_user
{
"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": {
View gist:917089b4ce10fd6faaee
$ cd /usr/local
$ git fetch origin
$ git reset --hard origin/master
@alexserver
alexserver / update_mongodb
Created Nov 18, 2014
update many records in mongodb
View update_mongodb
//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}});
});
@alexserver
alexserver / RegReplace custom conf
Created Nov 5, 2014
Custom configuration to remove garbage from google docs.
View RegReplace custom conf
// 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",
View .profile
# 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
@alexserver
alexserver / gist:698921006bb12133015e
Created May 30, 2014
replace single quotes by double quotes with regex in SublimeText or any editor.
View gist:698921006bb12133015e
//how to replace all single quotes by double quotes:
//search/replace, check regex.
//search:
'([^\']*)'
//replace:
"$1"
View chaijs
var ChaiJS = require("chai");
// make ChaiJS + SinonJS available to all tests
GLOBAL.should = ChaiJS.should;
GLOBAL.expect = ChaiJS.expect;
GLOBAL.assert = ChaiJS.assert;
You can’t perform that action at this time.