Skip to content

Instantly share code, notes, and snippets.

/*jslint regexp: true, browser: true */
/*global $: false */
$(function () {
'use strict';
$('div.tright, div.tleft').each(function () {
var fullWidth = $('#column-content').width(),
originalImage = $(this).find('img').first(),
originalImageWidth = originalImage.width(),
@jonvuri
jonvuri / gist:4007765
Created November 3, 2012 16:09
Why political journalists can’t stand Nate Silver: The limits of journalistic knowledge

Original article

The more I think about the rift between political journalism and Nate Silver, the more it seems that it’s one that’s fundamentally an issue of epistemology — how journalists know what they know. Here’s why I think that’s the case.

When we talk about the epistemology of journalism, it all eventually ties into objectivity. The journalistic norm of objectivity is more than just a careful neutrality or attempt to appear unbiased; for journalists, it’s the grounds on which they claim the authority to describe reality to us. And the authority of objectivity is rooted in a particular process.

That process is very roughly this: Journalists get access to privileged information from official sources, then evaluate, filter, and order it through the rather ineffable quality alternatively known as “news judg

class Main
{
public static void main(String[] args) throws Exception
{
byte[] buffer = {0x53, 0x6f, 0x08, 0x6e, 0x69, 0x01, 0x63}; // 'S', 'o', '^?' (Backspace), 'n', 'i', '^A' (SOH), 'c'
String str = new String(buffer, "US-ASCII");
System.out.println("String: " + str);
System.out.println("Trimmed string: " + str.replaceAll("[^\\p{Print}]",""));
}
}
@jonvuri
jonvuri / mkdirp.js
Created November 12, 2012 18:28
Shorter mkdirp
var fs = require('fs');
var path = require('path');
module.exports = exports = function mkdirp(dirpath, mode, callback) {
dirpath = path.resolve(dirpath);
if (typeof mode === 'function' || typeof mode === 'undefined') {
callback = mode;
mode = 0777 & (~process.umask());
}
if (!callback) {
@jonvuri
jonvuri / Splat.js
Created November 14, 2012 12:24
It's two functions
function makeSplat(length) {
var splat = [];
while (length-- > 0) {
splat[length] = _;
}
return splat;
}
@jonvuri
jonvuri / currytests.js
Created November 14, 2012 20:14
Mmmmm curry
var expect = require('chai').expect;
var identity = function (a) {
return a;
}
var first = function (a, b, c) {
return a;
}
@jonvuri
jonvuri / whysicpmatters.md
Created November 15, 2012 01:31
Brian Harvey: Why SICP Matters

[Original]

Why Structure and Interpretation of Computer Programs matters

Brian Harvey University of California, Berkeley

In 2011, to celebrate the 150th anniversary of MIT, the Boston Globe made a list of the most important innovations developed there. They asked me to explain the importance of SICP, and this is what I sent them:

@jonvuri
jonvuri / protoinspect.js
Created November 18, 2012 17:44
Inspect prototypes
var util = require('util');
module.exports = function protoinspect(object) {
return util.inspect(object) + (object.__proto__ ? protoinspect(object.__proto__) : '');
}
@jonvuri
jonvuri / pig_latin.rb
Created November 22, 2012 00:08
Pig Latin Refinement
def translate(pigstri)
vowels = [ "a", "e", "i", "o", "u", "y" ]
pigstri
.split(/ /, -1)
.map { |x|
first_vowel = x.chars.find_index { |x| vowels.include?(x) }
if vowels.include?(x[0])
x + "ay"
elsif x[0..1].include?("qu")
x[2..x.length] + x[0..1] + "ay"
var fs = require('fs');
var path = require('path');
var mkpath = require('mkpath');
// You probably want to pass in a callback to this function to send back errors, normally
var mkfile = function (filepath) {
mkpath(path.dirname(filepath), function (err) {
if (err) {
console.log(err);
} else {