Skip to content

Instantly share code, notes, and snippets.

View karlpokus's full-sized avatar
💭
wohoo!

carl-fredrik grimberg karlpokus

💭
wohoo!
View GitHub Profile
@karlpokus
karlpokus / moduleTest.md
Created November 16, 2016 16:48
testing core node modules with the REPL

testing core node modules with the REPL

The default evaluator will automatically load Node.js core modules into the REPL environment when used... https://nodejs.org/api/repl.html

$ node
> querystring.parse("")
{}

Easy peezy lemon sqeezy!

@karlpokus
karlpokus / swing-easing.md
Last active November 23, 2016 13:38
the easing function `swing` is really `easeOutQuad` in jQuery easing lib compared to plain jQuery
@karlpokus
karlpokus / pipeToMe.js
Created October 30, 2016 13:18
pipe to js. Pipe from file, echo or just pass some args
#!/usr/bin/env node
// 1. add shebang above
// 2. make file executable
// $ chmod +x pipeToMe.js
// 3. pipe from file
// $ cat file | ./pipeToMe.js
// 4. pipe from echo
// $ echo -n one two | ./pipeToMe.js
// 5. just pass some args
@karlpokus
karlpokus / secretary.js
Created October 20, 2016 09:35
n people take turns taking notes at the weekly meeting @Company. Whose turn is it week x?
function secretary(people, weekNumber){
var index = weekNumber % people.length;
return people[index];
}
@karlpokus
karlpokus / uuid.js
Last active October 20, 2016 09:11
Create unique id in js
// http://stackoverflow.com/a/2117523/1983554
function createId() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
}
@karlpokus
karlpokus / ts.md
Last active July 1, 2018 00:10
nodeJS - file ts - time created, modified
@karlpokus
karlpokus / mute.md
Created September 27, 2016 16:05
console.mute @uppsalaJS 2016-09-27

console.mute

usage

  • readme

how does it work?

  • node api - console
  • console.js

some tests

@karlpokus
karlpokus / piping.md
Last active September 27, 2016 08:37
Piping is fun! Maybe control flow is a more suitable title but who cares?

Piping is fun!

unix

$ ls | grep test

ExpressJS

app.get('/', fn1, fn2, fn3); // or pass an array
@karlpokus
karlpokus / url.md
Last active October 13, 2016 12:59
URL parts for dummies