Skip to content

Instantly share code, notes, and snippets.

View ThomasWunderlich's full-sized avatar

Thomas Wunderlich ThomasWunderlich

  • 13:31 (UTC -04:00)
View GitHub Profile
import requests
page = 1
download = True
while download:
payload = {'page': page, 'per_page': 80}
results = requests.get('https://api.punkapi.com/v2/beers', params=payload)
results = results.json()
# pull the plug if empty
@ThomasWunderlich
ThomasWunderlich / ForkingInstructions.md
Last active August 29, 2015 14:11
Forking instructions. This shows how to fork a repo, and keep a repo in sync with the original repo
  1. Fork a repository (http://github.com/zendframework/zf1)
  2. Clone your fork locally and enter it (use your own GitHub username in the statement below)
% git clone git@github.com:<username>/zf1.git
% cd zf1
  1. Add a remote to the canonical repository, so you can keep your fork up-to-date:
% git remote add zf1 https://github.com/zendframework/zf1.git
@ThomasWunderlich
ThomasWunderlich / Virtualbox cli restart
Created August 23, 2014 00:54
Vagrant fix by restarting Virtualbox on the cli
sudo /Library/StartupItems/VirtualBox/VirtualBox restart
@ThomasWunderlich
ThomasWunderlich / whatserver.sh
Created June 6, 2014 04:08
Commands to identify most UNIX style OS' from Michael Henry @neocri.me
# Should work almost everywhere
uname -a ; grep -e . /etc/*_ver* /etc/*-rel* /etc/*-rel/* ; sw_vers
# Also relevant, but some systems don't have grep -R, -r, or --recursive
uname -a ; grep -Re . /etc/*_ver* /etc/*-rel* ; sw_vers
@ThomasWunderlich
ThomasWunderlich / Gsutil Cron Configs
Created February 3, 2013 04:45
So you want to use gsutil in your crons but running into problems? Here's the solution:
The most likely reason is that cron runs in a very limited environment and doesn't have access to gsutil or to gsutil's configuration.To fix this you should set your Path variable and the gsutil configuration inside your script like so:
#!/bin/bash
PATH=path/to/gsutil
export BOTO_CONFIG="/path/to/.boto"
#rest of script here
@ThomasWunderlich
ThomasWunderlich / SingletonEx
Created February 3, 2013 03:36
Singleton pattern
<?php
class SingletonExample
{
static $instance;
private function __construct() {
/*Specific logic for this singleton */
}
public static function getInstance() {
@ThomasWunderlich
ThomasWunderlich / gist:4527338
Created January 14, 2013 02:20
Copy file (Ruby)
#!/usr/bin/env ruby
from_file, to_file=ARGV
script = $0
puts "Copying from #{from_file} to #{to_file}"
input = File.open(from_file).input.read()
puts "The input file is #{input.length} bytes long"
@ThomasWunderlich
ThomasWunderlich / Time_Regex(Ruby)
Created May 22, 2012 15:21
An explanation of the time regex found in the Saas Book.
#!/usr/bin/env ruby
time_regex = /^\d\d?:\d\d\s*[ap]m$/i
#^ here means beginning of line
#\d is a digit, \s is a (white)space character
#the ? means 0 or 1 and affects the character before it. so here it means that
#the second digit is optional. Ie if someone wrote 9:25 as opposed to 09:25
#both would be understood. Similarly, the * following \s means 0+ and states
#that there could be any amount of spaces