Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Jônatas Davi Paganini jonatas

🏠
Working from home
Block or report user

Report or block jonatas

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View generate_crossed_words.rb
def crossed_words size = 20
words = %w[jonatas aline lorenzo lucas
joao juca pedro mariana
pedroca joana bartolomeu
maria louise ana carol luiza salete rafael leandro]
matrix = (0..size).map{|_|['.']*size}
n = 0
while words.any?
word = words.sort_by(&:size).last
orientation = ['vertical', 'horizontal'].sample
View codeowners_to_database.rb
#!/usr/bin/env ruby
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'pathspec', require: 'pathspec'
gem 'pry'
end
module CodeownersToDatabase
View learn_context_wording.rb
require '../../fast/lib/fast'
changed_files = `git diff --name-only $(git merge-base origin/master HEAD) --diff-filter=AMCR -- '*_spec.rb'`.lines.map(&:chomp)
changed_files.each do |file|
ast = begin
Fast.ast_from_file(file)
rescue
next
end
results = Fast.search(ast, '(block (send nil context (str _)))')
View experimental_build_stubbed_independent_replacement.rb
# frozen_string_literal: true
def experimental_spec(file, occurrence)
parts = file.split('/')
dir = parts[0..-2]
filename = "experiment_#{occurrence}_#{__FILE__.split('.').first}_#{parts[-1]}"
File.join(*dir, filename)
end
def experiment(file, expression, replacement, index = nil)
View api-rewrite.rb
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'ffast',
git: 'https://github.com/jonatas/fast.git',
require: 'fast'
end
View example_stub_without_params.rb
class Account
def withdraw(value)
if @total >= value
@total -= value
:ok
else
:not_allowed
end
end
end
View allow_research.rb
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'ffast',
git: 'https://github.com/jonatas/fast.git',
require: 'fast'
end
Fast.class_eval do
View json_query.rb
require 'json'
require 'pp'
Query = Struct.new(:attributes, :conditions)
Condition = Struct.new(:query, :operator, :arg)
class Parser
attr_reader :query
@jonatas
jonatas / maze.rb
Last active Mar 4, 2018
Simple maze solver
View maze.rb
game = <<~MAZE
++++++++++++++++++++++
+ + ++ ++ +
+ + + +++ + ++
+ + + ++ ++++ + ++
+++ ++++++ +++ + +
+ ++ ++ +
+++++ ++++++ +++++ +
+ + +++++++ + +
+ +++++++ S + +
View sql_parser_query.rb
Query = Struct.new(:attributes, :source, :conditions, :order_by)
class SQLParser
attr_reader :query
def initialize(string)
@tokens = string.scan(/\(|\)|:?\w+|[\+\-\/\*=]+|[<>]=?/)
@query = Query.new
end
def next_token
@tokens.shift
You can’t perform that action at this time.