Skip to content

Instantly share code, notes, and snippets.

@phoffer
phoffer / karabiner.json
Created August 10, 2017 23:37
karabiner elements config
{
"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 February 9, 2017 17:40
postgis-rgeo-point.rb
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 June 21, 2016 00:12
timing two different crystal implementations of String#blank?
# 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 December 6, 2015 02:09
Custom CSS for Runner's World Forums
/*
---------------------
Author: Paul Hoffer
Github: phoffer
Twitter: @phoffer8
Version: 1.0
---------------------
# Purpose
@phoffer
phoffer / mc_nginx.conf
Created June 15, 2015 22:24
nginx sample
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 August 29, 2015 14:22
dark launch with mixin
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 March 4, 2014 16:21
Windows launcher for thin
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'