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: | |
- ./lib/no_gem_version.rb |
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
#define SAMPLE_OUTSIDE_EDITOR | |
using UnityEngine; | |
using UnityEngine.Profiling; | |
public class MonoBehaviourSingleton<T> : MonoBehaviour where T : MonoBehaviourSingleton<T> | |
{ | |
static MonoBehaviourSingleton<T> instance; | |
// Used to select the behavior of the singleton when it's destroyed, if it's "true" then |
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 'jwt' | |
module Token | |
class Builder | |
VALID_ALGORITHMS = ['HS256', 'RS256'].freeze | |
attr_reader :token | |
def initialize | |
@payload = {} |
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 Test | |
class Base | |
def hello | |
puts 'Hello' | |
end | |
end | |
Application = Base.new | |
module Delegator |
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' | |
require 'benchmark/ips' | |
require 'memory_profiler' | |
N = 50000 | |
PROCS = [ | |
[ | |
"Description 1", | |
-> { 'Insert code here' } |
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 Gracefully | |
class << self | |
alias_method :handle, :new | |
end | |
attr_reader :error, :value | |
def initialize | |
@value = nil | |
@error = nil |
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 BasicStruct | |
ATTRIBUTES = %i[] | |
def initialize(options = {}) | |
attributes = options.with_indifferent_access | |
self.class::ATTRIBUTES.each do |attribute| | |
instance_variable_set("@#{attribute}", attributes[attribute]) | |
class_eval { attr_reader attribute } | |
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
require 'rspec/expectations' | |
RSpec::Matchers.define :match_stream do |expected_stream| | |
match do |actual_stream| | |
loop do | |
actual_element = actual_stream.next rescue :eof | |
expected_element = expected_stream.next rescue :eof | |
return false unless actual_element == expected_element | |
return true if actual_element == :eof | |
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 Retryer | |
def initialize | |
@retry_times = 3 | |
@block = Proc.new {} | |
@args = nil | |
@backoff = false | |
end | |
def block(&block) | |
@block = block |
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 DatabaseRowStream | |
include Enumerable | |
BATCH_SIZE = 20_000 | |
def initialize(sql, options = {}) | |
@sql = sql | |
if options[:pluck] | |
@pluck = options[:pluck].respond_to?(:join) ? options[:pluck].join(', ') : options[:pluck] | |
end |