Skip to content

Instantly share code, notes, and snippets.

View dasniko's full-sized avatar

Niko Köbler dasniko

View GitHub Profile
@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 / 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;
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 / 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
*
*/
@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 / 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>');
var interval = 50;
startRaffle = function() {
[LED1, LED2, LED3].forEach(function(pin) {
setInterval(function() {
digitalWrite(pin, Math.random() > 0.5);
}, interval);
});
};
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 {