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
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
torgeir / demo.org
Last active Sep 19, 2017
GIt-kurs for nyansatte: Demo
View demo.org
@torgeir
torgeir / connect-wireless-gopro-to-wireless-router-with-two-network-interfaces.md
Last active Apr 7, 2019
Connect wireless gopro to wireless router with two network interfaces
View connect-wireless-gopro-to-wireless-router-with-two-network-interfaces.md

Connect wireless gopro to wireless router with two network interfaces

For a wireless router on 192.168.1.1 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 192.168.1.1, and run these iptables rules.

iptables -t nat -I PREROUTING -d 192.168.1.1 -j DNAT --to-destination 10.5.5.9 -p tcp --destination-port 8080
@torgeir
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
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
jquery@2.1.3:
version "2.1.3"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-2.1.3.tgz#6ec55204673d505d39432c5bf5cfad10e1dbad2e"
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(actions.click()), 1000);
@torgeir
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
// https://developers.google.com/web/updates/2017/05/devtools-release-notes#step-into-async
// cmd/ctrl click result when in `debugger` breakpoint
const sleep = s =>
new Promise(resolve => setTimeout(_ => resolve(s), 1000 * s));
function delayedFetch(url) {
debugger;
return Promise.resolve()
@torgeir
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
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
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>
<html>
<head>
<meta charset="UTF-8">
<title>Bad example to debug :D</title>
<style>
.colors .colorBlock {
display: inline-block;
width: 1em;
@torgeir
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.