Skip to content

Instantly share code, notes, and snippets.

View elkorn's full-sized avatar

Korneliusz Caputa elkorn

View GitHub Profile
#include <omnetpp.h>
class Server : public cSimpleModule
{
private:
cQueue queue; //the queue; first job in the queue is being serviced
cMessage *departure; //message-reminder of the end of service (job departure)
simtime_t departure_time; //time of the next departure
cOutVector *proces;
cMessage *pomiar;
@elkorn
elkorn / curry.js
Created April 19, 2013 05:34
Functional JS recipes
function toArray(val) {
return Array.prototype.slice.call(val);
}
/**
* Curries a function with given arguments.
*
* @method curry
* @return {Function} The curried version of the given function/
*/
function getCleanContentHolders(argument) {
var iframe = document.createElement('iframe');
iframe.style.display = "none";
iframe = document.body.appendChild(iframe);
var _window = iframe.contentWindow;
var _document = iframe.contentDocument || iframe.contentWindow.document;
document.body.removeChild(iframe);
return {
window: _window,
document: _document
function cartesian_join(a, b, keys, select) {
output = [];
second = [];
while(row_b = b()) {
second[second.length] = row_b;
}
var cols = select;
if (cols) {
$.each(keys, function(i, c) {
@elkorn
elkorn / findFirst.js
Last active September 18, 2016 08:21
Various useful utility functions
/**
* Finds the first occurence of an element specified by the given function in a collection.
*
* @method findFirst
* @param {Array} collection The collection to search.
* @param {Function} fn The selector function used to find an element.
* @return {*} The first occurence of the element.
*/
function findFirst(collection) {
@elkorn
elkorn / debounce.js
Created November 5, 2013 07:11
Function debounce by Unscriptable
Function.prototype.debounce = function (threshold, execAsap) {
var func = this, timeout;
return function debounced () {
var obj = this, args = arguments;
function delayed () {
if (!execAsap)
func.apply(obj, args);
timeout = null;
# Clojure
This is a cross-listing of papers related to Clojure, it's core, contrib and popular libraries. Papers noted at Clojure talks, meetups, and conferences can be found here as well.
## Data Structures
* core.rrb-vector
* [RRB-Trees: Efficient Immutable Vectors](http://infoscience.epfl.ch/record/169879/files/RMTrees.pdf)
## Pattern Matching
* core.match
* [Compiling Pattern Matching to good Decision Trees](http://www.cs.tufts.edu/~nr/cs257/archive/luc-maranget/jun08.pdf)
@elkorn
elkorn / gist:a7335a85f91cd0d20d4c
Created January 20, 2015 19:14
Typed actor concept
class IntStringActor extends TypedActor[Int,String] {
private var state: Int = 0
override def work(msg: Int): String = state.toString
override def respondWith(msg: String)(sender: Sender): Unit = sender ! msg
override def receiveMessage(msg: Int): Unit =
state = state + msg
}
@elkorn
elkorn / sessions.json
Last active October 25, 2015 00:26
NDC 2015
{
"wednesday": [
{
"title": "Keynote - Data and Goliath: The Hidden Battles to Collect Your Data and Control Your World",
"speaker": "Bruce Schneier",
"tags": [
"Security"
],
"description": "You are under surveillance right now. Your cell phone provider tracks your location and knows who's with you. Your online and in-store purchasing patterns are recorded, and reveal if you're unemployed, sick, or pregnant. Your e-mails and texts expose your intimate and casual friends. Google knows what you're thinking because it saves your private searches. Facebook can determine your sexual orientation without you ever mentioning it. Corporations use surveillance to manipulate not only the news articles and advertisements we each see, but also the prices were offered. Governments use surveillance to discriminate, censor, chill free speech, and put people in danger worldwide. And both sides share this information with each other or, even worse, lose it to cybercriminals in huge data breaches. Much of
[DEBUG] [02/23/2016 19:03:59.467] [run-main-0] [EventStream(akka://default)] Default Loggers started
[DEBUG] [02/23/2016 19:03:59.543] [default-akka.actor.default-dispatcher-3] [PersistenceQuery(akka://default)] Create plugin: jdbc-read-journal akka.persistence.jdbc.query.journal.JdbcReadJournalProvider
[DEBUG] [02/23/2016 19:03:59.566] [default-akka.actor.default-dispatcher-4] [akka.persistence.Persistence(akka://default)] Create plugin: jdbc-journal akka.persistence.jdbc.journal.JdbcAsyncWriteJournal
[DEBUG] [02/23/2016 19:03:59.657] [default-akka.actor.default-dispatcher-4] [akka.persistence.Persistence(akka://default)] Create plugin: jdbc-snapshot-store akka.persistence.jdbc.snapshot.JdbcSnapshotStore
[DEBUG] [02/23/2016 19:03:59.690] [default-akka.actor.default-dispatcher-3] [AkkaPersistenceConfigImpl(akka://default)]
====================================
Akka Persistence JDBC Configuration:
====================================
SlickConfiguration(slick.driver.PostgresDriver,None)
===================