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://github.com/microsoft/TypeScript/blob/ba5e86f1406f39e89d56d4b32fd6ff8de09a0bf3/src/compiler/checker.ts | |
// 1. add this line to ln:3 | |
export const _conditionalTypes: any = {} | |
// 2. then replace ln:12303 to ln:12360 | |
function trackConditionalType() { | |
// one time stuff |
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
# Version key/value should be on his own line | |
PACKAGE_VERSION=$(cat package.json \ | |
| grep version \ | |
| head -1 \ | |
| awk -F: '{ print $2 }' \ | |
| sed 's/[",]//g' \ | |
| tr -d '[[:space:]]') | |
echo $PACKAGE_VERSION |
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
// Params | |
// 1. {} add a query in here if you don't want to select all records (unlikely) | |
// 2. $rename one or more fields by setting the keys of the object to the old field name and their values to the new field name. | |
// 3. Set multi to true to force it to operate on all documents otherwise it will only operate on the first document that matches the query. | |
// | |
// Run this in the MongoDB shell. | |
db.<collectionName>.update( {}, { $rename: { '<oldName1>': '<newName1>', '<oldName2>': '<newName2>' } }, {multi: true} ) |
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
// Params: | |
// 1. query (filter) if you only want to remove this field from some records. {} will select any. | |
// 2. $unset the field(s) that you want to remove. Here I've set them to null but the value doesn't matter as it's ignored. | |
// 3. multi must be set to true otherwise it will only operate on the first record that it finds. | |
// | |
// Run this command in the MongoDB shell | |
db.<collectionName>.update( {}, {$unset: {<fieldName1>: null, <fieldName2>: null}}, {multi: true}); |
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
// If you want to convert an IEnumerable to a dictionary using LINQ then do: | |
Dictionary<string, object> dict = myList.ToDictionary(a => a.MyString, a => a.MyObject); |
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
function int2ip (ipInt) { | |
return ( (ipInt>>>24) +'.' + (ipInt>>16 & 255) +'.' + (ipInt>>8 & 255) +'.' + (ipInt & 255) ); | |
} |
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
// Require.js allows us to configure shortcut alias | |
require.config({ | |
// The shim config allows us to configure dependencies for | |
// scripts that do not call define() to register a module | |
shim: { | |
'socketio': { | |
exports: 'io' | |
}, | |
'underscore': { | |
exports: '_' |
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
// suggested shell cmd line to run this: | |
// | |
// mongo --shell example2.js | |
// | |
// Note: the { out : … } parameter is for mongodb 1.8+ | |
db.things.insert( { _id : 1, tags : ['dog', 'cat'] } ); | |
db.things.insert( { _id : 2, tags : ['cat'] } ); | |
db.things.insert( { _id : 3, tags : ['mouse', 'cat', 'dog'] } ); | |
db.things.insert( { _id : 4, tags : [] } ); |