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
package main | |
import ( | |
"fmt" | |
"encoding/json" | |
) | |
type A struct { | |
A string | |
} |
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
done := make(chan struct{}) | |
defer func(c chan struct{}) { | |
select { | |
case <-c: | |
default: | |
close(c) | |
} | |
}(done) |
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 A | |
def hi | |
puts 'hi' | |
end | |
end | |
a = A.new | |
a.hi | |
# => "hi" |
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 A | |
def hi | |
puts "hi" | |
end | |
end | |
a = A.new | |
a.hi | |
# => hi |
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
module M1 | |
def hi | |
puts "hi in M1" | |
end | |
end | |
class A | |
include M1 | |
def ha |
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 A | |
def hi | |
puts 'hi' | |
end | |
end | |
a = A.new | |
a.hi | |
# => "hi" |
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
# * Style guide based on Rails documention | |
module Namespace #:nodoc: don't document this | |
# Generic Namespace exception class | |
class NamespaceError < StandardError | |
end | |
# Raised when... | |
class SpecificError < NamespaceError | |
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
require "json" | |
requests = {} | |
File.open("production.log").each_line do |ln| | |
if ln =~ /^\[([0-9a-f]+)\] (.+)/ | |
id = $1 | |
msg = $2 | |
requests[id] ||= {lines: []} | |
requests[id][:lines] << msg | |
if msg =~ /Processing by (.+) as/ |
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
module ArCache | |
extend ActiveSupport::Concern | |
def get(path, headers = {}) | |
cache_key = "ar_cache_#{path}" | |
Rails.cache.fetch(cache_key, expires_in: 60.seconds) do | |
super | |
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
YourApp::Application.config.session_store.new(app).get_session({}, "session_store:fe95d1b2921ebf2eb7f18ece4f588520") |