Skip to content

Instantly share code, notes, and snippets.

View zamnuts's full-sized avatar

Andrew Zammit zamnuts

View GitHub Profile
@zamnuts
zamnuts / yt-dlp-all
Created November 27, 2021 06:54
yt-dlp playlist concurrent downloader
#!/usr/bin/env zsh
playlistUrl="$1";
numParallelDownloads="${2:-5}";
numParallelFragments="${3:-5}";
[[ -z "$playlistUrl" ]] && echo 'i need a url to a yt playlist please.' >&2 && exit 1;
[[ "$numParallelDownloads" =~ '^[^0-9]+$' ]] && echo "expected parameter 2 to be the number of parallel downloads, got '$numParallelDownloads'." >&2 && exit 1;
[[ "$numParallelFragments" =~ '^[^0-9]+$' ]] && echo "expected parameter 3 to be the number of parallel fragments, got '$numParallelFragments'." >&2 && exit 1;
@zamnuts
zamnuts / docker-machine-rename
Last active December 30, 2017 03:04 — forked from alexproca/docker-machine-rename
Rename docker-machine
#!/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");
# 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
var C = function C(a,b) {
this.a = a||'';
this.b = b||'';
};
Object.defineProperties(C.prototype,{
a: {
configurable: true,
enumerable: true,
get: function() {
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 August 3, 2016 12:07
enable break on exception
/*
* 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 July 25, 2014 15:19
MongoDB stores a String as a BSON Symbol with a fixed overhead of 39 bytes.
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 June 26, 2014 06:26
jade npp notepad++ userDefineLang
<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>