Skip to content

Instantly share code, notes, and snippets.

const _ = require('underscore');
const { Client } = require('pg');
const all_query = `SELECT id FROM "filter-test"."filter-test";`;
const some_query = `SELECT id, blob FROM "filter-test"."filter-test" WHERE id IN ('$(WHERE_IN_FILTER)');`;
async function query(q) {
const client = new Client({
user: 'postgres',
database: 'postgres'
@thomasjungblut
thomasjungblut / gist:fe9102e5a1592f8ba1a95c53345016c7
Created November 4, 2021 15:47
monty hall problem with monte carlo
#!/usr/bin/python3
import random as r
def random_doors():
doors = [False] * 3
doors[r.randint(0, 2)] = True
return doors
#!/usr/bin/python3
from time import sleep
import requests
from twilio.rest import Client
TWILIO_ACCOUNT_SID = "ACXXX"
TWILIO_AUTH_TOKEN = "XXX"
FROM = "+1XXXXX"
RECIPIENT = "+491XXXX"
@thomasjungblut
thomasjungblut / xgb_bayes_opt_cv.py
Last active March 31, 2021 04:02
XGBoost hyper parameter optimization using bayes_opt
from bayes_opt import BayesianOptimization
from sklearn.cross_validation import KFold
import xgboost as xgb
def xgbCv(train, features, numRounds, eta, gamma, maxDepth, minChildWeight, subsample, colSample):
# prepare xgb parameters
params = {
"objective": "reg:linear",
"booster" : "gbtree",
"eval_metric": "mae",
@thomasjungblut
thomasjungblut / MathLibBenchmark.java
Created May 26, 2013 08:03
Math Library Benchmark: GPU vs. JBLAS vs. pure Java
package de.jungblut.benchmark;
import java.util.Random;
import com.google.caliper.Param;
import com.google.caliper.Runner;
import com.google.caliper.SimpleBenchmark;
import de.jungblut.math.DoubleMatrix;
import de.jungblut.math.cuda.JCUDAMatrixUtils;
@thomasjungblut
thomasjungblut / gist.R
Last active November 14, 2019 04:57
XGBoost Validation and Early Stopping in R
train <- read.csv("train.csv")
bound <- floor(nrow(train) * 0.9)
train <- train[sample(nrow(train)), ]
df.train <- train[1:bound, ]
df.validation <- train[(bound+1):nrow(train), ]
train.y <- df.train$TARGET
validation.y <- df.validation$TARGET
dtrain <- xgb.DMatrix(data=df.train, label=train.y)
@thomasjungblut
thomasjungblut / gist:4495808
Last active June 21, 2017 01:32
serialize bloom filters
package de.jungblut.benchmark;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import com.google.common.hash.BloomFilter;
import com.google.common.hash.Funnels;
@thomasjungblut
thomasjungblut / gist:5146284
Last active November 6, 2016 10:39
Image Segmentation using mean shift clustering
package de.jungblut.ml;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class FlatMapTest {
public FlatMapTest() { // <init> //()V
<localVar:index=0 , name=this , desc=LFlatMapTest;, sig=null, start=L1, end=L2>
L1 {
aload0 // reference to self
invokespecial java/lang/Object <init>(()V);
return
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0