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 'active_support/core_ext/string' | |
module Logger | |
class Null | |
def initialize | |
@blob = {} | |
end | |
def unknown(*); end | |
def fatal(*); 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_generator = ->(name, attrs) { | |
file = "tmp/meta_classes/#{name.underscore}.rb" | |
FileUtils.mkdir_p(File.dirname(file)) | |
template = File.write(file, ERB.new(<<TEMP, nil, "%").result(binding)) | |
class <%= name %> | |
attr_accessor <%= attrs.map(&:inspect).join(', ') %> | |
def initialize(<%= attrs.join(", ") %>) | |
% attrs.each do |attr| | |
@<%= attr %> = <%= attr %> |
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
[[3, "end"], | |
[3, "end"], | |
[3, "end"], | |
[3, "end"], | |
[5, " end"], | |
[5, " end"], | |
[5, " end"], | |
[5, " end"], | |
[5, " end"], | |
[5, " 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
$ be() { if [ -f .env ]; then env $(<.env grep -v "^#") bundle exec "$@"; else bundle exec "$@"; fi; } | |
$ echo HELLO=WORLD > .env | |
$ echo "# a comment" >> .env | |
$ be ruby -e 'puts ENV["HELLO"]' | |
WORLD |
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 set_env | |
around do |ex| | |
@old_env = ENV.to_h | |
yield ENV | |
ex.call | |
ENV.replace(ENV) | |
end | |
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
ag ENV.*?[A-Z_]+ -o --no-filename | ag -o [A-Z_]+$ | sort | uniq |
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
mysql> create temporary table tmp (d INT(11)); | |
Query OK, 0 rows affected (0.02 sec) | |
/* there are 2 rows being inserted with value of 1 */ | |
mysql> insert into tmp (d) values (1), (2), (1), (3); | |
Query OK, 4 rows affected (0.01 sec) | |
/* this shows that distinct works */ | |
mysql> select distinct d from tmp; | |
+------+ |
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
>> RUST_BACKTRACE=1 cargo run > log.txt | |
Compiling serde v1.0.43 | |
Compiling core-foundation-sys v0.5.1 | |
Compiling regex-syntax v0.5.5 | |
Compiling walkdir v2.1.4 | |
Compiling base64 v0.9.1 | |
Compiling proc-macro2 v0.3.8 | |
Compiling num-traits v0.1.43 | |
Compiling rand v0.4.2 | |
Compiling net2 v0.2.32 |
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 Proc | |
def <<(*args) | |
args = args.flatten if args.count == 1 | |
-> (*items) { self.call(*items, *args) } | |
end | |
end | |
adder = -> (*args) { args.inject(&:+) } | |
puts [1,2,3,4,5] |
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 | |
require 'bundler/inline' | |
rescue LoadError => e | |
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler' | |
raise e | |
end | |
gemfile(true) do | |
source 'https://rubygems.org' | |
gem 'rails', github: 'rails/rails' |
NewerOlder