Skip to content

Instantly share code, notes, and snippets.

View goloroden's full-sized avatar
💭
The best way to predict the future is to invent it.

Golo Roden goloroden

💭
The best way to predict the future is to invent it.
View GitHub Profile
@goloroden
goloroden / app.js
Last active June 22, 2023 02:10
Async constructors for JavaScript
// In JavaScript, constructors can only be synchronous right now. This makes sense
// from the point of view that a constructor is a function that returns a newly
// initialized object.
//
// On the other hand, it would sometimes be very handy, if one could have async
// constructors, e.g. when a class represents a database connection, and it is
// desired to establish the connection when you create a new instance.
//
// I know that there have been discussions on this on StackOverflow & co., but
// the so-far mentioned counter arguments (such as: doesn't work as expected
@goloroden
goloroden / cla.md
Created May 17, 2017 16:43
Contributor license agreement (CLA) v1

Contributor license agreement (CLA)

This CLA is by and between

the native web GmbH Hauptstraße 8 79359 Riegel am Kaiserstuhl Germany

  • hereinafter referred to as the native web
@goloroden
goloroden / dnn.js
Created August 21, 2016 09:20
A very, very simple neural network (with only 1 neuron ;-))
'use strict';
const input = 0.5;
const expected = 0.8;
let weight = 0.5;
const alpha = 0.1;
const iterations = 100;
for (let i = 0; i < iterations; i++) {
@goloroden
goloroden / gist:bb3204e721ac5af32c3a
Created April 19, 2015 19:16
Countdown with (do)
(defun launch (n)
(do ((cnt n (- cnt 1)))
((zerop cnt) (format t "Blast off!"))
(format t "~S..." cnt)))
(defun cookie-monster ()
(format t "~&Give me cookie!!!")
(format t "~&Cookie? ")
(let ((x (read)))
(cond ((eq x 'cookie)
(format t "~&Thank you!...Munch munch munch...BURP"))
(t
(format t "~&No want ~S..." x)
(cookie-monster)))))
@goloroden
goloroden / gist:d8a97f72b7608b8e9c62
Last active August 29, 2015 14:19
Some recursive functions
(defun anyoddp (l)
(cond ((null l) nil)
((oddp (car l)) t)
(t (anyoddp (cdr l)))))
(defun fact (n)
(cond ((zerop n) 1)
(t (* n (fact (1- n))))))
(defun laugh (n)
@goloroden
goloroden / gist:3400e4fc7a21417f4276
Last active August 29, 2015 14:19
Some card playing code…
(defun rank (card)
(car card))
(defun suit (card)
(cadr card))
(setf my-hand '((3 hearts)
(5 clubs)
(2 diamonds)
(4 diamonds)
@goloroden
goloroden / gist:0a758e6612980c105dab
Created April 6, 2015 12:58
"Rock, paper, scissors" in Lisp
(defun play (a b)
(cond ((equal a b) 'tie)
((or (and (equal a 'rock) (equal b 'scissors))
(and (equal a 'scissors) (equal b 'paper))
(and (equal a 'paper) (equal b 'rock))) '(first wins))
(t '(second wins))))
npm info it worked if it ends with ok
npm verb cli [ 'node',
npm verb cli '/Users/golo/.nvm/versions/node/v0.12.0/bin/npm',
npm verb cli 'install',
npm verb cli 'myorg/myrepo',
npm verb cli '--loglevel=silly' ]
npm info using [email protected]
npm info using [email protected]
npm sill cache add args [ 'myorg/myrepo', null ]
npm verb cache add spec myorg/myrepo
@goloroden
goloroden / knockat.go
Created November 20, 2014 22:19
My first Go app
package main
import (
"net"
"os"
"time"
)
func main() {
host := os.Args[1] + ":" + os.Args[2]