Skip to content

Instantly share code, notes, and snippets.

View tudorpavel's full-sized avatar

Tudor Pavel tudorpavel

  • Cluj-Napoca, Romania
View GitHub Profile
@tudorpavel
tudorpavel / RUBY_SETUP.md
Last active September 27, 2016 09:02
Local setup for using Ruby on Linux
@tudorpavel
tudorpavel / some_model.rb
Created September 13, 2015 11:30
Rails PostGIS within_range query.
def self.within_range(range_km, lat, lng)
if lat.present? && lng.present?
joins(location: :point)
.where(
"ST_DWithin(Geography(ST_MakePoint(longitude, latitude)),
Geography(ST_MakePoint(#{lng}, #{lat})),
#{(range_km * 1000).to_i})"
)
else
none
def calc(arr)
arr[0] + (13.0 * arr[1] / arr[2]) + arr[3] + (12 * arr[4]) - arr[5] + (arr[6].to_f * arr[7] / arr[8])
end
def solutions
[1,2,3,4,5,6,7,8,9].permutation.to_a.keep_if { |p| calc(p) == 87.0 }
end
@tudorpavel
tudorpavel / RAILS_SETUP.md
Last active February 11, 2016 15:07
Local setup for Ruby on Rails development on Linux

Ruby on Rails Setup

Install Ruby

Ruby on Rails depends on the Ruby programming language (doh), so we need to install that first. Follow the Ruby Setup guide to install a local version of Ruby.

Install Rails

Install the latest version of Rails