Skip to content

Instantly share code, notes, and snippets.

View addisaden's full-sized avatar
🔍
Research Trip

addisaden addisaden

🔍
Research Trip
View GitHub Profile
@addisaden
addisaden / fib_cache.js
Created October 24, 2012 21:00
fib-cached function in js
var fib_cached = function() {
cache = new Array;
this.exec = function(n) {
if(n <= 0) {
return 0;
}
if(cache[n] != undefined) {
return this.cache[n];
}
if(n > 2) {
@addisaden
addisaden / cached_fibonacci.html
Created October 25, 2012 17:09
cached fibonacci calculation
<!--
This file in action: http://23g.eu/fibonacci/
-->
<html>
<head>
<title>fibonacci | wdeu</title>
<script type="text/javascript"><!--
var fib_obj = function () {
var cache = {};
@addisaden
addisaden / config
Created October 26, 2012 00:05
my i3 config -> save in ~/.i3/config
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout somewhen, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
@addisaden
addisaden / .vimrc
Created October 26, 2012 00:06
vim config
" juhu - bunte Fraben...
syntax on
" Zeilenummerierung ist toll
set number
" Zeilenumbrüche stören
set nowrap
" rückwärtskompatibilität von vim abschalten
@addisaden
addisaden / .bashrc
Created October 26, 2012 00:13
my .bashrc file
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
@addisaden
addisaden / is_return_evil_just_callbacks.js
Created December 1, 2012 13:42
Why is this code blocking?
var worker_clb = function(name, clb) {
var d = new Date();
for(var i = 0; i < 100000000; i++) {
i+i;
}
clb(name + "_clb returns after " + ((new Date()) - d) + " ms.");
}
var a_lot_to_do = function(name, clb) {
@addisaden
addisaden / fuzzy-test.rb
Last active December 10, 2015 19:08
Just a fun snippet for FUZZY-LOGIC
# encoding: utf-8
# please visit the repository of fuzzy-logic: https://github.com/addisaden/fuzzy-logic
require "fuzzy-logic"
temp = FuzzyLogic::Collection.new("Temperatures in °C") { |value|
value.is_a?(Numeric) ? (value <= 100 and value >= -100 ? true : false) : false
}
@addisaden
addisaden / cmd-app.rb
Last active December 10, 2015 19:58
Experiments to write a command-line app.
#!/usr/bin/env ruby
# encoding: utf-8
#
# good source: http://whatisthor.com/
require "thor"
class MyCmd < Thor
desc "hello [NAME]", "say hello to NAME"
require "highline/import"
user = ask("username: ")
password = ask("password: ") { |p|
p.echo = '*'
}
function hallo(name) {
alert('Hallo, ' + name + '!');
}
function welt(callback_function) {
callback_function('Welt');
}
welt(hallo); // => alert("Hallo, Welt!")