Skip to content

Instantly share code, notes, and snippets.

@torgeir
torgeir / identd-spoof
Created January 2, 2015 14:03
Spoof identd with xinetd
# file: /etc/xinet.d/identd-spoof
service identd-spoof
{
socket_type = stream
protocol = tcp
user = root
wait = no
server = /home/torgeir/bin/identd-spoof
flags = IPv6
@torgeir
torgeir / open-iisexpress-port-from-vmware-to-os-x
Last active August 29, 2015 14:13
Open iisexpress port through windows 8 firewall from vmware to os x
# put vmware in "Bridged" mode
# open your windows firewall ("everyone" seems to be windows-locale specific, so you might have to use something else for windowses not in english)
netsh http add urlacl url=http://*:53843/ user=everyone
netsh advfirewall firewall add rule name="iisexpress port" dir=in action=allow protocol=TCP localport=53843
# find the following line in ~/Documents/IISExpress/config/applicationhost.config for your app
<binding protocol="http" bindingInformation="*:53843:localhost" />
# add the following line below it with the ip from running ipconfig
@torgeir
torgeir / change-version-of-nuget-package.sh
Last active August 29, 2015 14:14
Change version of nuget package
# after changing the version (e.g. a roll back) of a version of a nuget package, e.g. RestSharp, run
Update-Package -Reinstall RestSharp -ProjectName ProjectName
# clean
# rebuild
@torgeir
torgeir / Kommuner.cs
Last active August 29, 2015 14:15
c# norges kommuner pr 16 feb 2015
// http://hotell.difi.no/?dataset=ssb/regioner/kommuner
public class Kommune {
public string Nummer { get; private set; }
public string Navn { get; private set; }
public Kommune(string nummer, string navn) {
Nummer = nummer;
Navn = navn;
@torgeir
torgeir / mocha.html
Created February 19, 2015 20:09
Run mocha locally in the browser
<!doctype html>
<meta charset=utf-8>
<title>tests</title>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/2.0.0/chai.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.js"></script>
<script>
var m = new Mocha({ ui: 'bdd' });
var context = {};
m.suite.emit('pre-require', context, null, m);
@torgeir
torgeir / lens.js
Created March 1, 2015 15:23
functional lens javascript
var lens = function (get, set) {
var f = function (value) { return get(value); };
f.set = set;
return f;
};
var first = lens(
function (value) { return value[0]; },
function (value, n) { return [n].concat(value.slice(1)); });
@torgeir
torgeir / transducers.js
Created April 10, 2015 21:29
Understanding transducers.js
function Map (f, form) {
this.f = f;
this.form = form;
}
Map.prototype = {
'@@transducer/init': function () {
return this.form['@@transducer/init']();
},
'@@transducer/step': function (acc, v) {
return this.form['@@transducer/step'](acc, this.f(v));
@torgeir
torgeir / transducers-clj.js
Last active August 29, 2015 14:19
transducers.js like in clojure
const comp = (...fns) => v => fns.reduce((acc, fn) => fn(acc), v);
const inc = x => v => v + x;
const incOne = inc(1);
const log = console.log.bind(console);
log([1, 2, 3].reduce((acc, v) => {
acc.push(incOne(v));
@torgeir
torgeir / PlayingWithAkka.java
Created May 5, 2015 21:18
Playing with Akka - ala clojure agents
package gd.wa;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.actor.UntypedActor;
import akka.pattern.Patterns;
import akka.util.Timeout;
import scala.concurrent.Future;
import scala.concurrent.duration.FiniteDuration;
@torgeir
torgeir / clojure-java-interop-calling-java-from-clojure.java
Last active August 29, 2015 14:20
Clojure Java interop - calling java from clojure
package gd.wa;
public class Result {
public final int value;
public Result(int value) {
this.value = value;
}