Skip to content

Instantly share code, notes, and snippets.


Benjamin Eckel bhelx

View GitHub Profile
#!/usr/bin/env python
# Converts any integer into a base [BASE] number. I have chosen 62
# as it is meant to represent the integers using all the alphanumeric
# characters, [no special characters] = {0..9}, {A..Z}, {a..z}
# I plan on using this to shorten the representation of possibly long ids,
# a la url shortenters
bhelx / sql_canary.rb
Last active Apr 14, 2020
Pass a block of code to `while_enabled` to sniff out any SQL queries it might be making.
View sql_canary.rb
class SqlCanary
def self.enable!
Thread.current[:sql_canary] = true
def self.disable!
Thread.current[:sql_canary] = false
def self.enabled?
bhelx / recurly_bot.ex
Created Nov 30, 2016
Elixir Plug Cowboy Example
View recurly_bot.ex
defmodule RecurlyBot do
use Application
# See
# for more information on OTP Applications
def start(_type, _args) do
import Supervisor.Spec, warn: false
# Define workers and child supervisors to be supervised
children = [
bhelx / test.php
Last active Sep 16, 2017
TLS Low Level Testing. You should expect to see it print TLS version 1.2.
View test.php
// This example is for testing php with libcurl
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
View urban_access_test.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
bhelx / fetch.rb
Last active May 9, 2017
Recursively fetch Craigslist apartments using their map's json api
View fetch.rb
REGION = 'neworleans'
BASE_URL = "https://#{REGION}"
parse_listings = lambda do |url|
results = JSON.parse Net::HTTP.get(URI(url))
results.first.each do |item|
if item.key? 'GeoCluster'"#{BASE_URL}#{item['url']}")
bhelx / binary_sort.rb
Last active Oct 10, 2016
View binary_sort.rb
class BinaryTree
attr_accessor :value, :left, :right
def insert(value)
if @value
if value < @value
@left ||=
bhelx / process.js
Last active Mar 1, 2016
Fetch and resize geojson images concurrently using async.js
View process.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 / face_extract.rb
Last active Dec 30, 2015
recursively walk directory and extract faces
View face_extract.rb
require "opencv"
require "fileutils"
include OpenCV
detector = CvHaarClassifierCascade::load("./haarcascade_frontalface_alt.xml")
input_dir = ARGV[0]
output_dir = ARGV[1] || 'output'
bhelx / safe_store.rb
Last active Dec 27, 2015
Securely store and retrieve a file from an external drive
View safe_store.rb
# 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:
You can’t perform that action at this time.