Skip to content

Instantly share code, notes, and snippets.

View martinus's full-sized avatar
😎
warp! Help, I'm trapped in a time

Martin Leitner-Ankerl martinus

😎
warp! Help, I'm trapped in a time
View GitHub Profile
@martinus
martinus / DifferentialEvolution.cpp
Created September 22, 2014 07:53
Differential Evolution - Sample Code
/* Example adapted from http://www.drdobbs.com/database/differential-evolution/184410166
*
* This implements the DE/rand/1/bin optimization algorithm.
*
*/
/* Initialize individuals */
for (i=0; i<NP; i++) {
/* randomly initialize all individuals */
for (j=0; j<D; j++) {
@martinus
martinus / benchmark2.cpp
Created July 27, 2019 10:53
simple benchmark of robin_hood map, updated
#include <iostream>
#include <string>
#include <chrono>
#include <unordered_map>
#include "tsl/robin_map.h"
#include "robin_hood.h"
using my_clock = std::chrono::high_resolution_clock;
@martinus
martinus / benchmark.cpp
Created July 25, 2019 05:55
simple benchmark of tsl, robin_hood, and std::unordered_map
#include <iostream>
#include <string>
#include <chrono>
#include <unordered_map>
#include "tsl/robin_map.h"
#include "robin_hood.h"
using namespace std;
using my_clock = std::chrono::high_resolution_clock;
@martinus
martinus / .bashrc
Created May 4, 2018 07:59
awesome bash prompt
function prompt_timer_start {
PROMPT_TIMER=${PROMPT_TIMER:-`date +%s.%3N`}
echo -ne "\033]0;${@}\007"
}
function prompt_svn_stats() {
command -v svn >/dev/null
if [ $? != 0 ]; then
return
fi
#pragma once
/// MarsagliaMWC99 is a simple random number generator based on
/// George Marsaglia's MWC (multiply with carry) generator.
/// Although it is very simple, it passes Marsaglia's DIEHARD
/// series of random number generator tests. It is exceptionally fast.
///
/// @see http://www.codeproject.com/Articles/25172/Simple-Random-Number-Generation
/// @see http://www.bobwheeler.com/statistics/Password/MarsagliaPost.txt
/// @see http://mathforum.org/kb/message.jspa?messageID=1524861
@martinus
martinus / trie.rb
Created December 23, 2009 21:23 — forked from DataWraith/trie.rb
class TrieNode
def initialize
@sub_tries = {}
@end_of_word = false
end
def insert(input)
to_insert = input
package com.ankerl.stuff;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
/**
* Calls multiple methods with a single interface.
@martinus
martinus / CachedProxy.java
Created December 22, 2008 21:23
Create cached proxy automatically
package com.ankerl.proxy;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.Map;
/**
* Creates an intermediate proxy object for a given interface. All calls are
@martinus
martinus / anagrams-fast.rb
Created August 9, 2008 10:01
Two Word Anagram Finder Algorithm (in Ruby)
#!/usr/bin/ruby
# created by Martin Ankerl http://martin.ankerl.com/
class String
# creates an array of characters
def letters
unpack("c*")
end
end