Skip to content

Instantly share code, notes, and snippets.

View thejefflarson's full-sized avatar
👨‍👩‍👧‍👦
being a dad

Jeff Larson thejefflarson

👨‍👩‍👧‍👦
being a dad
View GitHub Profile
@thejefflarson
thejefflarson / bm.rb
Created May 23, 2011 20:07
poor man's benchmark
def measure
t = Time.now
yield
puts Time.now - t
end
pub trait HasAcs {
fn valid(&self) -> bool;
fn from_row(row: &HashMap<&str, &str>) -> Self;
fn file() -> &'static str;
}
fn process_acs<T: HasAcs + diesel::query_builder::AsChangeset>() {
use schema::locations::dsl::*;
let conn = establish_connection();
find {../data/www.huffingtonpost.com,../data/www.thenation.com} -type f -print0 |\
xargs -0 pv |\
iconv -c -t UTF8 |\
gsed "s/['’]s//g" | gsed "s/s['’]//g" |\
gsed 's/http.* //g' |\
gsed "s|[“”,‘/\"—…:;()#@!<>{}?=% &*_]| |g" |\
gtr -d "'" |\
gtr -d "’" |\
gtr "[:upper:]" "[:lower:]" |\
gsed 's/[0-9]/ /g' |\
// compare to: https://github.com/dominictarr/hyperscript/blob/master/index.js (lol)
var e = function(/* tag, attrs, text, children...*/ ) {
var args = [].slice.call(arguments);
var tag = args.shift() || 'div';
var atts = args.shift() || {};
var text = args.shift() || '';
var kids = args;
var el = document.createElement(tag);
Object.keys(atts).forEach(function(k) {
require 'resolv'
require 'thread'
require 'csv'
require 'set'
ALPHABET = ('a'..'z').to_a + ('0'..'9').to_a + ['-']
def convert(num)
return ALPHABET[0] if num == 0
base = ALPHABET.length
converted = []
#include <fcntl.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <sys/select.h>
#include <sys/types.h>
#include <unistd.h>
#include <png.h>
if (req.responseText.indexOf('{') == 0) {
try {
eval('obj = '+req.responseText);
} catch (err) {
console.warn('unable to do anything with api rsp');
}
}
var e = function(/* tag, attrs, text, children...*/ ) {
var args = [].slice.call(arguments);
var tag = args.shift() || 'div';
var atts = args.shift() || attrs;
var text = args.shift() || '';
var kids = args;
var el = document.createElement(tag);
Object.keys(atts).forEach(function(k) {
el.setAttribute(k, atts[k]);
const Benchmark = require('benchmark');
var bench = Benchmark({
fn : function(){
var a = new Buffer(1024);
}
});
console.log(String(bench.run()));
extern crate hyper;
extern crate flate2;
use hyper::Client;
use std::io::{BufRead, BufReader};
use flate2::read::GzDecoder;
fn main() {
let client = Client::new();
let res = client.get("https://aws-publicdatasets.s3.amazonaws.com/common-crawl/crawl-data/CC-MAIN-2015-40/segments/1443736672328.14/wat/CC-MAIN-20151001215752-00000-ip-10-137-6-227.ec2.internal.warc.wat.gz")