Skip to content

Instantly share code, notes, and snippets.

peterhurford / ziptime.rb
Created October 29, 2014 05:13
Database of US Zipcodes and their Timezones, as a Ruby Hash
This file has been truncated, but you can view the full file.
# This is a database of zipcodes and their time zones
# by Peter Hurford <>
# Coded in an array as zitpime[<zip code>] = [<time offset from UTC>, <DST yes (1) or no (0)>]
# Daylight Savings is March 9 to November 2
# Data retrieved from (CSV and SQL available), which in turn retrieved data from the CivicSpace US ZIP Code Database.
# Here, I used Regex to sort the data into a Ruby hash.
# You are free to use this array for your own purposes, just provide attribution.
peterhurford / gist:8602d9fb334baa71d983
Last active April 9, 2023 15:22
How to use XAMPP to test PHP on your own computer

So this is a guide for how to use XAMPP to test any PHP website on your own computer. Well, actually, it's more a guide of guides than an actual guide. I personally didn't find the process to be bad, but it also wasn't straightforward, and it involved a lot of googling separate problems. There was no One Guide for the Entire Process, but a bunch of separate things.

So I decided to put everything together. Here are the steps:

Step 1: Install XAMPP. Download from here.

Step 2: Set up XAMPP. Follow instructions here.

Step 3: Go to PhpMyAdmin and create any relevant MySQL tables, if any.

peterhurford /
Last active August 29, 2015 14:11
Ruby Interview Questions (No Rails, for a Prospective Junior Developer / Intern)

What does a ||= b mean?

What is the difference between a symbol and a string?

What is the difference between ' and " in Ruby?

peterhurford /
Last active August 29, 2015 14:11
Rspresso: Coffeescript for R


(Name and initial idea from robertzk.)


number = 42 --> RSPRESSO! --> number <- 42


peterhurford /
Last active January 12, 2022 21:55
R Interview Questions

1.) If I have a data.frame df <- data.frame(a = c(1, 2, 3), b = c(4, 5, 6), c(7, 8, 9))...

1a.) How do I select the c(4, 5, 6)?

1b.) How do I select the 1?

1c.) How do I select the 5?

1d.) What is df[, 3]?

peterhurford /
Last active August 29, 2015 14:15
Rails Interview

1a.) Why would one use a symbol instead of a string?

1b.) Why would someone use a string instead of a symbol?

2a.) What is the difference between a lambda, a block and a proc?

2b.) What does -> (a) {p a}["Hello world"] do?

peterhurford /
Last active August 29, 2015 14:19
Why do R function operators need to force(f)?

While reading Hadley's Advanced R book chapter on function operators (see our work on creating a set of answers here), I came across this fact about lazy evaluation:

The function operators we’ve seen so far follow a common pattern:

funop <- function(f, otherargs) { function(...) { # maybe do something res <- f(...) # maybe do something else

peterhurford / hate.R
Created June 10, 2015 19:39
An R Function that Only Works When You Try to Debug it
# Debugging in R is much better than many languages, but sometime it can be
# frustrating. Here's a function that makes it even more frustrating --
# it only works when you try to debug it!
# The challenge:
### Write a function that, if the function has a browser in it, will execute
### every line correctly, but if it does not have a browser in it, it will
### error.
# The solution:
peterhurford /
Last active June 28, 2022 23:46
One Year Out: How I Became a Better Programmer

I've been coding professionally for a year now, having started work on the 30th of June. In that year I've programmed professionally in Ruby on Rails, R, and JavaScript / Coffeescript using both the Knockout and Angular frameworks.

I'd like to think I've become a much better programmer over the past year. Looking back at my old code, I can tell that I grew a lot.

Here's how I did it.

Spend Time Programming

peterhurford /
Created July 6, 2015 22:39
Notes on Hadley's "R Packages"

Notes from reading through R Packages by Hadley Wickham. This is meant to review, not replace, a thorough readthrough. I mainly wrote this as a personal review, since writing summaries and attempting to teach others are some of the best ways to learn things.


  • Packages are used to organize code together so that it can be used repeatedly and shared with others.

  • A lot of work with packages is done via the devtools package.