Skip to content

Instantly share code, notes, and snippets.

View frbl's full-sized avatar
🎯
Focusing

Frank Blaauw frbl

🎯
Focusing
View GitHub Profile
@frbl
frbl / proxmox_setup.md
Created June 11, 2019 19:43
Setting up proxmox
kwa_rk:
- a
- b
- c
melk:
- 1234
kaas:
- 12311
@frbl
frbl / assigned2me.sh
Created August 23, 2018 08:05
See all PR's on github that are assigned to you
#!/var/www/rvm/rubies/ruby-current/bin/ruby
require 'httparty'
GREEN = '1;32m'.freeze
YELLOW = '1;33m'.freeze
RED = '1;31m'.freeze
current_user = 'frbl'
res = HTTParty.get(
@frbl
frbl / eduroam
Created June 5, 2018 07:02
RUG / University of Groningen - Eduroam configuration for Linux /etc/NetworkManager/system-connections/eduroam
[connection]
id=eduroam
uuid=<THIS_CAN_BE_AUTOGENERATED>
type=wifi
permissions=user:<PC_USERNAME>:;
[wifi]
mac-address=<MACADDRESS_OF_YOUR_WLAN_CARD>
mac-address-blacklist=
mode=infrastructure
@frbl
frbl / xgboost_failing_update.R
Created October 24, 2017 21:38
Example of the update of XGBoost not working.
set.seed(12345)
library('data.table')
library('xgboost')
## Create simulation function
give_me_data <- function(nobs, delta = 0.05) {
X_mat <- data.table(A = rnorm(nobs, 0, 1), B = rnorm(nobs, 0, 1))
probs <- pmax(as.numeric(X_mat$A > 0) - 2*delta, 0) + delta
X_mat <- as.matrix(X_mat)
Y_vals <- rbinom(nobs, 1, probs)
@frbl
frbl / difference_between_rbind_rbindlist.R
Created October 24, 2017 09:24
Difference between rbind and rbindlist in terms of time, for appending a single row
library(microbenchmark)
library(data.table)
rbindlist_time <- function() {
data <- data.table(a=c(1),b=c(2))
for (item in 1:10000) {
data <- rbindlist(data, data.table(a=c(1),b=c(2)))
}
}
@frbl
frbl / glm_logistic_treatment.R
Last active October 19, 2017 17:20
Delta - A Treatment example
Osample_p_full <- read.csv('http://frbl.eu/files/gist_ac602828fedba735b4d1e4cb16472cbe.csv')
formula <- Delta ~ W + A
glm_pred <- glm(formula = formula(formula), data = Osample_p_full, family= binomial())
print(glm_pred)
# Call: glm(formula = formula(formula), family = binomial(), data = Osample_p_full)
#
# Coefficients:
# (Intercept) A W
# 18.378 -19.241 0.379
@frbl
frbl / bounded_logistic_regression.R
Last active November 3, 2017 16:55
Logistic regression with predicted probabilities constrained / capped / thresholded
#!/usr/bin/env Rscript
## Constrained logistic regression
## In this gist we create a regression for which the predicted probabilities are contstrained. That is, they can not be
## less than a minimum of delta, or a maxiumum of 1 - delta.
## Based on:
## - https://stats.idre.ucla.edu/r/dae/logit-regression/
## - https://github.com/achambaz/tsml.cara.rct/blob/2b2aa282d4a11c601b37cacb368b67d03f6e8fc9/R/misc.R#L440
## - https://github.com/achambaz/tsml.cara.rct/blob/fd426c2a6f91b692d379b4765d9900151d09daa6/R/targetGstar.R#L1
@frbl
frbl / data_export.html
Created June 11, 2017 09:12
Simpel voorbeeldje voor het lezen van de JSON
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
</head>
<body>
<ul id='data'>
</ul>
@frbl
frbl / notebook.sh
Created May 17, 2017 22:01
General script to run a notebook server in the current directory (uses docker)
#!/usr/bin/env sh
lib_dir=~/.R/lib/notebooks
mkdir -p $lib_dir
`sleep 3; open http://127.0.0.1:8888` &
docker run --rm -it \
-p 127.0.0.1:8888:8888 \
-v `pwd`:/home/jovyan/work \
-v $lib_dir:/usr/local/spark-2.1.0-bin-hadoop2.7/R/lib \
frbl/docker-notebook \
start-notebook.sh \