Skip to content

Instantly share code, notes, and snippets.

Avatar
🧶
Knitting the next thing

Rui rpbaltazar

🧶
Knitting the next thing
View GitHub Profile
View autoresize.coffee
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")
View world_capitals.csv
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
View alternative_endpoint.rb
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 / aliases.zsh
Last active Aug 28, 2018
Git aliases for zsh
View aliases.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
View controller_with_endpoint.rb
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
View setup-tasks.md
@rpbaltazar
rpbaltazar / pre-commit-hook
Last active Jun 29, 2017
Running rubocop and coffeelint before commiting
View pre-commit-hook
#!/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
View 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<><<><<^^<><
View gist:c8b961757e1b7e2b1ee4e67490918619
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 / config.json
Created Sep 14, 2016 — forked from anonymous/config.json
Orifice Calculator Config
View config.json
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",
You can’t perform that action at this time.