Skip to content

Instantly share code, notes, and snippets.

View jrissler's full-sized avatar
🚀
Builder, creator, evangalist

James Rissler jrissler

🚀
Builder, creator, evangalist
View GitHub Profile
@jrissler
jrissler / nearby-coordinates.sql
Created November 9, 2020 17:35 — forked from statickidz/nearby-coordinates.sql
Ordering with SQL by nearest latitude & longitude coordinates (MySQL & SQLite)
---
METHOD 1
This should roughly sort the items on distance in MySQL, and should work in SQLite.
If you need to sort them preciser, you could try using the Pythagorean theorem (a^2 + b^2 = c^2) to get the exact distance.
---
SELECT *
FROM table
ORDER BY ((lat-$user_lat)*(lat-$user_lat)) + ((lng - $user_lng)*(lng - $user_lng)) ASC
@jrissler
jrissler / upgrade.md
Created October 7, 2017 14:28 — forked from chrismccord/upgrade.md
Phoenix 1.2.x to 1.3.0 Upgrade Instructions

If you want a run-down of the 1.3 changes and the design decisions behidn those changes, check out the LonestarElixir Phoenix 1.3 keynote: https://www.youtube.com/watch?v=tMO28ar0lW8

To use the new phx.new project generator, you can install the archive with the following command:

$ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez

Bump your phoenix dep

Phoenix v1.3.0 is a backwards compatible release with v1.2.x. To upgrade your existing 1.2.x project, simply bump your phoenix dependency in mix.exs:

@jrissler
jrissler / gist:8028562
Created December 18, 2013 19:43
What would sandi do?
# our conditions would be an array of 5 true or false conditions
case our_conditions
when /TT.FF/
ClassOne.new(self, our_conditions)
return_value
when /FT.../
ClassTwo.new(self, our_conditions)
return_value
when /TT.TF/
ClassThree.new(self, our_conditions)
@jrissler
jrissler / gist:2480002
Created April 24, 2012 14:11
cas docs
#application_controller
before_filter CASClient::Frameworks::Rails::Filter
before_filter :current_user
def current_user
if session[:cas_user]
@current_user ||= User.find(:first, :conditions => ["LOWER(users.email) = ?", session[:cas_user].mb_chars.downcase], :include => [:user_collections, :main_role])
else
@current_user = nil
end