I hereby claim:
- I am glennfu on github.
- I am glennfu (https://keybase.io/glennfu) on keybase.
- I have a public key ASAVcYf3fpA81yrW6C_8vxGA37B59iFDv2SgKUvAKlXbZQo
To claim this, I am signing this object:
class ArticleChannel < ApplicationCable::Channel | |
def subscribed | |
@article = Article.find(params[:article_id]) | |
@editor_id = params[:editor_id] | |
# Write it only if the editor is truly nil in a single query to avoid race conditions | |
Article.where(id: @article.id, editor: nil).update(editor: @editor_id) | |
stream_for @article |
# frozen_string_literal: true | |
require "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
gem "rails", github: "rails/rails" |
Version4::Foo.last.bars.first.class | |
=> Version4::Bar | |
Version5::Foo.last.bars.first.class | |
=> Version4::Bar | |
# The models | |
class TextMessage < ApplicationRecord | |
belongs_to :account, inverse_of: :text_messages, optional: true | |
belongs_to :user, inverse_of: :text_messages, optional: true | |
has_many :phones, ->(text_message) { joins(name: :products).where("products.account_id = ?", text_message.account_id) }, foreign_key: :number, primary_key: :client_phone_number | |
has_many :names, through: :phones, source: :name | |
class Phone < ApplicationRecord | |
belongs_to :name, inverse_of: :phones |
I hereby claim:
To claim this, I am signing this object:
def parse_stuff | |
geoloc = Geokit::Geocoders::GoogleGeocoder3.geocode address.gsub("\n", ", ") | |
placemark = JSON.parse(geoloc.to_json) | |
# Sometimes the most accurate entry doesn't have a city, but a less accurate version does | |
if city.blank? && region.present? && geoloc.respond_to?(:all) | |
placemark["city"] = geoloc.all.detect(&:city).try(&:city) | |
end | |
end |
require 'geokit' | |
module Geokit | |
module IpGeocodeLookup | |
# Overriding this to only store for 2 hours instead of 30 days | |
def store_ip_location | |
return if params[:lat] && params[:lng] | |
unless session[:geo_location] |
/* | |
Turbolinks 5.0.0.beta4 | |
Copyright © 2016 Basecamp, LLC | |
*/ | |
; | |
(function() { | |
this.Turbolinks = { | |
supported: (function() { | |
return (window.history.pushState != null) && (window.requestAnimationFrame != null); |
class InventoryItem < ActiveRecord::Base | |
def self.update_kit_ids | |
search = NetSuite::Records::InventoryItem.search({ | |
criteria: { | |
basic: [ | |
{ | |
field: 'type', | |
operator: 'anyOf', | |
type: 'SearchEnumMultiSelectField', |
OldHttpRequest = Turbolinks.HttpRequest | |
class Turbolinks.CachedHttpRequest extends Turbolinks.HttpRequest | |
constructor: (_, location, referrer) -> | |
super(this, location, referrer) | |
requestCompletedWithResponse: (response, redirectedToLocation) -> | |
@response = response | |
@redirect = redirectedToLocation | |