Skip to content

Instantly share code, notes, and snippets.

View roobie's full-sized avatar

Björn Roberg roobie

View GitHub Profile
@roobie
roobie / .gitconfig
Created December 1, 2015 12:47
global gitconfig for windows example
[user]
name = Björn Roberg
email = bjorn.roberg@gmail.com
[core]
autocrlf = true
excludesfile = C:\\Users\\Bjorn\\Documents\\gitignore_global.txt
editor = 'C:/Program Files (x86)/Vim/vim74/gvim.exe'
@roobie
roobie / Result.js
Created December 1, 2015 13:44
a port of the `Result` type in Rust
'use strict';
const Result = function Result() {};
const Err = function Err(value) {
this.value = value;
};
const Ok = function Ok(value) {
this.value = value;
}
Result.match = function match(result, matcher, dynamicThis) {
@roobie
roobie / cond.js
Last active December 7, 2015 09:46
cond, almost like in lisp
/**
@example:
```javascript
const result = cond(
[false, () => 'this should not be'],
[Boolean(), () => 'Boolean defaults to false'],
[true, () => '`true` can be considered the "catch all" symbol in a cond expr.']
);
```
@roobie
roobie / recursive.erl
Last active December 11, 2015 09:23
reverse, tail call optimised.
-module(recursive).
reverse(L) ->
reverse_tco([], L).
reverse_tco(Acc, []) ->
Acc;
reverse_tco(Acc, [Head|Tail]) ->
reverse_tco([Head|Acc], Tail).
// ==UserScript==
// @name NeverNewTab
// @description Never open a new tab if you don't want it
// @namespace http//roberg.nu/NeverNewTab
// @license WTFPL
// @include http*
// @grant none
// @version 0.0.1
// @encoding utf-8
//
@roobie
roobie / tap-spec-webpack-plugin.js
Last active February 1, 2016 18:45
a webpack plugin that is used to enable continuous testing via webpack compilation
/*
The following packages are required (other versions may work)
"tap-spec": "^4.1.1",
"lodash": "^4.1.0",
--
minimal webpack config:
```
module.exports = {
target: 'node',
execute pathogen#infect()
syntax on
filetype plugin indent on
set background=dark
colorscheme solarized
set tabstop=2
@roobie
roobie / config.el
Created February 9, 2016 23:42 — forked from mars888/config.el
Quick and dirty Spacemacs configuration layer for Tide and TypeScript
(spacemacs|defvar-company-backends typescript-mode)
@roobie
roobie / Random.hx
Created February 29, 2016 14:49
uniform Int for Haxe
package;
class TestUniform {
public static
function testDistribution():Bool {
var n:Int;
var res = [];
var popSize = 100000;
var chunkSize = 100;
var range = {from: 0, to: 4};
@roobie
roobie / jsintro.md
Last active November 16, 2018 09:54 — forked from joladev/jsintro.md
JavaScript Intro

Disciplin

JS är ett dynamiskt, svagt typat språk, vilket innebär att många skyddsnät som man är van vid när man använder ett statisk, starkt typat språk, som exv C#, inte finns.

Detta ställer höga krav på utvecklaren att skriva tydlig kod samt att implementera tillräckligt med felhantering och/eller kollar för att vara säker på att värden finns och är av rätt underliggande typ innan man använder dem.

ES2015, ESNext, TS etc.

Väldigt stor skillnad på vad man har tillgängligt beroende på vilken specifikation man bestämmer sig för att använda. Dagens webbläsare har kommit långt i att implementera moderna (läs ES2015) features, men man kan inte vara säker på att de har stöd för allt. Därför väljer man oftast i nya projekt att kompilera sin kod mot ES5, som det finns stöd för ända ned till IE9.