Skip to content

Instantly share code, notes, and snippets.

View bjoerge's full-sized avatar

Bjørge Næss bjoerge

View GitHub Profile
@bjoerge
bjoerge / 302
Last active August 29, 2015 14:01
curl -I -A 'Mozilla/5.0 (Linux; U; Android 4.2.2; nb-no; SM-G350 Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30' 'http://www.ranablad.no/api/reaktorcore/v1/roles/apdm/ranablad/me'
HTTP/1.1 302 Moved Temporarily
Server: Varnish
Location: http://mobil.ranablad.no/api/reaktorcore/v1/roles/apdm/ranablad/me
Accept-Ranges: bytes
Date: Mon, 12 May 2014 13:05:34 GMT
X-Varnish: 2475744373
Age: 0
Via: 1.1 varnish
Connection: close
$ curl -v bilkollektivet.no
* Adding handle: conn: 0x7fa0a9004400
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fa0a9004400) send_pipe: 1, recv_pipe: 0
* About to connect() to bilkollektivet.no port 80 (#0)
* Trying 77.40.153.36...
* Connected to bilkollektivet.no (77.40.153.36) port 80 (#0)
// Can you spot the bug? You will never se any errors in devtools/console when running this.
new Promise(function(reslove) {
resolve("Foo");
})
.then(function() {
console.log("Why is this never called?");
});
var EventEmitter = require("events").EventEmitter;
// A thing to manage/track state changes
// Changes passed to setState are queued up and effectuated in the next event loop tick
class Stateful extends EventEmitter {
constructor() {
this.state = this.getInitialState();
this._stateChangeQueue = [];
this._stateChangeInProgress = false;
@bjoerge
bjoerge / keybase.md
Created September 23, 2014 19:03
keybase.md

Keybase proof

I hereby claim:

  • I am bjoerge on github.
  • I am bjoerge (https://keybase.io/bjoerge) on keybase.
  • I have a public key whose fingerprint is 1CB9 3D09 AAEA C6D9 8F54 B971 9944 8770 48FC 8B0D

To claim this, I am signing this object:

@bjoerge
bjoerge / not-ok.js
Last active August 29, 2015 14:09
uglify warnings
(function () {
if (x && !(x + "1") && y) { // 1
var qq;
foo();
} else {
bar();
}
if (x || !!(x + "1") || y) { // 2
foo();
@bjoerge
bjoerge / rxjs-autocomplete.js
Last active August 29, 2015 14:12
Minimal rxjs autocomplete impl
// Based on https://github.com/Reactive-Extensions/RxJS/tree/master/examples/autocomplete
var Rx = require("rx-dom");
var querystring = require("querystring");
var jsonp = require("jsonp");
function searchWikipedia(term) {
return new Promise((resolve, reject) => {
var params = querystring.stringify({
@bjoerge
bjoerge / index.js
Created January 9, 2015 09:40
requirebin sketch
var EventEmitter = require("events").EventEmitter;
function PathEmitter() {
window.addEventListener('popstate', this._emitNavigate.bind(this));
EventEmitter.call(this);
}
PathEmitter.prototype = new EventEmitter();
PathEmitter.prototype._emitNavigate = function _emitNavigate() {
@bjoerge
bjoerge / nodeswitch.sh
Created January 14, 2015 10:24
Switch between io.js and node.js on OSX
alias useio='ln -sf /usr/local/bin/iojs /usr/local/bin/node && node -v'
alias usenode='(brew unlink node && brew link --overwrite node) > /dev/null && node -v'
@bjoerge
bjoerge / index.js
Created January 27, 2015 18:59
requirebin sketch
var concat = require('concat-stream');
function parseCSV(file) {
var parser = csvParse({
delimiter: ',',
auto_parse: true,
columns: true
});
return new Promise(function(resolve, reject) {