Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View rpbaltazar's full-sized avatar
🧶
Knitting the next thing

Rui Baltazar rpbaltazar

🧶
Knitting the next thing
View GitHub Profile
Muitos parabéns aos papás e que sejam todos muito felizes!
Um abraço para os rapazes e um beijinho à Jee, a quem coube a grande tarefa!
@rpbaltazar
rpbaltazar / input
Created February 18, 2017 03:33
puzzle input
^><^>>>^<^v<v^^vv^><<^<><<vv^<>^<^v>^vv<>v><vv^^<>>^^^v<<vv><<^>^<^v<^>^v><<<v^<v<<<v<<vv<v<^><^>><>v>v^<<v^^<^v<><^>^<<^^^>v>>v^^<v>>^>vv><v>>^>>v^>^v>^<^^v>^>^^v<v>^^<v<>>v^^v><^><^<<>v^<^<^v<v>v^>>>v^v^>^<>^v<^^vv<v>^>^<>^^<vv^<><<v<^<^^>vv<>^>v<^>^v>v^>^v<>^><>><vv<>v^v<><>v^v>>>>v^^>^><^^<v<^><^<v>>^v^v<>v<<<^<<vvvv<<v^vv^>v^^^<^^^<v>>v<^v>>>>>v<^^^^>v<^<><v>>>>><v>>v^vvvv^^<v^<>^v<^v^>v><^>^v<<>>vv^>v>v^^>vv^<^vvv<>><>><><^^^<v<>^<^^^<v><^v>>v>^v<v^vv^<>^^^>v^^^v>>^v^^<^>>^>^<<v>>>^^<>>^vv>v^<^>>>><v<><><^^v<><<<<^^<>>^<vvv^><>v<v<<<<><v<<v>v<v^><vv<v^>^<^>v^^><^v>^^>v<>^v^<>^vv^><v^^vv>vvv>v>^<vv^>>^>>^>><>>>^^^^v<vv>^<>v^^><v^>^<>v<^^v><v<<><^v><>^^^^^v^v>>^^v><<><<vv>^^^^><^>v>><<<^v>v^^>^v^<^^v>v<^<<>>^v<<<v<<>>v<^v^><vv<v^v>v^<v>><v>^v<<<vv^>v<v>>v>>v><v><v^>v^^v>^v^>>>><>^>v>^v^>>>>v^<<vv<^v><<>v<v^<^^<<v<^v^^v^>vv><vv<v^<^>><^^>^<><^^<v<><^v^v^<^^>^<v><^<v>v^<<<^^v<v>^v>>><>^^>vv<<^v^<<<<^^>>>v>v<<<>^^>>>v>^>v>vv<<>^<^><v^>^^<^<v<<v<^>>^v^<vvv><>v^><<v>^^<v^vv^^^<vvv^<^>^>vv>><^v<^<<v<><<><<^^<><
@rpbaltazar
rpbaltazar / pre-commit-hook
Last active June 29, 2017 04:48
Running rubocop and coffeelint before commiting
#!/usr/bin/env ruby
require 'rubocop'
ADDED_OR_MODIFIED = /A|AM|^M/.freeze
EXCLUDE_FILES = ["db/schema.rb"]
def get_filename(file_with_status)
file_with_status.split(" ")[1]
end
@rpbaltazar
rpbaltazar / controller_with_endpoint.rb
Created November 20, 2017 04:44
TRB endpoint integration
class Api::V1::MyController < Api::V1::BaseController
def push_all
op_res = V1::MyOperation::PushAll.(params, current_user: current_user)
success_proc = ->(result, _representer) do
{ "data": result["response"], "status": :ok }
end
endpoint_res = OPL::Endpoint.(op_res, nil, success: { resolve: success_proc })
render json: endpoint_res[:data], status: endpoint_res[:status]
end
@rpbaltazar
rpbaltazar / aliases.zsh
Last active August 28, 2018 05:54
Git aliases for zsh
# Customize to your needs...
alias gitspec='rspec $(git st | grep "...spec/.*_spec.rb" | cut -c 4- | xargs)'
alias gap='git add -p'
alias gan='git add -N .'
alias ganp='git add -N . && git add -p'
alias gpb='`git push 2>&1 > /dev/null | grep "git push"`'
alias gplush='git pull; git push'
alias grbrm='git-branch-remote-delete' # from functions.zsh
alias gbrrm='git-branch-remote-delete' # from functions.zsh
@rpbaltazar
rpbaltazar / alternative_endpoint.rb
Last active February 24, 2018 07:43
Endpoint proposal
require 'dry-matcher'
module FirstTouch
# This class assumes that the project is api only and its rendering
# JSON. For other options (e.g render a view) this needs to be thought
class Endpoint
Matcher = Dry::Matcher.new(
success: Dry::Matcher::Case.new(
match: ->(result:, **) { result.success? },
resolve: ->(result:, representer:, **) do
@rpbaltazar
rpbaltazar / world_capitals.csv
Last active May 8, 2018 01:45
World capitals
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
Abu Dhabi
Abuja
Accra
Adamstown
Addis Ababa
Algiers
Alofi
Amman
Amsterdam
Andorra la Vella
@rpbaltazar
rpbaltazar / autoresize.coffee
Created April 6, 2018 02:10
Text box auto resize
ko.bindingHandlers.autoResize =
init: (element, _valueAccessor, allBindings) ->
$(element).addClass("resizable")
observable = allBindings().textInput
updateHeight = (element) ->
$(element).css("height", "1px")
totalHeight = element.scrollHeight
$(element).css("height", "#{totalHeight}px")
"Conns"=>{:name=>"Conns", :part_of_name=>true, :options=>["5-1/2\" (VX54)", "4\" IF (NC46)", "4-1/2\" IF (NC50)", "3-1/2\" IF (NC38)", "5-1/2\" VX54"], :type=>"Single Choice"},
"Clamp"=>{:name=>"Clamp", :part_of_name=>true, :options=>["Manual", "Hydraulic"], :type=>"Single Choice"},
"Conn 1"=>{:name=>"Conn 1", :part_of_name=>true, :options=>["21-1/4\" API 2K", "7-1/16\" API 5K", "10\" ANSI 600 RTJ", "1/4\" NPT Male", "1/2\" NPT male", "13-5/8\" API 5K", "8-5/8\" Reg Box", "4-1/16\" API 5K", "2-1/16\" API 5K", "13-5/8\" API 3K", "2\" ANSI 2500 RTJ", "20-3/4\" API 3K", "13-5/8\" API 10K", "33\" API ?", "3\" NPT Female", "1\" NPT Male", "2\" NPT Male", "2\" Fig 400 Thread", "3\" Fig 400 Thread", "3\" Fig 1502 Thread", "3-1/16\" API 10K", "11\" API 5K", "1/8\" NPT Male"], :type=>"Single Choice"},
"Length"=>{:name=>"Length", :part_of_name=>true, :options=>["m", "ft", "inch"], :type=>"Number"},
"Capacity"=>{:name=>"Capacity", :part_of_name=>true, :options=>["kg", "lbs"], :type=>"Number"},
"Sling Legs"=>{:name=>"Sli