Skip to content

Instantly share code, notes, and snippets.

Paul Hoffer phoffer

Block or report user

Report or block phoffer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@phoffer
phoffer / karabiner.json
Created Aug 10, 2017
karabiner elements config
View karabiner.json
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
@phoffer
phoffer / RGeo PostGIS roundtrip
Last active Feb 9, 2017
postgis-rgeo-point.rb
View RGeo PostGIS roundtrip
require 'rgeo'
# RGeo factory for spherical latlong points
rgeo_factory = RGeo::Geographic.spherical_factory(:srid => 4326)
coord = rgeo_factory.point(-111.500244140625, 40.84706035607122)
# => RGeo point "Point (-111.500244140625 40.84706035607122)"
point_text = RGeo::WKRep::WKBGenerator.new(hex_format: true, type_format: :ewkb, emit_ewkb_srid: true).generate(coord)
# => "0020000001000010e6c05be0040000000040446c6c79478831" # this is what is stored in Postgres
new_coord = RGeo::WKRep::WKBParser.new(rgeo_factory, support_ewkb: true, default_srid: 4326).parse(point_text)
# => RGeo point "Point (-111.500244140625 40.84706035607122)"
new_coord == coord # => true
@phoffer
phoffer / blank.cr
Last active Jun 21, 2016
timing two different crystal implementations of String#blank?
View blank.cr
# crystal version: 0.17.4
struct Char
def blank?
case ord
when 9, 0xa, 0xb, 0xc, 0xd, 0x20, 0x85, 0xa0, 0x1680, 0x180e,
0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006,
0x2007, 0x2008, 0x2009, 0x200a, 0x2028, 0x2029, 0x202f,
0x205f, 0x3000 then true
else
false
@phoffer
phoffer / rwol.css
Last active Dec 6, 2015
Custom CSS for Runner's World Forums
View rwol.css
/*
---------------------
Author: Paul Hoffer
Github: phoffer
Twitter: @phoffer8
Version: 1.0
---------------------
# Purpose
View mc_nginx.conf
server {
listen 80;
server_name localhost mc.local;
root /Users/paul/Projects/mc/public;
try_files $uri/index.html $uri @app;
# Send everything to the app defined in the upstream
location /todo {
@phoffer
phoffer / dark_launch.rb
Last active Aug 29, 2015
dark launch with mixin
View dark_launch.rb
module DarkLaunch
FEATURES = %w(feature_a feature_b feature_c) # could load this from a config file
def self.included(base)
FEATURES.each do |f|
base.send(:define_method, "has_access_to_#{f}?") { DarkLaunch.feature_visible(f, self) }
end
# could add a method_missing handler for the same prefix, for things that aren't explicitly defined
end
@phoffer
phoffer / _start_thin.rb
Created Mar 4, 2014
Windows launcher for thin
View _start_thin.rb
ENV['MONGOLAB_URI'] = 'mongodb://user:pass@server:port/db_name'
ENV['other_ENV_var'] = 'other environment variable'
spawn 'thin -R config.ru start -p 3000'
You can’t perform that action at this time.