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
# gem 'did_you_mean', '0.9.7' | |
require 'yaml' | |
require 'set' | |
require 'did_you_mean' | |
class DidYouMean::WordCollection | |
include DidYouMean::BaseFinder | |
def initialize(words) |
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
#- correct_word: incorrect_word(user input) | |
# result: | |
# - list_of_candidates | |
--- | |
- absence: absense | |
result: | |
- absences | |
- absents | |
- absence | |
- absentee |
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
require 'json' | |
require 'open-uri' | |
require 'benchmark/ips' | |
require 'memory_profiler' | |
json = open('https://network.pivotal.io/api/v2/products').read | |
Benchmark.ips do |x| | |
x.report('symbolize_names: false') { JSON.parse(json) } | |
x.report('symbolize_names: true') { JSON.parse(json, symbolize_names: true) } |
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
def with_exceptions_app(enabled = true) | |
org_show_detailed_exceptions = Rails.application.env_config['action_dispatch.show_detailed_exceptions'] | |
org_show_exceptions = Rails.application.env_config['action_dispatch.show_exceptions'] | |
# This overrides the cached setting in Rails.application.config.consider_all_requests_local | |
Rails.application.env_config['action_dispatch.show_detailed_exceptions'] = !enabled | |
# Render templates instead of raising exceptions. | |
Rails.application.env_config['action_dispatch.show_exceptions'] = enabled |
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
require 'benchmark/ips' | |
require 'andpush' | |
require 'fcm' | |
server_key = ENV.fetch('FCM_TEST_SERVER_KEY') | |
DEVICE_TOKEN = ENV.fetch('FCM_TEST_REGISTRATION_TOKEN') | |
FCM_CLIENT = FCM.new(server_key) | |
PAYLOAD_FOR_FCM = { dry_run: true, notification: { title: "u", body: "y" } } |
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
require 'json' | |
require 'securerandom' | |
require 'delegate' | |
class ObjectMapper < SimpleDelegator | |
def self.parse(json_string, **opts) | |
JSON.parse(json_string, object_class: JsonHash, create_additions: true, create_id: JSON_CREADE_ID, **opts) | |
end | |
JSON_CREADE_ID = SecureRandom.uuid.freeze |
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
require 'benchmark_driver' | |
Benchmark.driver do |x| | |
x.prelude <<~RUBY | |
METHODS = ''.methods | |
INPUT = 'start_with?' | |
spell_checker = DidYouMean::SpellChecker.new(dictionary: METHODS) | |
RUBY |
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
require 'benchmark/ips' | |
require 'andpush' | |
require 'fcm' | |
server_key = ENV.fetch('FCM_TEST_SERVER_KEY') | |
DEVICE_TOKEN = ENV.fetch('FCM_TEST_REGISTRATION_TOKEN') | |
FCM_CLIENT = FCM.new(server_key) | |
PAYLOAD_FOR_FCM = { dry_run: true, notification: { title: "u", body: "y" } } |
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
# config/graphql.yml | |
development: | |
sw_api: | |
url: "https://example.com/graphql" | |
schema_path: "path/to/schema.json" | |
# app/operations/sw_api/hero.graphql | |
query($episode: Episode) { | |
hero(episode: $episode) { | |
name |
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 { LitElement, html, customElement } from '@polymer/lit-element' | |
const NUMBER_OF_GRID = 12 | |
const generateCss = (screenSize) => { | |
return Array.apply(0, Array(NUMBER_OF_GRID)).map((element, index) => index + 1).map(num => | |
` | |
:host([${screenSize}="${num}"]) { | |
-ms-flex-preferred-size: ${(100 / NUMBER_OF_GRID) * num}%; | |
flex-basis: ${(100 / NUMBER_OF_GRID) * num}%; |