Skip to content

Instantly share code, notes, and snippets.

gfredericks / java_math_100.clj
Created September 27, 2014 13:20
The first 100 natural numbers expressed using only the java.lang.Math class
View java_math_100.clj
;; 0:
(-> Math/E Math/toRadians Math/round)
;; 1:
(-> Math/E Math/log Math/round)
;; 2:
(-> Math/E Math/sqrt Math/round)
;; 3:
(-> Math/E Math/round)
;; 4:
(-> Math/PI Math/ceil Math/round)
debasishg / gist:8172796
Last active August 7, 2023 20:13
A collection of links for streaming algorithms and data structures
View gist:8172796
  1. General Background and Overview
jinroh /
Last active July 27, 2023 11:14
Fourier series visualisation with d3.js.

From Wikipedia:

In mathematics, a Fourier series decomposes periodic functions or periodic signals into the sum of a (possibly infinite) set of simple oscillating functions, namely sines and cosines (or complex exponentials).

Use the bottom right form to change the visualized serie.

maxogden / index.js
Last active May 9, 2021 02:20
fast loading of a large dataset into leveldb
View index.js
// data comes from here
// download 1994.csv.bz2 and unpack by running: cat 1994.csv.bz2 | bzip2 -d > 1994.csv
// 1994.csv should be ~5.2 million lines and 500MB
// importing all rows into leveldb took ~50 seconds on my machine
// there are two main techniques at work here:
// 1: never create JS objects, leave the data as binary the entire time (binary-split does this)
// 2: group lines into 16 MB batches, to take advantage of leveldbs batch API (byte-stream does this)
var level = require('level')
BurntSushi / 01-possible-generic-map.go
Last active May 14, 2019 16:49
Code from my blog post "Writing type parametric functions in Go."
View 01-possible-generic-map.go
// This is *not* valid Go!
func Map(f func(A) B, xs []A) []B {
ys := make([]B, len(xs))
for i, x := range xs {
ys[i] = f(x)
return ys
Map(func(x int) int { return x * x }, []int{1, 2, 3})
p1nox /
Last active May 5, 2023 02:03
PostgreSQL configuration without password on Ubuntu for Rails


You could have postgre installed on localhost with password (or without user or password seted after instalation) but if we are developing we really don't need password, so configuring postgre server without password for all your rails project is usefull.

Install Postgre packages

  • postgresql
  • postgresql-client
  • libpq-dev
emeeks /
Last active August 22, 2023 16:27 — forked from mbostock/.block
An online tool for interactive teaching of network visualization and representation principles.

The range sliders at the top change the values for the force-directed algorithm and the buttons load new graphs and apply various techniques. This will hopefully serve as a tool for teaching network analysis and visualization principles during my Gephi courses and general Networks in the Humanities presentations.

Notice this includes a pretty straightforward way to load CSV node and edge lists as exported from Gephi.

It also includes a pathfinding algorithm built for the standard data structure of force-directed networks in D3. This requires the addition of .id attributes for the nodes, however.

Now with Clustering Coefficients!

Also, it loads images for nodes but the images are not in the gist. The code also refers to different network types but the data files on Gist only refer to the transportation network.

mbostock /
Last active June 7, 2023 18:33
Underscore’s Equivalents in D3
mbostock / .block
Last active May 4, 2023 13:03
The Gist to Clone All Gists
View .block
license: gpl-3.0
tmcw / floyd.js
Created August 23, 2012 13:02
Floyd's Algorithm for Random Subsets
View floyd.js
function sample(list, m) {
var n = list.length;
if (m > n) return void console &&
console.log('list length must be > sample');
var sampleList = [];
for (var i = n - m; i < n; i++) {
var item = list[~~(Math.random() * i)];
if (sampleList.indexOf(item) !== -1)