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
log/ |
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 OneLinerExamples | |
# https://github.com/rack/rack/blob/f9ad97fd/lib/rack/request.rb#L150-L155 | |
def body := get_header(RACK_INPUT) | |
def script_name := get_header(SCRIPT_NAME).to_s | |
def script_name=(s) := set_header(SCRIPT_NAME, s.to_s) | |
def path_info := get_header(PATH_INFO).to_s | |
def path_info=(s) := set_header(PATH_INFO, s.to_s) | |
# https://github.com/rack/rack/blob/f9ad97fd/lib/rack/response.rb#L126-L129 |
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
alias gti="git" | |
alias gst="git status" | |
alias gbr="git branch" | |
alias glg="git log" | |
alias gfu="git fetch upstream" | |
alias gfo="git fetch origin" | |
alias gpo="git push origin" | |
alias gpu="git push upstream" |
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
# | |
# Run this with `rails runner route_ast.rb` | |
# | |
Rails.application.routes.routes.each do |route| | |
ast = route.ast | |
# do stuff with AST... | |
end |
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}%; |
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
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
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 '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 'rack' | |
Rack::Server.start(app: Proc.new{|env| [200, {'Content-Type' => 'text/html'}, env]}, Port: 8080) |
NewerOlder