Skip to content

Instantly share code, notes, and snippets.

View dbrattli's full-sized avatar
👨‍💻
Python ❤️ F#

Dag Brattli dbrattli

👨‍💻
Python ❤️ F#
View GitHub Profile
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* */
/* Simple node js module to get distance between two coordinates. */
/* */
/* Code transformed from Chris Veness example code - please refer to his website for licensing */
/* questions. */
/* */
/* */
/* Latitude/longitude spherical geodesy formulae & scripts (c) Chris Veness 2002-2011 */
/* - www.movable-type.co.uk/scripts/latlong.html */
@dbrattli
dbrattli / lol.py
Last active December 28, 2015 21:09
List out of lambda, Python versions
empty_list = None
def prepend(el, lst):
def func(selector):
return selector(el, lst)
return func
def head(lst):
def selector(h, t):
return h
@dbrattli
dbrattli / IEnumerable.fs
Last active October 16, 2018 18:25
IEnumerable
type IDisposable =
abstract member Dispose: unit -> unit
type IEnumerator<'a> =
inherit IDisposable
abstract member Current : 'a with get
abstract member MoveNext : unit -> bool
abstract member Reset : unit -> unit
type IEnumerable<'a> =
@dbrattli
dbrattli / IEnumeratorT.cs
Last active October 16, 2018 17:38
.NET IEnumerator<T>
public interface IDisposable {
void Dispose();
}
public interface IEnumerator<out T> : IDisposable
{
T Current {
get;
}
@dbrattli
dbrattli / gist:a61e7de3ca5c0269f436
Last active August 29, 2015 14:23
Python help for RxPY flat_map_latest
>>> from rx import Observable
>>> help(Observable.flat_map_latest)
@dbrattli
dbrattli / actions.py
Last active May 12, 2016 05:51
Closing over loop variable considered harmful
actions=[]
for x in range(10):
actions.append(lambda: print(x))
for act in actions:
act()
// A (synchronous) value
let value = 42
// A (synchronous) function returning a value
let func () =
42
let value = func ()
open System.Threading
// A (synchronous) function taking a long time before returning a value
let blockingFunc () =
Thread.Sleep 5000
42
@dbrattli
dbrattli / SyncBlockingForever.fs
Last active October 7, 2018 08:30
SyncBlockingForever
// A (synchronous) function that might block forever
let later () =
System.Console.ReadLine()