type Customer {
id: ID!
email: String!
}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a skeleton for testing models including examples of validations, callbacks, | |
# scopes, instance & class methods, associations, and more. | |
# Pick and choose what you want, as all models don't NEED to be tested at this depth. | |
# | |
# I'm always eager to hear new tips & suggestions as I'm still new to testing, | |
# so if you have any, please share! | |
# | |
# @kyletcarlson | |
# | |
# This skeleton also assumes you're using the following gems: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module GeoHelper | |
def maxmind_locate | |
uri = URI("https://geoip.maxmind.com/geoip/v2.1/city/#{request.remote_ip}?pretty") | |
Net::HTTP.start(uri.host, uri.port, | |
:use_ssl => uri.scheme == 'https', | |
:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urlparse | |
import httplib | |
import base64 | |
proxy_uri = "http://user:password@proxy_host:proxy_port" | |
host = 'www.google.com' | |
port = 443 | |
url = urlparse.urlparse(proxy_uri) | |
conn = httplib.HTTPSConnection(url.hostname, url.port) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query | |
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails | |
#payload: [{"kind"=>"person"}] | |
Segment.where("payload @> ?", [{kind: "person"}].to_json) | |
#data: {"interest"=>["music", "movies", "programming"]} | |
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json) | |
Segment.where("data #>> '{interest, 1}' = 'movies' ") | |
Segment.where("jsonb_array_length(data->'interest') > 1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/dev/real-world-rails (master) | |
$ ag -G 'config/initializers/' ::DATE_FORMATS | |
apps/accelerated_claims/config/initializers/date_formats.rb | |
1:Date::DATE_FORMATS[:printed] = '%d %B %Y' | |
apps/advocate-defence-payments/config/initializers/date_time.rb | |
2:Date::DATE_FORMATS[:default] = Settings.date_format | |
5:DateTime::DATE_FORMATS[:default] = Settings.date_time_format | |
8:Time::DATE_FORMATS[:default] = Settings.date_time_format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// first run: | |
// yarn add glob-all purgecss-webpack-plugin --dev | |
/* | |
config/webpack/environment.js | |
PurgeCSS configuration for Rails 5 + Webpacker + Tailwind CSS + Vue.js | |
Optionally, put this in production.js if you only want this to apply to production. | |
For example, your app is large and you want to optimize dev compilation speed. | |
*/ |