Skip to content

Instantly share code, notes, and snippets.

@framp
framp / 100mb.cpp
Created October 28, 2012 20:29
Testing different solutions for counting the occurrences of a given character inside a 100mb file (comparing performances between ack, STL streams on disk and STL streams with a file saved on a ramdisk).
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <ctime>
using namespace std;
void generate(char * filename, string range)
{
int rangeLength = range.length();
srand (time(NULL));
@framp
framp / squarespace-fonts-filter.js
Created June 13, 2014 12:41
Just a small snippet to filter out the great list of font at http://blog.squarespace.com/blog/curated-typography
var fonts = Array.prototype.slice.call(document.querySelectorAll('.font'));
var state = ['none', 'block'];
var condition = function(i, skip){
return i.childNodes[0].className.indexOf(skip)===-1;
}
var filter = function(skip, i){
i.style.display = state[condition(i, skip)>>0];
};
fonts.forEach(filter.bind(null, 'Typekit'));
@framp
framp / common-dustjs-helpers.js
Created June 13, 2014 18:43
Fixed some issues with the module common-dustjs-helpers
(function (dust) {
var _eval_dust_string = function(str, chunk, context) {
var buf;
if (typeof str === "function") {
if (str.length === 0) {
str = str();
} else {
buf = '';
(chunk.tap(function(data) {
buf += data;
@framp
framp / compress.js
Created August 20, 2014 21:52
Working on data inside compressed archives using node.js and pipes
var es = require('event-stream')
process.stdin
.pipe(es.split())
.pipe(es.map(function (data, callback) {
var line = data.toString().split(',');
if (line.length>3){
var filename = line[0];
var date = [line[1].substr(0,4), line[1].substr(4,2), line[1].substr(6)].join('-');
date = + new Date(date);
@framp
framp / postgres-test.md
Last active August 29, 2015 14:05
Weird thoughts about a weird problem

http://stackoverflow.com/questions/25415424/whats-an-efficient-way-to-store-a-time-series

Group the data by TYPE (what I'd like, ideally)
A timestamp in ms is 8 bytes, the 2 floats could be real of 4 bytes each
16*3091472167 = 49463554672 bytes ~ 46GiB ~ nearly 3 times the zipped files

Group by month
Each timestamp is now between 0 and 2678400000, which fits a 4b integer
Using a smallint for storing the difference from the first float

All the types are columns

@framp
framp / timestamp.txt
Created August 20, 2014 23:01
Saving a timestamp
#TIMESTAMP,DATA1,DATA2
1234567890,1.000,2.000
1234567990,1.000,2.000
1234566890,1.000,2.000
1234566891,1.000,2.000
123456
-7
-890:1.000,2.000
-990:1.000,2.000
@framp
framp / gist:5a4e8691c103ed6428d0
Created February 25, 2015 16:29
Keybase verification
### Keybase proof
I hereby claim:
* I am framp on github.
* I am framp (https://keybase.io/framp) on keybase.
* I have a public key whose fingerprint is 1E32 8125 358E B586 58CB 8349 1D45 C466 9E7D 1EFA
To claim this, I am signing this object:
@framp
framp / instructions.md
Last active August 29, 2015 14:16
Breaking Trello challenge

Write JavaScript (or CoffeeScript) code to find a 9 letter string of characters that contains only letters from

acdegilmnoprstuw

such that the hash(the_string) is

956446786872726

if hash is defined by the following pseudo-code:

@framp
framp / header
Last active August 29, 2015 14:17
sounds packing experiment
","data:audio/mp3;base64,
@framp
framp / hararyGraph.js
Created March 23, 2015 06:41
Generates the adjacency map of an harary graph with n nodes and k-connected
//Generates the adjacency map of an harary graph with n nodes and k-connected
function hararyGraph(n, k){
var adj = []
if (k>=n) k=n-1
var hn = Math.ceil(n/2)
var hk = Math.floor(k/2)
var rk = hk*2
for (var i=1; i<=n; i++){
adj[i-1] = []