This file contains hidden or 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
# I use find -print0 and xargs -0 when the filenames contain characters used as delimitors, | |
# like space in this case | |
# | |
find '/tmp/temp results' -name '*.tmp' -print0 | xargs -0 -n 1 -J % rm '%' |
This file contains hidden or 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
git config `push.default`: | |
– `nothing`: do nothing (make the user say what they mean) | |
– `matching`: push all local branches for which a remote branch of the same name exists | |
– `upstream`: push only the current branch, push it to its upstream, making push and pull symmetric | |
– `simple`: like upstream, but only if the branch names match (will become default in 2.0) | |
– `current`: push just the current branch |
This file contains hidden or 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 convert_to_proc(&proc) | |
proc | |
end | |
hello = convert_to_proc { |name| puts "Hello #{name}" } | |
hello.call("Eric") # => "Hello Eric" |
This file contains hidden or 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" | |
array = [...] | |
Benchmark.bm(7) do |x| | |
x.report("map") { array.map(&:upcase) } | |
x.report("map!") { array.map!(&:upcase) } | |
end | |
This file contains hidden or 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
namespace :time_travel do | |
desc "Description of the lightning task" | |
task :lightning do |t| | |
# ... | |
end | |
desc "Description of the de_lorean task" | |
task :de_lorean do |t| | |
# ... |
This file contains hidden or 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
<% | |
=begin | |
%> | |
This <a href="javascript:void(0);">will not be in the result HTML page.</a> | |
<% | |
=end | |
%> |
This file contains hidden or 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
class MyController < ApplicationController | |
def action_xyz | |
if request.xhr? | |
set_cache_buster | |
end | |
render json: {what: 'ever'} | |
end |
This file contains hidden or 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
en: | |
# ~~~~~~~~ | |
# Model Errors | |
# ~~~~~~~~ | |
activemodel: | |
errors: | |
models: | |
bidrequest: | |
not_json: "Not a valid JSON" | |
url_not_valid: "Not a valid URL" |
This file contains hidden or 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
describe MyController do | |
before do | |
# ... | |
# Stub MyController.action to always return OK | |
def @controller.action | |
render status: 200, nothing: true | |
end |
This file contains hidden or 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
nc -kl 12345 # netcat listen on port 12345 and keep-alive |