Skip to content

Instantly share code, notes, and snippets.

@tkroman
tkroman / Builder.java
Created October 18, 2014 23:50
Conditioned/retriable tasks
import java.util.Objects;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
class Builder<T> {
private TimeUnit timeUnit;
private long period;
private int attempts;
private Callable<T> task;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Label;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.io.fs.FileUtils;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import sun.jvm.hotspot.utilities.Bits;
import java.util.Arrays;
import java.util.stream.IntStream;
/**
* @author tk.roman
*/
public class Heys {
// N ^ 2 = 16 => use ints
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;
const char* A = "A.txt";
const char* B = "B.txt";
vector<int> fillVector(const char*);
@tkroman
tkroman / vctr.cpp
Created October 21, 2011 21:17
vctr
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;
const char* A = "A.txt";
const char* B = "B.txt";
vector<int> fillVector(const char*);
@tkroman
tkroman / determinant
Created December 9, 2011 22:15
det(M)
require 'mathn'
size = gets.chomp.to_i
$array = Array.new(size) { |iarray| iarray = Array.new(size) { |j| j = gets.chomp.to_i } }
m = Matrix.rows($array)
puts m.det
@tkroman
tkroman / gist:3407422
Created August 20, 2012 20:11
let vs let*
;; scheme code:
(define (partial-tree elts n)
(if (= n 0)
(cons '() elts)
(let ((left-size (quotient (- n 1) 2)))
(let ((left-result (partial-tree elts left-size)))
(let ((left-tree (car left-result))
(non-left-elts (cdr left-result))
(right-size (- n (+ left-size 1))))
(let ((this-entry (car non-left-elts))
@tkroman
tkroman / gist:3854190
Created October 8, 2012 18:51
playing around with wolfram|alpha api basics
require 'net/http'
require 'nokogiri'
require 'Qt'
APPID = "QV4WQY-RYGTU7UPH2"
WADDR = 'http://api.wolframalpha.com/v2/query'
def queryWA(qry)
uri = URI(WADDR)
res = Net::HTTP.post_form(uri, 'input' => qry, 'appid' => APPID)
@tkroman
tkroman / stl_queue.cpp
Created November 11, 2012 14:23
stl crap
#include "stl_queue.hpp"
STLQueue::STLQueue() {
queue = new deque<double>;
}
void STLQueue::push(const double n) {
queue->push_back(n);
}
/*
* 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
*