Skip to content

Instantly share code, notes, and snippets.

View daniel-j-h's full-sized avatar
🤗

Daniel J. H. daniel-j-h

🤗
View GitHub Profile
@daniel-j-h
daniel-j-h / TwitterClient
Created August 9, 2012 20:21
Twitter's most popular
#!/usr/bin/env python2.6
import pycurl, json
user = "YOURTWITTERNAME"
password = "YOURTWITTERPASSWORD"
streamurl = "https://stream.twitter.com/1/statuses/filter.json"
track = "locations=-74,40,-73,41" # nyc
@daniel-j-h
daniel-j-h / counting.c
Created August 24, 2012 02:53
counting_bloom_add segfaults
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dablooms.h"
int main() {
counting_bloom_t* bloom = NULL;
@daniel-j-h
daniel-j-h / core.clj
Last active December 20, 2015 22:39
Clojure + Leap Motion Requirements: Appropriate Leap libraries / native deps
(ns leap-clojure.core
(:import (com.leapmotion.leap Controller Listener Pointable))
(:gen-class))
(defn frame-handler
"Decides what to do with new frame data from the device"
[^Controller controller]
(let [frame (.frame controller)
box (.interactionBox frame)
@daniel-j-h
daniel-j-h / core.clj
Created August 16, 2013 18:06
Fun with Natural language processing. Not really useful right now.
(ns nlp.core
(:require [opennlp.nlp :as nlp]
[opennlp.tools.filters :as filters]
[net.cgrand.enlive-html :as html]))
(def ^:dynamic *base-url* "https://news.ycombinator.com")
;; get models from http://opennlp.sourceforge.net/models-1.5/
(def tokenize (nlp/make-tokenizer "models/en-token.bin"))
@daniel-j-h
daniel-j-h / c++11-longest-monotonic-prefix.cpp
Last active December 21, 2015 10:09
Given a collection of numbers, find the longest monotonic prefix (ascending or descending), i.e. l-m-prefix [3 2 1 2 3 4] => [3 2 1].
/*
* Given a collection of numbers, find the longest monotonic prefix (ascending or descending);
* e.g.: l-m-prefix [3 2 1 2 3 4] => [3 2 1]
*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <iterator>
@daniel-j-h
daniel-j-h / count_min.cpp
Last active December 30, 2015 08:49
Simple cardinality estimator. You can provide hash<T> specializations for custom types, as long as the hash values roughly follow a uniform distribution. Otherwise the estimation gets skewed.
#include <cstddef>
#include <functional>
#include <algorithm>
#include <iterator>
#include <limits>
#include <iostream>
#include <string>
// g++ -Wall -Wextra -pedantic -std=c++11 count_min.cpp
@daniel-j-h
daniel-j-h / main.cc
Created April 20, 2014 16:50
C++ Intel Threading Building Blocks palindrome example, showing reduction vs. combinable -- note: memory bound
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <algorithm>
#include <fstream>
#include <functional>
#include "tbb/task_scheduler_init.h"
#include "tbb/blocked_range.h"
@daniel-j-h
daniel-j-h / notes.md
Created May 6, 2014 12:49
ceph/ceph @24c5ea8: -Weverything

A plea for more tooling usage

Motivation

I tried to build Ceph with the Clang (3.4) compiler. The only issue preventing the build to finish was a "VLA of non-POD type" usage which I fixed here:

ceph/ceph#1768

@daniel-j-h
daniel-j-h / main.cc
Last active October 10, 2018 16:52
C++ Intel Threading Building Blocks task scheduling observer
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <mutex>
#include <thread>
#include "tbb/task_scheduler_observer.h"
#include "tbb/task_scheduler_init.h"
#include "tbb/blocked_range.h"
@daniel-j-h
daniel-j-h / blocking_queue.hpp
Last active August 29, 2015 14:02
blocking queue, non-blocking queue (Sean Parent's list splice trick), monitor<T>, concurrent<T> (Herb Sutter's primitives)
#ifndef BLOCKING_QUEUE_H
#define BLOCKING_QUEUE_H
#include <list>
#include <mutex>
#include <condition_variable>
#include <iterator>
template <typename T>