Skip to content

Instantly share code, notes, and snippets.

@kristian76
kristian76 / Main.elm
Last active June 20, 2016 13:52
issuelist.elm for fetching issues from github
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.App as Html
import Html.Events exposing (..)
import Http
import Json.Decode as Json exposing ((:=))
import Json.Encode exposing (encode)
import Task
import Date exposing (Date)
import String
@kristian76
kristian76 / router.js
Created May 18, 2016 05:20
SPA RxJS based router
var hashChangeEvent = Rx.Observable.fromEvent(window, 'hashchange');
var hash = location.hash;
var hashSubject = new Rx.BehaviorSubject(hash);
hashSubject.subscribe(function(hash) {
router(hash.replace('#', ''));
});
hashChangeEvent.subscribe(function(e) {
hashSubject.onNext(location.hash);
@kristian76
kristian76 / micro-template-engine.js
Last active April 26, 2024 08:18
micro template engine
(function(){
var cache = {};
this.tmpl = function tmpl(str, data){
// Figure out if we’re getting a template, or if we need to
// load the template – and be sure to cache the result.
var fn = !/\W/.test(str) ?
cache[str] = cache[str] ||
tmpl(document.getElementById(str).innerHTML) :
@kristian76
kristian76 / package.json
Created March 22, 2016 14:43
React setup with Babel, Webpack and fetch run npm install to have it up and running. Run npm install serve to get a dev server for assets
{
"name": "reactworkbench",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "cd public && serve"
},
"author": "",
@kristian76
kristian76 / gist:4aa7a907c788a8b0fa69
Created March 1, 2016 14:52
Gun DB and node.js
/*
* Package.json
*/
{
"name": "gunner",
"version": "1.0.0",
"description": "",
"main": "http.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
@kristian76
kristian76 / dates
Created January 25, 2016 22:49
SVG and project timeline. Pretty damn ugly, but working
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Dates man</title>
</head>
<body>
<div id="chart"></div>
<script data-main="main.js" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.22/require.min.js"></script>
</body>