Skip to content

Instantly share code, notes, and snippets.

View gosukiwi's full-sized avatar

Federico Ramirez gosukiwi

View GitHub Profile
# frozen_string_literal: true
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
@gosukiwi
gosukiwi / demo.rb
Last active May 15, 2018 17:42
Helper Methods Module Pattern
# app/controllers/books_controller.rb
class BooksController < ApplicationController
include HelperMethods::BooksController
def index; end
def show; end
end
# app/controllers/helper_methods/books_controller.rb
module HelperMethods
@gosukiwi
gosukiwi / sed-cheatsheet.md
Last active September 3, 2018 17:38
sed cheatsheet

Sed Cheatsheet

Sed is a non-interactive line-based text editor. It can perform an edition in either file or STDIN and print it in STDOUT, which can later be redirected to a file it needed.

CLI options

-e  Editing instructions follows
-f  File name of script follows
-n  Supress automatic output of lines
-i  Extension - Edit files in-place, saving backups with the specified extension.  

If a zero-length extension is given, no backup will be saved.

@gosukiwi
gosukiwi / rspec_rails_cheetsheet.rb
Created January 17, 2018 18:53 — forked from mlr/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet with expect syntax (including capybara matchers)
# Model
expect(@user).to have(1).error_on(:username) # checks whether there is an error in username
expect(@user.errors[:username]).to include("can't be blank") # check for the error message
# Rendering
expect(response).to render_template(:index)
# Redirecting
object(stdClass)#857 (6) {
["all"]=>
object(JPaginationObject)#1035 (5) {
["text"]=>
string(8) "View All"
["base"]=>
string(1) "0"
["link"]=>
string(10) "/index.php"
["prefix"]=>
// ==UserScript==
// @name No me jodas Clarin
// @namespace gosukiwi.greasemonkey.nmjc
// @description Borra el overlay de mierda que pone Clarin para que te registres
// @include https://www.clarin.com/*
// @include https://clarin.com/*
// @version 0.0.1
// @grant none
// ==/UserScript==
$ flog -g start.rb
16.7: flog total
8.4: flog/method average
15.7: FileSync total
15.7: FileSync#sync start.rb:2-17
$ flog -g end.rb
24.1: flog total
4.0: flog/method average
;; Parsing 2 + 2
Start := Binop
:= Subtraction
:= Adition
:= Division "+" Binop
:= Multiplication "+" Binop
:= Number "+" Binop
:= 2 "+" Binop
:= 2 "+" Subtraction
:= 2 "+" Adition
class Markdown
# ...
def self.to_html(input)
@generator.generate(@parser.parse(@tokenizer.tokenize(input)))
end
# ...
end
class TestGenerator < Minitest::Test
def setup
@tokenizer = Tokenizer.new
@parser = Parser.new
@generator = Generator.new
end
def generate(markdown)
tokens = @tokenizer.tokenize(markdown)
ast = @parser.parse(tokens)