Skip to content

Instantly share code, notes, and snippets.

Avatar

Federico Ramirez gosukiwi

View GitHub Profile
View rails_issue_32953.rb
# 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
Helper Methods Module Pattern
View demo.rb
# 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
View sed-cheatsheet.md

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 Jan 17, 2018 — forked from mlr/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet with expect syntax (including capybara matchers)
View rspec_rails_cheetsheet.rb
# 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
View gist:ace3078f20f4a2ee3662f552aa1e8d48
object(stdClass)#857 (6) {
["all"]=>
object(JPaginationObject)#1035 (5) {
["text"]=>
string(8) "View All"
["base"]=>
string(1) "0"
["link"]=>
string(10) "/index.php"
["prefix"]=>
View clarin.user.js
// ==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==
View flog
$ 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
View gist:519b55b4048303d4da9e5408b9942b08
;; Parsing 2 + 2
Start := Binop
:= Subtraction
:= Adition
:= Division "+" Binop
:= Multiplication "+" Binop
:= Number "+" Binop
:= 2 "+" Binop
:= 2 "+" Subtraction
:= 2 "+" Adition
View demo.rb
class Markdown
# ...
def self.to_html(input)
@generator.generate(@parser.parse(@tokenizer.tokenize(input)))
end
# ...
end
View demo.rb
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)