Skip to content

Instantly share code, notes, and snippets.

@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;
package de.jungblut.benchmark;
import java.util.ArrayList;
import com.google.caliper.Param;
import com.google.caliper.Runner;
import com.google.caliper.SimpleBenchmark;
public class PerfectSquaresBenchmark extends SimpleBenchmark {
String pathBase = "/home/thomasjungblut/Downloads/";
PDDocument source = PDDocument.load(pathBase
+ "c1.pdf");
PDDocument lastPage = PDDocument.load(pathBase + "updated.pdf");
source.removePage(source.getNumberOfPages() - 1);
source.addPage( (PDPage) lastPage.getDocumentCatalog().getAllPages().get(0) );
source.save(pathBase + "c2_updated.pdf");
/**
* 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
@thomasjungblut
thomasjungblut / gist:11193991
Created April 22, 2014 20:56
Apache GPG PublicKey
pub 2048D/4F238505 2011-09-20
uid Thomas Jungblut <tjungblut@apache.org>
sig 3 4F238505 2011-09-20 Thomas Jungblut <tjungblut@apache.org>
pub 4096R/56623ACB 2014-04-22
uid Thomas Jungblut (apache account email pgp client blax) <tjungblut@apache.org>
sig 3 56623ACB 2014-04-22 Thomas Jungblut (apache account email pgp client blax) <tjungblut@apache.org>
sub 4096R/BDDECF6D 2014-04-22
sig 56623ACB 2014-04-22 Thomas Jungblut (apache account email pgp client blax) <tjungblut@apache.org>
@thomasjungblut
thomasjungblut / BinaryTree.java
Last active August 29, 2015 14:02
findKthSmallestValue in a Binary Tree.
package de.jungblut.interviews;
import java.util.Stack;
import com.google.common.base.Preconditions;
public class BinaryTree {
class TreeNode {
TreeNode left;
@thomasjungblut
thomasjungblut / gist:fdf458587463a993d173
Created February 7, 2015 20:47
PiEstimator (multithreaded monte carlo)
import java.util.concurrent.Executors
import scala.util.Random
import java.util.concurrent.ExecutorService
import java.util.concurrent.Callable
import java.util.concurrent.FutureTask
import java.util.concurrent.ExecutorCompletionService
import scala.collection.mutable.MutableList
object PiEstimator extends App {
@thomasjungblut
thomasjungblut / gist:e4759797f5a52d78e06d
Last active August 29, 2015 14:16
MinHashing Example
package de.jungblut.nlp;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.google.common.base.Stopwatch;
@thomasjungblut
thomasjungblut / gist:624ba7b7f4dc6246659c
Created June 17, 2015 20:09
numerical gradients with fmincg
import de.jungblut.math.DoubleVector;
import de.jungblut.math.MathUtils;
import de.jungblut.math.dense.DenseDoubleVector;
import de.jungblut.math.minimize.CostFunction;
import de.jungblut.math.minimize.CostGradientTuple;
import de.jungblut.math.minimize.Fmincg;
public class FminCGNumericalGradient {
static class RealCostFunction implements CostFunction {
@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)