Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Zammit zamnuts

View GitHub Profile
@zamnuts
zamnuts / docker-machine-rename
Last active Dec 30, 2017 — forked from alexproca/docker-machine-rename
Rename docker-machine
View docker-machine-rename
#!/usr/bin/env zsh
# usage: docker-machine-rename default my-default
function docker-machine-rename {
oldName="$1";
newName="$2";
[ -z "$oldName" -o -z "$newName" ] && echo "Must specify both the old and new machine names" && return 2;
storePathRoot=$(docker-machine inspect -f '{{ .Driver.StorePath }}' "$oldName");
View libinput-gestures.conf
# for Ubuntu 16.10 GNOME 3.20
# on dell precision 5520
# configured against http://github.com/bulletmark/libinput-gestures rev d0bf9e0
# see https://wiki.gnome.org/Design/OS/KeyboardShortcuts
# expo equivalent toggle
gesture swipe up 3 xdotool key super
gesture swipe down 3 xdotool key super
# browser back/forward
View json-enumerable-defineproperties.js
var C = function C(a,b) {
this.a = a||'';
this.b = b||'';
};
Object.defineProperties(C.prototype,{
a: {
configurable: true,
enumerable: true,
get: function() {
View migrate-with-transform.js
var MongoClient = require('mongodb').MongoClient;
MongoClient.connect('mongodb://localhost/fromdb',function(err,dbLocal) {
if ( err ) throw err;
MongoClient.connect('mongodb://remotehost/todb',function(err,dbRemote) {
if ( err ) throw err;
var collectionLocal = dbLocal.collection('fromcollection'),
collectionRemote = dbRemote.collection('tocollection'),
queryLocal = {field:'value'};
collectionLocal.find(queryLocal).each(function(err,docLocal) {
@zamnuts
zamnuts / break-on-exception.js
Last active Aug 3, 2016
enable break on exception
View break-on-exception.js
/*
* filename: index.js
* run: node--debug-brk index.js
* tested in node v0.10.30
*/
global.v8debug.Debug.setBreakOnException(); // enable it, global.v8debug is only defined when --debug flag is set
setTimeout(function() {
bogus(); // should break here, "`bogus` is not defined"
},2000);
@zamnuts
zamnuts / bson-utf8-overhead
Created Jul 25, 2014
MongoDB stores a String as a BSON Symbol with a fixed overhead of 39 bytes.
View bson-utf8-overhead
var bson = require('bson').BSONPure;
var str = 'привет';
var buf = new Buffer(str);
console.log({
str: str, // 'привет'
buf: buf, // <Buffer d0 bf d1 80 d0 b8 d0 b2 d0 b5 d1 82>
strLen: str.length, // 6
bufLen: buf.length, // 12
bufBytes: Buffer.byteLength(str,'utf8'), // 12
@zamnuts
zamnuts / jade-userDefineLang.xml
Created Jun 26, 2014
jade npp notepad++ userDefineLang
View jade-userDefineLang.xml
<NotepadPlus>
<UserLang name="Jade" ext="jade" udlVersion="2.1">
<Settings>
<Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="yes" Keywords5="yes" Keywords6="yes" Keywords7="no" Keywords8="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments">03/* 04*/ 00// 00//- 01 02</Keywords>
<Keywords name="Numbers, prefix1"></Keywords>
<Keywords name="Numbers, prefix2"></Keywords>