Skip to content

Instantly share code, notes, and snippets.

View robinvanemden's full-sized avatar
🌳
⏩ ⏩

Robin van Emden robinvanemden

🌳
⏩ ⏩
View GitHub Profile
@robinvanemden
robinvanemden / ufw.sh
Last active July 22, 2016 10:41 — forked from kim3er/script
IP address limited UFW firewall config for Couchbase 4.5
#!/bin/sh
IP_ADDRESS="192.168.0.2"
ufw allow from $IP_ADDRESS to any port 4369
ufw allow from $IP_ADDRESS to any port 8091
ufw allow from $IP_ADDRESS to any port 8092
ufw allow from $IP_ADDRESS to any port 11214
ufw allow from $IP_ADDRESS to any port 11215
ufw allow from $IP_ADDRESS to any port 11209
@robinvanemden
robinvanemden / CMAB.py
Created November 16, 2017 23:12 — forked from axlevisu/CMAB.py
A class which solves multi-armed bandit problem
from scipy.stats import beta
from scipy.integrate import quad
from random import randint
import numpy as np
from operator import add
#Contextual Multi-Armed Bandit for Bernoulli Case
class CMAB:
@robinvanemden
robinvanemden / LinUCB.ipynb
Created November 16, 2017 23:12 — forked from tushuhei/LinUCB.ipynb
LinUCB implementation based on Chu, Wei, et al. "Contextual Bandits with Linear Payoff Functions." AISTATS. Vol. 15. 2011.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np
class ContextualThompson(object):
def __init__(self, d=10, R=0.01, epsilon=0.5, delta=1.0, n_arms=10):
self.n_arms = n_arms
self.d = d
self.R = R
self.delta = delta
self.epsilon = epsilon
import random
import time
import matplotlib.pyplot as plt
import numpy as np
from numpy import linalg as la
DIM = 10.0
GRAPH_NUM = 520
#!/bin/sh
#
# Startup / shutdown script for the couchbase server
#
# Copyright (c) 2011, Couchbase, Inc.
# All rights reserved
#
#
### BEGIN INIT INFO
# Provides: couchbase-server
@robinvanemden
robinvanemden / jquery.couch.longpoll.js
Created November 5, 2016 16:38 — forked from schinckel/jquery.couch.longpoll.js
Long-polling handler for CouchDB
/*
# jquery.couch.longpoll.js #
A handler that can be used to listen to changes from a CouchDB database,
using long-polling.
This seemed to be a bit simpler than using continuous polling, which I
was unable to get working with jQuery.
<?php
// Webhook code to update repo clone and execute required deployement code when new commit was pushed
// Webhook content-type should be set to application/json and a random secret code should be set too.
// Secret Random Code You set on github webhook settings
const SECRET_TOKEN = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
if(strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') != 0){
throw new Exception('Request method must be POST!');
}
@robinvanemden
robinvanemden / toUTF8Array.js
Created December 14, 2019 10:16 — forked from joni/toUTF8Array.js
toUTF8Array: Javascript function for encoding a string in UTF8.
function toUTF8Array(str) {
var utf8 = [];
for (var i=0; i < str.length; i++) {
var charcode = str.charCodeAt(i);
if (charcode < 0x80) utf8.push(charcode);
else if (charcode < 0x800) {
utf8.push(0xc0 | (charcode >> 6),
0x80 | (charcode & 0x3f));
}
else if (charcode < 0xd800 || charcode >= 0xe000) {
@robinvanemden
robinvanemden / Makefile
Created February 14, 2020 19:25 — forked from keeferrourke/Makefile
Generic Makefile
# Generic makefile for a C project
# Written by Keefer Rourke <mail@krourke.org>
#
# This file is Public Domain or, in places where public domain works
# are not recognized, licensed as CC0. Legal text:
# <https://creativecommons.org/publicdomain/zero/1.0/legalcode.txt>
#
# This Makefile should not rely and any GNU-specific functionality,
# though it is based on the GNU make documentation which is available
# at: <https://www.gnu.org/software/make/manual/make.html>