Skip to content

Instantly share code, notes, and snippets.

View dasniko's full-sized avatar

Niko Köbler dasniko

View GitHub Profile
package jug.da.lottery;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class Lottery {
var interval = 50;
startRaffle = function() {
[LED1, LED2, LED3].forEach(function(pin) {
setInterval(function() {
digitalWrite(pin, Math.random() > 0.5);
}, interval);
});
};
@dasniko
dasniko / app.js
Last active August 29, 2015 14:08
Simple Node.js/Express app
var express = require('express')
var app = express()
// respond with "Hello World!" on the homepage
app.get('/', function (req, res) {
res.send('<h1>Hello JavaScript!</h1>');
});
// accept POST request on the homepage
app.post('/', function (req, res) {
res.send('Got a POST request</h1>');
@dasniko
dasniko / fib.js
Created November 19, 2014 06:56
Fibonacci/Array Benchmark Test (JavaScript)
var fibonacci = function() {
var i;
var fib = [];
fib[0] = 1;
fib[1] = 1;
for(i = 2; i <= 100; i++) {
fib[i] = fib[i-2] + fib[i-1];
}
fib;
};
@dasniko
dasniko / FibonacciBenchmark.java
Created November 19, 2014 07:07
Fibonacci & Array/List Benchmark (Java)
package de.nko.benchmark;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @author Niko Koebler, http://www.n-k.de, @dasniko
*
*/
var http = require("http"),
redis = require("redis");
var redisClient = redis.createClient(6379, "127.0.0.1", {});
var TTL = 300;
var server = http.createServer(function(request, response) {
var headers = {"Content-Type": "text/plain"};
if (request.method.toUpperCase() !== "POST") {
response.writeHead(405, headers);
@dasniko
dasniko / nashorn-polyfill.js
Last active May 28, 2018 15:40
necessary JavaScript polyfills for working with Nashorn JS-engine
var global = this;
var window = this;
var process = {env: {}};
var console = {};
console.debug = print;
console.warn = print;
console.log = print;
@dasniko
dasniko / tools.md
Last active October 17, 2016 07:46
My favourite JavaScript tools

My favourite JavaScript tools

This list is subject to change at any time, just as tools an my personal view changes.
Additionally, these are just my the ones I prefer, does not mean that I don't know nor like others!

Programming Languages

  • JavaScript in ECMAScript 2015 (ES6) or higher
    • ES5 only if really needed, as you always can use Babel
  • TypeScript
@dasniko
dasniko / keybase.md
Created October 28, 2017 20:26
keybase.md

Keybase proof

I hereby claim:

  • I am dasniko on github.
  • I am dasniko (https://keybase.io/dasniko) on keybase.
  • I have a public key ASAIPZokcnTYoxb9pRpue-YRXawuvDpwpX7mc_Qp_6gLuQo

To claim this, I am signing this object:

package dasniko.util;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
/**
* @author Niko Köbler, https://www.n-k.de, @dasniko
*/
public class ToStringUtil {