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 cjs-shim.js
self.setImmediate = cb => Promise.resolve().then(cb)
var fsModule = new Blob([`
module.exports = {
readdirSync() {
return []
},
readFileSync(file) {
const xhr = new XMLHttpRequest()
@FireNeslo
FireNeslo / web-crypto-jwt.js
Last active Jun 19, 2019
JWT tokens using web crypto
View web-crypto-jwt.js
import crypto from 'isomorphic-webcrypto'
const encoder = new TextEncoder()
const decoder = new TextDecoder()
const ALGORITHMS = {
HS: { name: 'HMAC' },
ES: { name: 'ECDSA', namedCurve: 'P-256' },
RS: { name: 'RSASSA-PKCS1-v1_5', modulusLength: 2048, publicExponent: new Uint8Array([0x01, 0x00, 0x01]) },
PS: { name: 'RSA-PSS', saltLength: 128, modulusLength: 2048, publicExponent: new Uint8Array([0x01, 0x00, 0x01]) },
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) {
You can’t perform that action at this time.