Skip to content

Instantly share code, notes, and snippets.

View deivinsontejeda's full-sized avatar
🎯

Deivinson Tejeda deivinsontejeda

🎯
  • Santiago of Chile
View GitHub Profile
# delay the GC - usage as below
# Spec::Runner.configure do |config|
.....
# config.before(:each) do
# begin_gc_deferment
# end
# config.after(:each) do
require 'json'
class JsonFormatter
METHODS = %w[start close stop start_dump dump_pending dump_failures dump_summary]
METHODS.each { |m| define_method(m) { |*a| } }
def initialize(out)
@output = out
@event_id = 0
@passed = true
class SimpleLinearRegression
def initialize(xs, ys)
@xs, @ys = xs, ys
if @xs.length != @ys.length
raise "Unbalanced data. xs need to be same length as ys"
end
end
def y_intercept
mean(@ys) - (slope * mean(@xs))
class TestDSL < Regexp
def initialize(&block)
instance_eval &block
super('/some_regex/')
end
def some_method(value)
puts "Output: #{value}"
end
end
@deivinsontejeda
deivinsontejeda / gist:6919226
Created October 10, 2013 14:24
Constantize without ActiveSupport

Constatize a string without ActiveSupport (commonly come by default in rails) isn't friendly and in some case include AS is overkill. So, with this snipe you can constatize a String.

require 'net/http'
cls = "Net::HTTP".split('::').inject(Object) { |host,name| memo.const_get(name) }

# now you can use cls like normal constant
cls.new

@deivinsontejeda
deivinsontejeda / gist:7721060
Last active September 15, 2017 12:46
.gemrc
---
:verbose: false
install: --no-document --env-shebang
:sources:
- https://rubygems.org
:benchmark: false
:backtrace: false
update: --no-document --env-shebang
:update_sources: true
require 'irb/completion'
ARGV.concat [ "--readline", "--prompt-mode", "simple" ]
IRB.conf[:EVAL_HISTORY] = 1000
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:HISTORY_FILE] = File::expand_path("~/.irbhistory")
#begin
# require 'pry'
# Pry.start
#rescue LoadError
# puts "you need run 'gem install pry'"

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
package main
import (
"fmt"
)
const (
GOROTUNIES = 2
)