Skip to content

Instantly share code, notes, and snippets.

@bhelx
bhelx / fetch.rb
Last active May 9, 2017 21:57
Recursively fetch Craigslist apartments using their map's json api
REGION = 'neworleans'
BASE_URL = "https://#{REGION}.craigslist.org"
parse_listings = lambda do |url|
results = JSON.parse Net::HTTP.get(URI(url))
results.first.each do |item|
if item.key? 'GeoCluster'
parse_listings.call("#{BASE_URL}#{item['url']}")
@bhelx
bhelx / binary_sort.rb
Last active October 10, 2016 20:10
BINARY SORT FOR EXERCISE.
class BinaryTree
attr_accessor :value, :left, :right
def insert(value)
if @value
if value < @value
@left ||= BinaryTree.new
@left.insert(value)
else
@bhelx
bhelx / process.js
Last active March 1, 2016 23:08
Fetch and resize geojson images concurrently using async.js
"use strict";
let im = require('imagemagick');
let async = require('async');
let fs = require('fs');
let request = require('request');
let path = require('path');
let os = require('os');
let fetchAndProcess = (task, done) => {
@bhelx
bhelx / face_extract.rb
Last active December 30, 2015 21:09
recursively walk directory and extract faces
require "opencv"
require "fileutils"
include OpenCV
detector = CvHaarClassifierCascade::load("./haarcascade_frontalface_alt.xml")
input_dir = ARGV[0]
output_dir = ARGV[1] || 'output'
FileUtils.mkdir_p(output_dir)
@bhelx
bhelx / safe_store.rb
Last active December 27, 2015 21:09
Securely store and retrieve a file from an external drive
# This script allows securely storing and retrieving a file to USB drive using rbnacl
#
# Usage:
#
# 1) Generate a private key:
#
# ruby safe_store.rb --generate-key -k /Volumes/SAFEUSB/my_private_key.key
#
# 2) Write the ciphertext file to your drive (mine is named PATRIOT).
# This will write a file at /Volumes/PATRIOT/plain.txt.ctxt:
@bhelx
bhelx / doge.txt
Created October 11, 2013 15:45
doge
:::::::::::::::---:::///:///:::::///::::::--........................................................
::::::::::::::::::::///:://::--:://++/:::---....................................----................
:::::::::::::::::/::::::::------:/++o+/::--..................................-:///++/-..............
::::::::::::::://:::-------..---:/++ooo+/:-.................................-:/+++ooso-.............
::::::::::::::::::-------....--::/++ooo+++:-.............................--:/+++++ossso-............
:::::::::::------------.....--::///++ooo+++/:---........................-://++++++ooosso-...........
::----------..------......---::/++++/////////////:::::----------.....-://+oso++ooooossss/...........
----......------------------:///+////:::////////////////////////////://++osoooooosssssoso:..........
......--------------::::///:/::::::::::///////////////////////////+oo++oossooossyyyyysooo+..........
-------::::::://////++++//:::::::::::///////++/++/////////////////++ooosyyoo+osyhhhhysooso-.........
@bhelx
bhelx / books.md
Last active December 21, 2015 17:08
Trying to reduce my library. Most of these books I got in college. My plan is to give them away.

Java (some textbooks)

  • Java: The Good Parts
  • Java: Concurrency in Practice (feat. Paul Christmann)
  • Java Generics and Collections
  • Java Web Services Up and Running
  • Data structures and other Objects using java
  • Spring MVC and Web Flow
  • Big java (second edition)
  • Effective Java (good java book)
@bhelx
bhelx / chrubuntu.md
Last active December 14, 2015 02:09
Samsung Chrubuntu
var NickList = function () {
this.nicks = [];
this.colorMap = {};
this.colors = [
'#ff00ff',
'#00007f',
'#009300',
'#ff0000',
'#7f0000',
'#9c009c',
@bhelx
bhelx / trace.js
Last active December 11, 2015 04:29
This is an incomplete thought. Doesn't actually show enough information to do anything useful.
/**
* Intelligent Traceroute
*
* Do a traceroute on a domain, prints a json array
* of the hops with their physical locations.
*
* //Example
* node trace.js google.com
*
* npm install traceroute async underscore request