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 / DropdownMenu.jsx
Last active January 17, 2020 19:25
ReactJS Dropdown Menu with optgroup
import React from 'react';
var SelectInput = React.createClass({
propTypes: {
groupBy: React.PropTypes.string,
options: React.PropTypes.array.isRequired,
placeholder: React.PropTypes.string,
selected: React.PropTypes.string
},
@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 / 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 {
@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
@zackperdue
zackperdue / gist:7631681
Created November 24, 2013 20:00
ActiveModel::ForbiddenAttributesError in BlueprintsController#create
Controller:
class BlueprintsController < ApplicationController
protect_from_forgery with: :exception
def index
@blueprints = Blueprint
end
$controller = Request::current()->controller();
$action = Request::current()->action();
$directory = Request::current()->directory();
$controller_name = ($directory)? $directory.'_'.$controller : $controller;
if ( ! $this->a2->allowed($controller_name, $action))
{
HTTP::redirect(Route::url('account', array('action' => 'login')));
}
@zackperdue
zackperdue / gist:4726516
Last active December 12, 2015 06:08
Note: Modal body is part of another view. (using twitter bootstrap) Why is my Form tag not showing up? Driving me nuts!!!!
<!-- unexpected html. missing form element once it is rendered to page -->
<div class="modal-body">
<p>This is a safety feature so you don't do something you didn't mean to do.</p>
<div class="control-group">
<div class="controls">
<input type="password" name="password" placeholder="Your Account Password">
</div>
</div>