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 "bundler" | |
lockfile = Bundler::LockfileParser.new(Bundler.read_file("Gemfile.lock")) | |
dsl = Bundler::Dsl.new | |
dsl.eval_gemfile("Gemfile") | |
gems = dsl.dependencies.map(&:name) | |
lockfile.specs.lazy.select do |spec| | |
gems.include?(spec.name) | |
end.map do |spec| | |
version_parts = spec.version.to_s.split(".") | |
if version_parts.count > 2 |
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
files = Dir["files/*.js"] | |
space_indented_count = files.select do |file| | |
File.read(file).split("\n").any? do |line| | |
line.match /^ .*/ | |
end | |
end.count | |
puts "Among the #{files.count} most popular Javascript projects in Github, #{space_indented_count} uses space indendation" |
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
(function() { | |
var componentSetupFlag = 'featureHasBeenInitialized'; | |
var setup = function() { | |
var elements = $('[data-feature-attribute]'); | |
if (elements.length == 0) { | |
return; | |
} | |
elements.each(function(index, element) { |
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
(function() { | |
// here I can declare my private functions | |
var setup = function() { | |
var elements = $('[data-toggle=my-feature]'); | |
if (elements.length == 0) { | |
return; | |
} |
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
ಠ_ಠ wget https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.3.tar.bz2 | |
ಠ_ಠ tar xvfj ruby-2.2.3.tar.bz2 | |
ಠ_ಠ cd ruby-2.2.3 | |
ಠ_ಠ yardoc --debug *.c | |
[debug]: Parsing ["addr2line.c", "array.c", "bignum.c", "class.c", "compar.c", "compile.c", "complex.c", "cont.c", "debug.c", "dir.c", "dln.c", "dln_find.c", "dmydln.c", "dmyenc.c", "dmyext.c", "encoding.c", "enum.c", "enumerator.c", "error.c", "eval.c", "eval_error.c", "eval_jump.c", "file.c", "gc.c", "golf_prelude.c", "goruby.c", "hash.c", "id.c", "inits.c", "io.c", "iseq.c", "lex.c", "load.c", "loadpath.c", "localeinit.c", "main.c", "marshal.c", "math.c", "miniinit.c", "miniprelude.c", "newline.c", "node.c", "numeric.c", "object.c", "pack.c", "parse.c", "prelude.c", "proc.c", "process.c", "random.c", "range.c", "rational.c", "re.c", "regcomp.c", "regenc.c", "regerror.c", "regexec.c", "regparse.c", "regsyntax.c", "ruby.c", "safe.c", "signal.c", "siphash.c", "sparc.c", "sprintf.c", "st.c", "strftime.c", "string.c", "struct.c", "symbol.c", "thread.c", "thread_pthread.c" |
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 Brave | |
def self.be(exception_classes = [NoMethodError]) | |
begin | |
yield | |
rescue *exception_classes => e | |
end | |
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
class ApplicationController | |
before_action :log_params | |
def log_params | |
# do some stuff with it, for example store it into the database | |
recursive_backup_params(params: params).to_json | |
end | |
def recursive_backup_params(params: {}) |
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
source 'https://rubygems.org' | |
ruby '2.2.2' | |
gem 's3', '~> 0.3' | |
# other stuff |
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
RSpec.configure do |config| | |
config.before :suite, type: :feature do | |
load "#{Rails.root}/db/seeds.rb" | |
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 'fileutils' | |
class Object | |
def pat | |
if block_given? | |
yield self | |
else | |
self | |
end | |
end |