Skip to content

Instantly share code, notes, and snippets.

@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>
@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 / 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 / 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 / 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 / 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 / http.js
Last active August 19, 2016 05:50
Gun and webpack
var express = require('express'),
app = express();
var Gun = require('gun');
var gun = Gun({
file: 'data.json'
});
gun.wsp(app);
app.use(express.static(__dirname)).listen(9000);
@kristian76
kristian76 / main.js
Created August 27, 2016 09:26
React and Gun showing list of Github issues
/**
* Main.js
*/
'use strict';
import React from 'react'
import { render } from 'react-dom'
const gun = Gun(location.origin +'/gun');
const GUN_PATH = 'repo_42';
/*
* JavaScript Pretty Date
* Copyright (c) 2011 John Resig (ejohn.org)
* Licensed under the MIT and GPL licenses.
* prettyDate("2008-01-28T20:24:17Z") // => "2 hours ago"
* prettyDate("2008-01-27T22:24:17Z") // => "Yesterday"
* prettyDate("2008-01-26T22:24:17Z") // => "2 days ago"
* prettyDate("2008-01-14T22:24:17Z") // => "2 weeks ago"
* prettyDate("2007-12-15T22:24:17Z") // => undefined
@kristian76
kristian76 / index.js
Last active November 22, 2016 17:16
task board made with rect
/**
* index.js
*/
"use strict";
// Require app specific CSS
require('./app.css');
import React from 'react';
import ReactDOM from 'react-dom';