Skip to content

Instantly share code, notes, and snippets.

@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) {
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 / 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

/*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(),
could not source "$VIM\vimrc"
sourcing "$HOME\_vimrc"
Searching for "autoload/pathogen.vim" in "C:/MinGW/msys/1.0/home/U01
60100/vimfiles,c:\Program Files (x86)\Vim/vimfiles,c:\Program Files
(x86)\Vim\vim73,c:\Program Files (x86)\Vim/vimfiles/after,C:/MinGW/msys
/1.0/home/U0160100/vimfiles/after"
Searching for "C:/MinGW/msys/1.0/home/U0160100/vimfiles\autoload/pat
@jonvuri
jonvuri / .vimrc
Created September 19, 2012 13:02
runtime bundle/pathogen/autoload/pathogen.vim
call pathogen#infect()
" Die
set nocompatible
" Make commands like yy, D, p, etc. work with the OSX clipboard
set clipboard=unnamed
" Make the mouse work
@jonvuri
jonvuri / gist:3714253
Created September 13, 2012 13:26
Looking for someone to host al2o3cr

jrajav here, I wrote and hosted al2o3cr for a while. It's a bot in #ruby that interprets code on-the-fly in the channel, like most language channels on Freenode have. Unfortunately, I can't host it any longer. My work machine was the only one that could handle it, and that now has to host a scaling utility as well, which interferes with the VM the bot was on. If anyone else has a Linux box on which they can host and maintain the bot, please let me know at jrajav at gmail dot com and I'll tell you how to get it set up. It's pretty simple, and reasonably secure. Everything takes place in a chroot with below-root access. Still, I can't guarantee that it won't blow your system up. If security is important (like it was for me), you still might want to run it in a VM or on a more disposable machine.

@jonvuri
jonvuri / gist:3691002
Created September 10, 2012 13:43
Homebrew ffmpeg install issue
% HOMEBREW_MAKE_JOBS=1 VERBOSE=1 brew install --HEAD pigoz/mplayer2/mplayer2
==> Installing mplayer2 dependency: ffmpeg
==> Downloading http://ffmpeg.org/releases/ffmpeg-0.11.1.tar.bz2
Already downloaded: /Library/Caches/Homebrew/ffmpeg-0.11.1.tar.bz2
/usr/bin/tar xf /Library/Caches/Homebrew/ffmpeg-0.11.1.tar.bz2
==> ./configure --prefix=/usr/local/Cellar/ffmpeg/0.11.1 --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --cc=cc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
./configure --prefix=/usr/local/Cellar/ffmpeg/0.11.1 --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --cc=cc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
install prefix /usr/local/Cellar/ffmpeg/0.11.1
source path .
C compiler cc
#compdef _files
fuzzy_complete() {
words=( ${(z)BUFFER} );
pieces=( ${(s:/:)words[-1]} );
globpt=${(j:*:)${(s::)pieces[-1]}};
matches=( $pieces[1,-2]/*${~globpt}* );
(( $#matches == 1 )) && BUFFER="${words[1,-2]} ${matches[1]}" && CURSOR=$#BUFFER || zle -M "Completions: $matches"
};
#include <stdio.h>
int main() {
int num = 0;
int i;
int counter;
do {
counter = 0;
num++;