Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
KNEE DEEP IN THE HOOPLA

Josh Holbrook jfhbrook

💭
KNEE DEEP IN THE HOOPLA
View GitHub Profile
View bin.py
#!/usr/bin/env python2
from twisted.internet import reactor
from twisted.internet.endpoints import TCP4ClientEndpoint
from bot import DDGBotFactory
import config
endpoint = TCP4ClientEndpoint(reactor, config.host, 6667)
@jfhbrook
jfhbrook / README.md
Created Feb 25, 2014
An interesting SNAFU with the `gm` module:
View README.md

gm will modify streaming data even in cases when the function is not intended to

I think this is an odd consequence of how the gm module invokes the gm binary for these cases.

I made a few test cases: The streaming case pipes to the gm module to get image size, and then pipes the (theoretically unmodified) output to disk. The buffer case passes a full buffer to gm, and then writes the original buffer back to disk.

So check this logging out:

Running streaming version:
View .vimrc
"Use tpope's pathogen
execute pathogen#infect()
set runtimepath^=~/.vim/bundle/ctrlp.vim
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
"Tab settings
set expandtab
set tabstop=2
@jfhbrook
jfhbrook / err.log
Last active Aug 29, 2015
joi + browserify = sads
View err.log
Uncaught Error: Cannot find module '/node_modules/joi/languages/en-us.json' _prelude.js:1
s _prelude.js:1
(anonymous function) _prelude.js:1
internals.Err.toString errors.js:26
exports.process errors.js:55
internals.Any.validate any.js:498
exports.validate index.js:51
(anonymous function)
@jfhbrook
jfhbrook / Makefile
Created May 26, 2014
Customized subshell in makefile
View Makefile
env:
sh -c 'PATH=$$PWD/Scripts:$$PATH "$$SHELL"'
@jfhbrook
jfhbrook / serious-question.md
Created Jul 11, 2014
I HERD U LIEK RUNTIME COMPLEXITY PUZZLES
View serious-question.md

What is the runtime complexity of:

for (var i = 1; i <= N; i *= 2) {
  for (var j = 1; j <= N; j *= 2) {
    for (var k = 1; k <= i; k++) {
      constantTime();
    }
  }
}
View oh-crap-is-vagrant-running.sh
#!/bin/bash
CAN_HAZ_VMS=$(vboxmanage list runningvms)
CAN_HAZ_POWR=$(pmset -g ps | grep -i "AC Power")
IMPORTANT_MESSAGE="OH FUCK IM ON BATTERY AND LEFT VAGRANT RUNNING"
if [ ! -z "$CAN_HAZ_VMS" ]; then
if [ -z "$CAN_HAZ_POWR" ]; then
echo $IMPORTANT_MESSAGE
osascript -e "display notification \"$IMPORTANT_MESSAGE\""
View prompt.cpp
#include <iostream>
#include <string>
std::string eval(std::string input)
{
return std::string("\"") + input + std::string("\"");
}
const std::string PROMPT = "> ";
@jfhbrook
jfhbrook / fixtures.js
Last active Aug 29, 2015
vanilla vs async vs promises
View fixtures.js
var Promise = require('bluebird');
var double = exports.double = {};
double.asPromise = function(x) {
return new Promise(function(resolve, reject) {
process.nextTick(function() {
resolve(x * 2);
});
});
};
View _mapping.txt
josh@koffing:~/dev/jesusabdullah/archivist$ curl http://localhost:9200/archivist/_mapping?pretty
{
"archivist" : {
"mappings" : {
"image" : {
"_timestamp" : {
"enabled" : true
},
"properties" : {
"channel" : {
You can’t perform that action at this time.