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 / mininal-maven-pom.xml
Last active Sep 12, 2019
A minimal maven pom.xml
View mininal-maven-pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>gd.wa</groupId>
<artifactId>minimal-pom</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
@torgeir
torgeir / nohup-rsync-with-password.sh
Created Jan 9, 2016
How to run rsync with password in background from a NAS's ssh
View nohup-rsync-with-password.sh
RSYNC_PASSWORD=... nohup rsync -av /DataVolume/Folder/* rsync://rsync@server:873/Folder/ &
@torgeir
torgeir / elmish.js
Last active Jul 19, 2019
A plain js take on @ccorcos elmish
View elmish.js
const declare = function (dispatch, state) {
const view = function () {
if (state.error) {
return <p>Error: { state.error }</p>;
}
if (state.loading) {
return <p>Clock: Loading..</p>;
}
@torgeir
torgeir / #1 - Scala macros tutorial.md
Last active Jul 6, 2019
A quick howto on getting started with scala macros (from the scala macros paradise branch, using sbt and sbt gen-idea)
View #1 - Scala macros tutorial.md

Scala macros tutorial, using sbt

The following steps executed in order will;

  • create the project file structure
  • set the sbt version
  • add the gen-idea sbt plugin (if you want to import your project into intellij)
  • create an sbt build, that builds the macros project prior to the macrostest project (so the regex macro is usable in the macrostest project)
  • create the macros project scala file
  • create the macrostest project scala file
View react-scaled-file-upload.js
function resize (file, maxWidth, maxHeight, fn) {
var reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function (event) {
var dataUrl = event.target.result;
var image = new Image();
image.src = dataUrl;
image.onload = function () {
@torgeir
torgeir / resize-home-folder-partition-on-ubuntu-snappy-core-on-the-raspberry-pi-2.md
Last active May 1, 2019
Resize home folder partition on ubuntu snappy core on the raspberry pi 2
View resize-home-folder-partition-on-ubuntu-snappy-core-on-the-raspberry-pi-2.md

Note where home is

(RaspberryPi2)root@localhost:~# df -h /home/
Filesystem      Size  Used Avail Use% Mounted on
/dev/mmcblk0p4   1.6G 1.3G   160M  89% /oem
(RaspberryPi2)root@localhost:~# df -h
@torgeir
torgeir / aws-stream-logs-from-cloudwatch-lambda-es--lambda-code.js
Created Aug 4, 2016
AWS stream logs from "cloudwatch -> lambda -> es" node.js lambda-code
View aws-stream-logs-from-cloudwatch-lambda-es--lambda-code.js
// v1.1.2
var https = require('https');
var zlib = require('zlib');
var crypto = require('crypto');
var endpoint = '<aws es endpoint>';
exports.handler = function(input, context) {
// decode input from base64
var zippedInput = new Buffer(input.awslogs.data, 'base64');
@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 / gulpfile.js
Last active Apr 2, 2019 — forked from markgoodyear/01-gulpfile.js
Example gulpfile.js
View gulpfile.js
// Load plugins
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
clean = require('gulp-clean'),
@torgeir
torgeir / compile.cljs
Last active Mar 9, 2019
Using clojurescript to compile clojurescript
View compile.cljs
(ns example.core
(:require [cljs.js :as cjs]
[cljs.analyzer :as ana :include-macros true]
[cljs.reader :as r]
[cljs.pprint :as pprint]))
(enable-console-print!)
(let [src "(ns t.math)
(defn increase [n] (inc n))"
You can’t perform that action at this time.