Skip to content

Instantly share code, notes, and snippets.

View clausd's full-sized avatar

Claus Dahl clausd

View GitHub Profile
@max-mapper
max-mapper / index.js
Created June 9, 2012 20:49
histogram bucket sorting with crossfilter
function createDimensions(key) {
var asc = xf.dimension(function (d) { return +(d[key]) })
var desc = xf.dimension(function (d) { return -1 * (+(d[key])) })
var sorter = new BucketSort(+(desc.top(1)[0][key]), +(asc.top(1)[0][key]), 100)
var buckets = xf.dimension(function (d) { return sorter.getBucket(+d[key]) })
var group = buckets.group()
return {
asc: asc,
desc: desc,
buckets: buckets,
@leecrossley
leecrossley / shake.js
Last active December 28, 2021 10:56
Shake gesture detection in PhoneGap / Cordova
/*
THIS GIST IS OUT OF DATE AND NOT MONITORED
PLEASE SEE https://github.com/leecrossley/cordova-plugin-shake-detection
*/
var shake = (function () {
var shake = {},
watchId = null,
options = { frequency: 300 },
previousAcceleration = { x: null, y: null, z: null },
@adamjmurray
adamjmurray / DLSSynth_with_Ruby_FFI.rb
Last active April 26, 2017 13:47
How to play MIDI using the OS X built-in DLS synth using Ruby & FFI
require 'ffi'
# A MIDI driver to play MIDI using OSX's built in DLS synthesizer.
#
# == Authors
#
# * Adam Murray <adam@compusition.com>
#
# == Copyright
#
@mattb
mattb / gist:da8d779573a10300e512
Last active August 29, 2015 14:02
Calculating the median distance and time of NYC taxi rides in 2013
// transcribed from an Apache Spark 1.0 spark-shell session
// using data from http://chriswhong.com/open-data/foil_nyc_taxi/
// and the QTree algorithm for approximate quantiles over large datasets
// each of the distanceRange and minutesRange calculations below takes about 15 minutes on my four-core SSD-based Macbook Pro
import com.twitter.algebird._
import com.twitter.algebird.Operators._
implicit val qtSemigroupD = new QTreeSemigroup[Double](6)
val in = sc.textFile("trip_data") // a directory containing all the trip_data*.csv files downloaded from the above link
@frankie567
frankie567 / interactive_google_oauth2.py
Last active July 29, 2023 22:07
Interactive Google OAuth2 flow with Streamlit
import asyncio
import streamlit as st
from httpx_oauth.clients.google import GoogleOAuth2
st.title("Google OAuth2 flow")
"## Configuration"
client_id = st.text_input("Client ID")