Skip to content

Instantly share code, notes, and snippets.

View nurey's full-sized avatar

Ilia Lobsanov nurey

View GitHub Profile
@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",
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: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
# 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 / 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
class ScheduleGroup < ActiveRecord::Base
include AbstractGroup
has_and_belongs_to_many :schedules
end
class Schedule < ActiveRecord::Base
has_and_belongs_to_many :schedule_groups
end
@nurey
nurey / gist:1169346
Created August 24, 2011 21:47
recurly jsonp
Request URL:https://api-sandbox.recurly.com/jsonp/propertycloud-test/subscribe?callback=jQuery15204271336100064218_1314221946001&subscription%5Bplan_code%5D=2&subscription%5Bquantity%5D=1&subscription%5Bcoupon_code%5D=early&subscription%5Badd_ons%5D=&account%5Bfirst_name%5D=Ilia&account%5Blast_name%5D=Lobsanov&account%5Baccount_code%5D=ilia%40nurey.com-16&account%5Bemail%5D=ilia%40nurey.com&billing_info%5Bmonth%5D=8&billing_info%5Byear%5D=2012&billing_info%5Bnumber%5D=4111111111111111&billing_info%5Bverification_value%5D=111&billing_info%5Baddress1%5D=11+ivy+&billing_info%5Baddress2%5D=&billing_info%5Bcity%5D=toronto&billing_info%5Bstate%5D=ontario&billing_info%5Bzip%5D=m4l2h6&billing_info%5Bcountry%5D=CA&_=1314222009210
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Cookie:km_ai=3L2u0z8Pq7nfP7Lq8iTarb%2B7z1w%3D; km_lv=x; omp__super_properties=%7B%22
Uncaught TypeError: Object function h(a,b,c){var f,g;if(!(g=c&&c[a])){if(c=!c)h:{for(c=b.target;c;){if((g=h.data(c,q))&&(!a||g[a]))break h;c=c.parentNode}c=null}g=c}if(g){f=b;var c=f.type,i,j;f=h.Event(f),f.type=a,g=f.originalEvent,i=h.event.props;if(g)for(j=i.length;j;)a=i[--j],f[a]=g[a];c.search(/mouse(down|up)|click/)>-1&&!f.which&&(f.which=1);if(c.search(/^touch/)!==-1&&(a=e(g),c=a.touches,a=a.changedTouches,c=c&&c.length?c[0]:a&&a.length?a[0]:d)){g=0;for(len=s.length;g<len;g++)a=s[g],f[a]=c[a]}h(b.target).trigger(f)}return f} has no method 'Event'
hmobile_application-80cf04ccdb0980071685ed596bdcf695.js:18
kmobile_application-80cf04ccdb0980071685ed596bdcf695.js:19
f.event.handlemobile_application-80cf04ccdb0980071685ed596bdcf695.js:17
f.event.add.i.handle.kmobile_application-80cf04ccdb0980071685ed596bdcf695.js:16
370
mobile_application-80cf04ccdb0980071685ed596bdcf695.js:18Uncaught TypeError: Object function h(a,b,c){var f,g;if(!(g=c&&c[a])){if(c=!c)h:{for(c=b.target;c;){if((g=h.data(c,q))&&(!a||g[a]))bre
@nurey
nurey / fb-fan-export.js
Created October 6, 2011 01:58 — forked from adamloving/fb-fan-export.js
Export Facebook Page Fans
/*
For more detailed instructions on how to use this script, sign up with your email here:
http://adamloving.com/internet-programming/how-toexport-facebook-page-fans
DISCLOSURE: This javascript runs in your browser pretending to be you
looking through your page fans. Facebook should have no problem with this,
but who knows if they will think it is strange to see you looking through
all your fans so quickly (the script waits 3s before requesting each page).
I've had no problem running this so far for 1000s of page fans, but I
goldrush:manager ilia$ git show a62e29f5009e73bc32dc978046c088afa93ae9cd
commit a62e29f5009e73bc32dc978046c088afa93ae9cd
Author: Ilia Lobsanov <ilia@nurey.com>
Date: Tue Oct 11 11:59:19 2011 -0400
update datatables
diff --git a/vendor/plugins/datatables b/vendor/plugins/datatables
index a9e3d63..56646d1 160000
--- a/vendor/plugins/datatables