Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am nurey on github.
  • I am ilia (https://keybase.io/ilia) on keybase.
  • I have a public key whose fingerprint is ADC2 0622 48F3 E61F 899A 9BD6 FCC9 4A43 EE4F A3A2

To claim this, I am signing this object:

select ST_Area(the_geom), ST_Area(the_geom::geography) from geospatial_lookup where id = 23578;
st_area | st_area
--------------------+------------------
0.0706906461999737 | 632842160.137236
(1 row)
@nurey
nurey / students.rb
Last active February 26, 2016 02:57
# this requires ruby 2.3
students = {
:"bobby crimble" => {
math: 68,
physics: 77,
phys_ed: 81,
english: 71
},
:"anne shirley" => {
@nurey
nurey / time_vs_datetime.md
Created August 14, 2015 16:45 — forked from pixeltrix/time_vs_datatime.md
When should you use DateTime and when should you use Time?

When should you use DateTime and when should you use Time?

It's a common misconception that [William Shakespeare][1] and [Miguel de Cervantes][2] died on the same day in history - so much so that UNESCO named April 23 as [World Book Day because of this fact][3]. However because England hadn't yet adopted [Gregorian Calendar Reform][4] (and wouldn't until [1752][5]) their deaths are actually 10 days apart. Since Ruby's Time class implements a [proleptic Gregorian calendar][6] and has no concept of calendar reform then there's no way to express this. This is where DateTime steps in:

>> shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND)
=> Tue, 23 Apr 1616 00:00:00 +0000
>> cervantes = DateTime.iso8601('1616-04-23', Date::ITALY)
=> Sat, 23 Apr 1616 00:00:00 +0000
# Rails 4.2.1
[19] pry(main)> ActionController::Base.helpers.class
=> ActionView::Base
[20] pry(main)> ActionController::Base.helpers.asset_path 'clear.gif'
=> "/assets/clear.gif"
[21] pry(main)> ActionView::Base.asset_path 'clear.gif'
=> "/clear.gif
@nurey
nurey / gist:ec37982ef33d82a9d9d8
Last active August 29, 2015 14:09
has_locker
CREATE OR REPLACE FUNCTION has_locker(field json)
RETURNS boolean
LANGUAGE sql
AS $function$
select
case json_extract_path_text($1, 'locker')
when 'None' then false
when 'No' then false
create or replace function json_maintenance(field json) returns numeric as
$$
BEGIN
select json_extract_path_text($1, 'maintenance')::numeric(6,2);
EXCEPTION WHEN others THEN
RETURN null;
END
$$
language plpgsql strict;
@nurey
nurey / gist:9916489
Last active August 29, 2015 13:57
watchman --persistent --server-encoding=json log-level debug
{
"version": "2.9.5",
"log": "1396365899: tid=211292160 notify_thread[/Users/ilia/Devel/angularjs-imageupload-directive/src] assessing triggers\n"
}
{
"version": "2.9.5",
"log": "1396365899: tid=211292160 notify_thread[/Users/ilia/Devel/angularjs-imageupload-directive/src] assessing triggers\n"
}
{
"version": "2.9.5",
SELECT "places".* FROM (
SELECT
*,
ST_Distance_Sphere(geom, 'SRID=4326;POINT(-79.3937393 43.6526704)') as distance
FROM places
ORDER by geom <#> 'SRID=4326;POINT(-79.3937393 43.6526704)' LIMIT 50
) AS places
WHERE "places"."place_category_id" = 10 ORDER BY distance ASC LIMIT 5
@nurey
nurey / cocos2d.podspec
Created March 25, 2013 22:56
Podspec for cocos2d 2.1.beta3. There's not an official podspec for this version.
Pod::Spec.new do |s|
s.name = 'cocos2d'
s.license = 'MIT'
s.version = '2.1.beta3'
s.summary = 'cocos2d for iPhone is a framework for building 2D games, demos, and other graphical/interactive applications.'
s.description = 'cocos2d for iPhone is a framework for building 2D games, demos, and other graphical/interactive applications for iPod Touch, iPhone, iPad and Mac. It is based on the cocos2d design but instead of using python it, uses objective-c.'
s.homepage = 'http://www.cocos2d-iphone.org'
s.author = { 'Ricardo Quesada' => '[email protected]', 'Zynga Inc.' => 'https://zynga.com/' }
s.source = {:git => 'https://github.com/cocos2d/cocos2d-iphone.git', :tag => 'release-2.1-beta3'}