Skip to content

Instantly share code, notes, and snippets.

Working from home

Zack Perdue zackperdue

Working from home
View GitHub Profile
zackperdue / UITextField + Extension.swift
Created Feb 12, 2020
[FIX] UITextField Text Jumping Sideways
View UITextField + Extension.swift
override func resignFirstResponder() -> Bool {
let resigned = super.resignFirstResponder()
return resigned
View location.rb
before_create :set_location
def set_location
factory = RGeo::Geographic.spherical_factory(srid: 4326)
self.lonlat = factory.point(lon, lat)
View database.yml
default: &default
adapter: postgis
schema_search_path: '"$user", public, postgis'
url: <%= ENV.fetch('DATABASE_URL', '').sub(/^postgres/, "postgis") %>
zackperdue / postgis.rb
Created Feb 27, 2017
postgis initializer for rails
View postgis.rb
RGeo::ActiveRecord::SpatialFactoryStore.instance.tap do |config|
# By default, use the GEOS implementation for spatial columns.
config.default = RGeo::Geos.factory_generator
# But use a geographic implementation for point columns.
config.register(RGeo::Geographic.spherical_factory(srid: 4326), geo_type: "point")
zackperdue / Procfile
Created Jan 25, 2016
Procfile for Foreman gem I often use.
View Procfile
web: bundle exec unicorn -p $PORT
worker: bundle exec sidekiq -q default
cron: bundle exec clockwork clock.rb
View upload.html
<input type="file" name="file_selector" id="file_selector" multiple="multiple" accept="video/*">
View script.js
var fileSelector = document.getElementById('file_selector')
var uploader = new FileUploader({
uploadType: 'Video',
fileInput: fileSelector
zackperdue /
Last active Aug 29, 2015


Attach this plugin to an input field and it matches the width of the field to the number of characters in the field. Great for inline editable text fields!

zackperdue / user.rb
Created May 21, 2015
Overwrite the way the friendly_id gem generates unique slugs.
View user.rb
friendly_id :slug_candidates, use: :slugged, slug_column: :namespace
def slug_candidates
[:first_name, :last_name]
def normalize_friendly_id(value)
super.gsub(/\-/, '')
zackperdue / LoadingIcon.css
Created May 7, 2015
ReactJS CSS3 Animated Loading Icon
View LoadingIcon.css
.spinner {
margin: 100px auto;
width: 50px;
height: 30px;
text-align: center;
font-size: 10px;
opacity: .5;
.spinner > div {