Skip to content

Instantly share code, notes, and snippets.

View azuby's full-sized avatar

azuby

  • California, USA
View GitHub Profile
@azuby
azuby / Dog.java
Last active June 12, 2016 18:29 — forked from cmelchior/ SerializeToJson.java
Serialize RealmObjects using Gson
package io.realm.example;
import io.realm.RealmObject;
public class Dog extends RealmObject {
private String name;
public String getName() {
return name;
package io.realm.example;
import io.realm.RealmObject;
public class Dog extends RealmObject {
private String name;
public String getName() {
return name;
package io.realm.example;
import io.realm.RealmObject;
public class Dog extends RealmObject {
private String name;
public String getName() {
return name;
@azuby
azuby / gist:5356433
Last active December 16, 2015 01:39 — forked from kelso/gist:5356418
Starts working at 7am at Job A
Starts travelling at 8am from Job A
Starts working at 9am at Job B
Finished for the day at 3pm
| datetime | activity | job_id | duration | adjusted_dateimte | adjusted_duration
+----------+---------------+--------+
7am work 1 1 9am 0 (9am - 8am)

Method A: Carrier - Poor Location Precision, Secure

Method B: Client(phone) - High Location Precision, Insecure (Can be spoofed)

Option 1: Improve precision of Method A (Carrier Location)

  • Supports all phones on Tier 1 carriers
  • Find and correct for inaccuracy patterns

Option 2: Prevent spoofing of Method B (Client Location)

class Diagnosis < ActiveRecord::Base
has_and_belongs_to_many :prescriptions
has_many :patients, :through=>:prescriptions
end
@azuby
azuby / message.rb
Created March 5, 2012 21:45 — forked from StlTenny/gist:1981303
StlTenny Models
class Message < ActiveRecord::Base
belongs_to :user
# accepts_nested_attributes_for :user
end
def self.active
s = arel_table where(
s[:begins_at].lteq(Time.now.utc).or(s[:begins_at].eq(nil)),
s[:ends_at].gt(Time.now.utc).or(s[:ends_at]).eq(nil))
)
end
def self.active
s = arel_table.where(
s[:begins_at].lteq(Time.now.utc).or(s[:begins_at].eq(nil)),
@azuby
azuby / gist:1441213
Created December 7, 2011 02:49 — forked from radar/gist:1441191
validates :superiority
def superiority
User.find(superior_id).company_id == User.find(inferior_id).company_id
end
# Karpah's method
validates :superior_id, :if => "User.find(superior_id).company_id == User.find(inferior_id).company_id"