Skip to content

Instantly share code, notes, and snippets.

View zackperdue's full-sized avatar
🛩️
Working from home

Zack Perdue zackperdue

🛩️
Working from home
  • Unicorn
  • Bali, Indonesia
View GitHub Profile
@zackperdue
zackperdue / UITextField + Extension.swift
Created February 12, 2020 06:57
[FIX] UITextField Text Jumping Sideways
override func resignFirstResponder() -> Bool {
let resigned = super.resignFirstResponder()
self.layoutIfNeeded()
return resigned
}
@zackperdue
zackperdue / location.rb
Created February 27, 2017 12:23
In your model...
before_create :set_location
def set_location
factory = RGeo::Geographic.spherical_factory(srid: 4326)
self.lonlat = factory.point(lon, lat)
end
default: &default
adapter: postgis
schema_search_path: '"$user", public, postgis'
production:
url: <%= ENV.fetch('DATABASE_URL', '').sub(/^postgres/, "postgis") %>
@zackperdue
zackperdue / postgis.rb
Created February 27, 2017 12:14
postgis initializer for rails
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")
end
@zackperdue
zackperdue / Procfile
Created January 25, 2016 21:28
Procfile for Foreman gem I often use.
web: bundle exec unicorn -p $PORT
worker: bundle exec sidekiq -q default
cron: bundle exec clockwork clock.rb
<input type="file" name="file_selector" id="file_selector" multiple="multiple" accept="video/*">
var fileSelector = document.getElementById('file_selector')
var uploader = new FileUploader({
uploadType: 'Video',
fileInput: fileSelector
})
@zackperdue
zackperdue / README.md
Last active August 29, 2015 14:21
Matchlength.js

Matchlength.js

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!

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