Skip to content

Instantly share code, notes, and snippets.

View noahhl's full-sized avatar

Noah Lorang noahhl

  • Basecamp
  • Pittsburgh, PA
View GitHub Profile
15/04/23 20:17:48 INFO mapreduce.Job: map 0% reduce 0%
15/04/23 20:18:10 INFO mapreduce.Job: map 1% reduce 0%
15/04/23 20:18:47 INFO mapreduce.Job: map 2% reduce 0%
15/04/23 20:19:20 INFO mapreduce.Job: map 3% reduce 0%
15/04/23 20:19:54 INFO mapreduce.Job: map 4% reduce 0%
15/04/23 20:20:28 INFO mapreduce.Job: map 5% reduce 0%
15/04/23 20:21:06 INFO mapreduce.Job: map 6% reduce 0%
15/04/23 20:21:40 INFO mapreduce.Job: map 7% reduce 0%
15/04/23 20:22:14 INFO mapreduce.Job: map 8% reduce 0%
15/04/23 20:22:48 INFO mapreduce.Job: map 9% reduce 0%

Keybase proof

I hereby claim:

  • I am noahhl on github.
  • I am noahhl (https://keybase.io/noahhl) on keybase.
  • I have a public key whose fingerprint is 9E53 CF84 0DA7 1B25 B991 548F BB64 6F9C 364F 4E5C

To claim this, I am signing this object:

/**
* Convert file of cartesian points to an STL file
*/
import java.io.*;
import java.util.*;
public class cart2stl {
//EDIT THE NEXT TWO LINES WITH THE APPROPRIATE INPUT/OUTPUT FILE NAMES
public static final String fileIn = "face.txt";
@noahhl
noahhl / sar-statsd.rb
Created March 3, 2013 21:38
Send sar/sysstat metrics to a statsd server, store them as timers
#!/usr/bin/env ruby
require 'socket'
STATSD_HOST = '127.0.0.1'
STATSD_PORT = 8125
NAMESPACE = "sysstat"
@hostname = `hostname -s`.chomp
@statsd = UDPSocket.new
@statsd.connect STATSD_HOST, STATSD_PORT
> data <- data.frame(a = c(1,2,3,4,4,5), b = c('a', 'b', 'c', 'd', 'e', 'f'))
> data[!duplicated(data$a), ]
a b
1 1 a
2 2 b
3 3 c
4 4 d
6 5 f
> data[!duplicated(data$a) & !duplicated(data$a, fromLast=T), ]
a b
# Run from the directory containing your git repository
require 'time'
Dir.glob("./*").each do |dir|
`cd #{dir} && git log --pretty=format:'%an: %at' >> ~/commit_times.txt`
end
file = File.new(File.expand_path("~/commit_times.txt"), "r")
commits = []
while(line=file.gets)
#!/usr/bin/ruby
# Generate a shell of a script for the language you specify.
# Set up your script templates in ~/.scriptify
require 'optparse'
options = {:edit => false}
optparse = OptionParser.new do |opts|
opts.banner = "Usage: scriptify language filename"
@noahhl
noahhl / amortization.R
Created July 21, 2011 00:12
Fun with mortgage amortizations
# Credit due to Thomas Girke ("http://faculty.ucr.edu/~tgirke/Documents/R_BioCond/My_R_Scripts/mortgage.R") for original implementation of mortgage()
# Definitions:
# P = principal, the initial amount of the loan
# I = annual interest rate
# L = length of the loan in years, or at least the length over which the loan is amortized.
# to use, run it as graphs <- amortizationScenarios(P, I, L), then graphs[1], graphs[2]
amortizationScenarios <- function(P=500000, I = 6, L=30) {
@noahhl
noahhl / Misc server benchmarks
Created April 15, 2011 01:48
Rhttpd vs. Nack (via Pow) vs. Apache
rRack
betsy:dashboards noah$ ab -n 10000 -c 10 http://127.0.0.1:10000/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
@noahhl
noahhl / FindDependencies.R
Created April 4, 2011 01:29
Find package dependencies in R source files and optionally try to install them
# This function finds all "require" and "library" statements within a
# directory tree of R code and optionally attempts to install them as
# quietly as possible.
# Usage: setwd("yourcodedirectory"); FindDependencies()
# To install required packages if not currently available, run
# FindDependencies(install=T).
FindDependencies <- function(install=F) {
files <- dir(pattern="\\.R$|\\.S$|\\.r$|\\.s$", recursive=T)
dependencies <- c()