This file contains hidden or 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
| //I've not tested this yet, it's an idea, that might become a proof of concept | |
| //It could definitely do with a clean, and eventually a nice re-usable function call | |
| __granularChangePush(changes){ | |
| if(changes.length>0 && typeof this.__api == 'function'){ | |
| return recursivePromise(this.__api.bind(this),changes,0) | |
| } | |
| function recursivePromise(_list,index){ | |
| return new Promise((resolve,reject)=>{ | |
| createRecursivePromise([_list,index],(list)=>{(list.length>0?resolve:reject)(l)},doStuff) |
This file contains hidden or 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
| # below is my prompt-y bit of choice: `current-dir ~ ` | |
| #export PS1="\[\e[33m\]\W \[\e[35m\]~ \[\e[m\]" | |
| #export PROMPT_COMMAND='echo -ne "\033]0;${PWD/#$HOME/~}\007"' | |
| # or something a little fancier: `current-dir <random fruit>` | |
| #FRUITS=(🍎 🍐 🍊 🍋 🍌 🍉 🍇 🍓 🍒 🍑 🍍 🥝) | |
| #export PS1="\[\e[33m\]\W \[\e[35m\]${FRUITS[$(echo $RANDOM%12 | bc)]} \[\e[m\]" | |
| # for a new fruit on each line, rather than one per session | |
| # export PROMPT_COMMAND='echo -ne "${FRUITS[$(echo $RANDOM%12 | bc)]} "' | |
| alias zed="open -a /Applications/zed.app" |
This file contains hidden or 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
| #!/usr/bin/env node | |
| const path = require('path'); | |
| const fs = require('fs'); | |
| const cmdr = require('commander'); | |
| //this requires Cairo: https://www.npmjs.com/package/canvas | |
| // brew install pkg-config cairo libpng jpeg giflib | |
| const Canvas = require('canvas'); | |
| const Image = Canvas.Image; |
This file contains hidden or 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
| // use like: | |
| // ctx.fillStyle='rgba(256,256,256,1)'; | |
| // arrow(ctx, img.width/2, img.height/2, 90, 60); | |
| function arrow(ctx, x, y, width, height) { | |
| // x and y are the center | |
| //TODO: take a direction, currently l->r | |
| ctx.beginPath(); | |
| ctx.moveTo(x - (width/2), y-(height/2)+(height/3)); | |
| // down | |
| ctx.lineTo(x - (width/2), y-(height/2)+(height/3*2)); |
This file contains hidden or 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
| // Say we have `names=[['johnny','rotten'],['gene','simmons']]` and want `johnny rotten and gene simmons` | |
| // `join2D(names,' ',' and ')` | |
| const join2D = (names, sep1, sep2) => (names.map(n=>n.join(sep1)).join(sep2)) |
This file contains hidden or 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
| #!/usr/bin/env node | |
| const path = require('path'); | |
| const fs = require('fs'); | |
| const cmdr = require('commander'); | |
| //this requires Cairo: https://www.npmjs.com/package/canvas | |
| // brew install pkg-config cairo libpng jpeg giflib | |
| const Canvas = require('canvas'); | |
| cmdr |
This file contains hidden or 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
| query { | |
| viewer { | |
| #user(login:"davidsharp"){ | |
| login | |
| gists(last:50){ | |
| nodes{ | |
| path: name | |
| description | |
| isPublic | |
| } |
This file contains hidden or 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
| /* | |
| EXAMPLE: | |
| const kringle = new Kringle([ | |
| {name: 'foo bar', email: 'foobar@baz.com', group:1}, | |
| {name: 'bar baz', email: 'barbaz@foo.com', group:1}, | |
| {name: 'baz foo', email: 'bazfoo@bar.com', group:2}, | |
| {name: 'foo baz', email: 'foobaz@bar.com', group:3}, | |
| ]) | |
| kringle.run() | |
| kringle.list.forEach((c,i)=>( |
This file contains hidden or 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
| #!/usr/bin/env node | |
| 'use strict'; | |
| const path = require('path'); | |
| const fs = require('fs'); | |
| const cmdr = {path:process.argv[process.argv.length-1]} | |
| console.log('Manipulating : '+cmdr.path); | |
| if(!cmdr.path){console.log('No path given');process.exit();} |
This file contains hidden or 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
| #!/usr/bin/env node | |
| 'use strict'; | |
| // > npm i -g commander; npm i -g canvas; | |
| // this also requires Cairo: https://www.npmjs.com/package/canvas | |
| // > brew install pkg-config cairo libpng jpeg giflib | |
| const path = require('path'); | |
| const fs = require('fs'); | |
| const cmdr = {path:process.argv[process.argv.length-1]} |