Skip to content

Instantly share code, notes, and snippets.

Øystein Ø. Olsen FireNeslo

Block or report user

Report or block FireNeslo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View struct.js
var structure = (function () {
"use strict";
function BaseStruct(values) {
for(var i= values.length-1; i>= 0; i--) {
this[i] = values[i]
}
}
BaseStruct.prototype.toJSON = function toJSON() {
var array = new Array(this.length)
for(var i = array.length-1; i >= 0; i--) {
@FireNeslo
FireNeslo / immap.js
Last active May 14, 2017
Immutable thingy
View immap.js
var {ARRAY, NUMBER, STRING, BOOLEAN, OBJECT} = {
ARRAY: Symbol('array'),
OBJECT: Symbol('object'),
NUMBER: Symbol('number'),
STRING: Symbol('string'),
BOOLEAN: Symbol('boolean'),
}
function flatMap(list, callback) {
const result = []
@FireNeslo
FireNeslo / demo.es6
Last active Jan 2, 2018
Simple es6 heredoc thingy
View demo.es6
var html = heredoc `
<section>
<h1> title</h1>
<p>content</p>
</section>
`
@FireNeslo
FireNeslo / base.es6
Created Oct 14, 2015
Base Mdoel es6
View base.es6
function belongsto(Class, property, descriptor) {
return {
get() {
return descriptor.get().find(this[property+'Id'])
},
set(id) {
return this[property+'Id'] = id.id || id
}
}
}
@FireNeslo
FireNeslo / index.js
Created Sep 18, 2015
requirebin sketch
View index.js
var Peer = require('simple-peer')
var client = new Peer({ initiator: true })
var server = new Peer()
var IPADDRESS = /[0-9]+(?:\.[0-9]+){3}/g
var addresses = []
function getIPs(signal) {
var result = null
Object.keys(signal||{}).forEach(function test(key) {
while(result = IPADDRESS.exec(signal[key])) {
@FireNeslo
FireNeslo / symbolic.js
Last active Aug 29, 2015
browserify transform for ruby style symbols
View symbolic.js
var through = require('through2');
var symbols = /¤([^\s,:;()\[\]{}=]+)/g
function strings(string, match) {
return "'" + match + "'"
}
module.exports = function (file) {
return through(function (buffer, enc, next) {
var input = buffer.toString('utf8')
View designer.html
<link rel="import" href="../polymer/polymer.html">
<polymer-element name="my-element" attributes="show left right open">
<template>
<style>
:host {
display block;
width: 100%;
box-sizing: border-box;
View promise.js
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define([], factory);
} else if (typeof exports === 'object') {
module.exports = factory();
} else {
root.Promise = factory();
}
}(this, function () {
function Promise(init) {
View namespace.js
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['injector'], factory);
} else if (typeof exports === 'object') {
module.exports = factory(require('./injector'));
} else {
root.namespace = factory(root.Injector);
}
}(this, function (Injector) {
var spaces = {};
@FireNeslo
FireNeslo / typeOf.js
Last active Aug 29, 2015
A better typeof function
View typeOf.js
function typeOf(object) {
if(object && "name" in object.constructor) {
return object.constructor.name;
}
if(typeof object === 'number' && object !== object) {
return 'NaN';
}
var type = Object.prototype.toString.call(object);
return type.substring(8,type.length-1);
}
You can’t perform that action at this time.