Skip to content

Instantly share code, notes, and snippets.

View dylanj's full-sized avatar

Dylan Johnston dylanj

View GitHub Profile
@echo off
for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (
set dow=%%i
set month=%%j
set day=%%k
set year=%%l
)
set datestr=%month%_%day%_%year%
echo datestr is %datestr%
# prints all? domain+tld combos which are available.
require 'nokogiri'
require "net/http"
require "uri"
def tldsearch(domain)
args = { d: domain, r: 'ALL', freedom: 0, onlydom: 0, option: 0 }
endpoint = "https://www.inwx.com/de/domain/check2ajax"
req_start = Time.now
### Keybase proof
I hereby claim:
* I am dylanj on github.
* I am zqz (https://keybase.io/zqz) on keybase.
* I have a public key ASBdic3PcERshrNKqZtWcRVi1BXPA0qUn0QpnnbL77wALQo
To claim this, I am signing this object:
without wait
count: 3040
highest: 0.002497736
lowest: 0.000104346
average: 0.00021010162796052627
with wait
count: 3040
highest: 0.021411709
lowest: 0.000494643
@dylanj
dylanj / gist:15d7c9791ae319af021c
Created July 22, 2014 13:50
Splits a shitty factories.rb with multiple factory definitions into individual files for each factory. Very brittle, please never use this.
FACTORY_DIR = 'spec/factories/'
lines = File.open(ARGV[0]).read
def write_factory(factory_name, factory_class, factory_lines)
factory_file = FACTORY_DIR + factory_name + '.rb'
outs = "FactoryGirl.define do\n"
outs += " factory :#{factory_name}"
outs += ", class: '#{factory_class}'" if factory_class != nil
require 'rubygems'
require 'json'
require 'net/http'
module WunderGround
def self.query( city )
api_uri = URI.parse URI.escape( "http://api.wunderground.com/api/~AKI_KEY~/geolookup/conditions/forecast/q/#{city}.json" )
response = Net::HTTP.get_response api_uri
data = response.body
json = JSON.parse data
@dylanj
dylanj / gist:1303271
Created October 21, 2011 07:06
get some sqlite quotes going on yo'
char *sqlite_sanitize( char* str )
{
char *safe_str;
int str_len = strlen( str );
int str_bad_chars = 0;
for( int i = 0; i < str_len; i++ )
if ( str[i] == '\'' || str[i] == '\"' )
str_bad_chars++;