Skip to content

Instantly share code, notes, and snippets.

Torgeir Thoresen torgeir

Block or report user

Report or block torgeir

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
torgeir / index.js
Last active Oct 8, 2017
redux-observable example
View index.js
const Rx = require('rxjs/Rx');
const { createStore, applyMiddleware } = require('redux');
const { createEpicMiddleware, combineEpics } = require('redux-observable');
const inc = n => n + 1;
const reducer = function ({ count } = { count: 0 }, { type } = {}) {
switch (type) {
case "add":
return { count: inc(count) };
torgeir /
Last active Sep 19, 2017
GIt-kurs for nyansatte: Demo
torgeir /
Last active Apr 7, 2019
Connect wireless gopro to wireless router with two network interfaces

Connect wireless gopro to wireless router with two network interfaces

For a wireless router on with two network interfaces, e.g. wlan0 and wlan1, you can expose your gopro's live stream on a port on the router using the following setup.

Connect your machine to wlan0, ssh to your router, and run these iptables rules.

iptables -t nat -I PREROUTING -d -j DNAT --to-destination -p tcp --destination-port 8080
torgeir / yarn-two-versions-of-jquery.txt
Created Aug 23, 2017
Yarn: Two versions of jquery?
View yarn-two-versions-of-jquery.txt
~/Desktop/yarn-jquery-pickadate $ yarn add jquery@2.1.3
~/Desktop/yarn-jquery-pickadate $ yarn add pickadate
~/Desktop/yarn-jquery-pickadate $ cat yarn.lock
# yarn lockfile v1
version "2.1.3"
resolved ""
View minimal-redux-async-example.js
const initialState = Immutable.Map({ count: 42 });
const actions = {
click: function () {
return { type: "click" };
asyncClick: function () {
return function (dispatch) {
setTimeout(() => dispatch(, 1000);
torgeir / chrome-async-debug-example.js
Last active Aug 11, 2017
Chrome 60 async debugging, clever stepping
View chrome-async-debug-example.js
// async debugging in chrome 60
// cmd/ctrl click result when in `debugger` breakpoint
const sleep = s =>
new Promise(resolve => setTimeout(_ => resolve(s), 1000 * s));
function delayedFetch(url) {
return Promise.resolve()
torgeir / flattened-nested-promises-with-asyncawait.js
Last active Jun 7, 2017
Flatten nested promises with asyncawait + then or plain synchronous looking asyncawait.
View flattened-nested-promises-with-asyncawait.js
let wait = (s, data) =>
new Promise(resolve => setTimeout(resolve.bind(null, data),
s * 1000));
let loc = (l) =>
({ location: l });
let region = (r) =>
({ region: r,
locations: [wait(3, loc(`${r} loc 1`)),
torgeir / redux-ish.clj
Created May 28, 2017 — forked from nhusher/redux-ish.clj
Redux with basically no effort in clojurescript, plus core.async to handle asynchronous actions
View redux-ish.clj
(ns reduxish.state-tools
(:require-macros [cljs.core.async.macros :refer [go go-loop]])
(:require [cljs.core.async.impl.protocols :refer [WritePort ReadPort]]
[cljs.core.async :refer [<!]]))
(defn channel? [ch]
(and (satisfies? WritePort ch) (satisfies? ReadPort ch)))
(defn dispatch! [reducer state value]
(println value)
torgeir / profile-with-chrome-devtools-and-improve--improved.html
Last active Mar 28, 2017 — forked from anonymous/debug-me.html
Faggruppemøte 2017-03-28: Performance: Profile and timeline debugging example, and improved version.
View profile-with-chrome-devtools-and-improve--improved.html
<!DOCTYPE html>
<meta charset="UTF-8">
<title>Bad example to debug :D</title>
.colors .colorBlock {
display: inline-block;
width: 1em;
torgeir / clipboard-utils.clj
Last active Mar 1, 2017 — forked from Folcon/clipboard-utils.clj
Just a quick clipboard slip/slurp I put together because I didn't find anything similar, don't know if it's useful for anyone but found it invaluable when getting large strings being returned from the repl and sticking the result in an editor for more car
View clipboard-utils.clj
(defn get-clipboard []
(.getSystemClipboard (java.awt.Toolkit/getDefaultToolkit)))
(defn slurp-clipboard []
(if-let [contents (.getContents (get-clipboard) nil)]
(.getTransferData contents java.awt.datatransfer.DataFlavor/stringFlavor)))
(defn spit-clipboard [text]
(.setContents (get-clipboard) (java.awt.datatransfer.StringSelection. text) nil))
You can’t perform that action at this time.