Skip to content

Instantly share code, notes, and snippets.

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 Jan 20, 2021
Async constructors for JavaScript
View app.js
// 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
Contributor license agreement (CLA) v1
View cla.md

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 Aug 21, 2016
A very, very simple neural network (with only 1 neuron ;-))
View dnn.js
'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++) {
View gist:bb3204e721ac5af32c3a
(defun launch (n)
(do ((cnt n (- cnt 1)))
((zerop cnt) (format t "Blast off!"))
(format t "~S..." cnt)))
View gist:94ec8bda51f953b43386
(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 Aug 29, 2015
Some recursive functions
View gist:d8a97f72b7608b8e9c62
(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 Aug 29, 2015
Some card playing code…
View gist:3400e4fc7a21417f4276
(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 Apr 6, 2015
"Rock, paper, scissors" in Lisp
View gist:0a758e6612980c105dab
(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))))
View gist:7bc7d34937f71b331211
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 npm@2.5.1
npm info using node@v0.12.0
npm sill cache add args [ 'myorg/myrepo', null ]
npm verb cache add spec myorg/myrepo
@goloroden
goloroden / knockat.go
Created Nov 20, 2014
My first Go app
View knockat.go
package main
import (
"net"
"os"
"time"
)
func main() {
host := os.Args[1] + ":" + os.Args[2]