query Hero($episode: Episode, $withFriends: Boolean!) {
hero(episode: $episode) {
name
friends @include(if: $withFriends) {
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
Resources: | |
- https://superuser.com/questions/39040/re-indent-shell-script | |
- https://unix.stackexchange.com/questions/12902/how-to-run-find-exec | |
- https://superuser.com/questions/336016/invoking-vi-through-find-xargs-breaks-my-terminal-why | |
find ./path/to/dir -type f -name '*.rb' \ | |
-exec vim -c 'set tabstop=2 shiftwidth=2 | retab | +normal gg=GZZ | %s/\s\+$//e | wq' {} \; |
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
mix run deps.get, compile |
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 install sinatra --no-rdoc --no-ri |
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
# Will experience a performance benefit over #instance_eval as | |
# this method will experience only 1 scope change whereas with | |
# #instance_eval, that will happen for each request | |
def generate_method(method_name, &block) | |
method_name = method_name.to_sym | |
define_method(method_name, &block) | |
# grab the unbound method block | |
method = instance_method method_name | |
remove_method method_name | |
method |
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
rackup -p 4567 | |
# Must be called in same directory as config.ru | |
# -s thin specifies to run w/ thin server | |
rackup -p 4567 -s thin |
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 'sinatra/base' | |
class MyApp < Sinatra::Base; end | |
class SubApp < MyApp; end | |
MyApp.set :string, "Hi" | |
MyApp.string #=> "Hi" | |
SubApp.string #=> "Hi" | |
SubApp.set :string, "Hello" | |
SubApp.string #=> "Hello" | |
MyApp.string #=> "Hi" |
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
ls -l | grep ^d |
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
# Find the SHA of the dropped commit | |
gitk --all --date-order $(git log -g --pretty=%H) | |
# Once you have found the correct state of your branch, you can get back to that state by running | |
git reset --hard SHA | |
# You could also link that old state to a new branch name using | |
git checkout -b newbranch SHA |
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
#!/usr/bin/env bash | |
# Assumes you are running with Bash 3 | |
# {see: https://stackoverflow.com/questions/1494178/how-to-define-hash-tables-in-bash} | |
# First, indirection. | |
animals_moo=cow; sound=moo; i="animals_$sound"; echo "${!i}" | |
# Secondly, `declare`: | |
sound=moo; animal=cow; declare "animals_$sound=$animal"; echo "$animals_moo |
OlderNewer