Skip to content

Instantly share code, notes, and snippets.

View cassio-maletich's full-sized avatar
🌎

Cássio Maletich cassio-maletich

🌎
View GitHub Profile
@cassio-maletich
cassio-maletich / README.md
Created November 9, 2022 18:21 — forked from leastbad/README.md
Choices.js Stimulus wrapper preview

Choices.js Stimulus wrapper

https://joshuajohnson.co.uk/Choices/

Soon, this will be published as an NPM package, but there's an absence of documentation right now. It supports almost all functions from the original library; soon it will support 100% of them.

This wrapper adds Ajax pre-fetch search. Happens if controller has a data-search-path attribute.

Stimulus controller targets use new v2 syntax. Controller attaches a reference to itself on the element so that you can access the internal state from external scripts.

@cassio-maletich
cassio-maletich / Capybara.md
Created October 7, 2022 18:41 — forked from tomas-stefano/Capybara.md
Capybara cheatsheet

Capybara Actions

# Anchor
click_link 'Save'

# Button
click_button 'awesome'

# Both above
@cassio-maletich
cassio-maletich / 00.md
Created September 25, 2022 20:55 — forked from maxivak/00.md
Selenium tests on Ruby

Selenium tests on Ruby

Install

gems:

  • gem 'capybara', '2.10.1'
  • gem 'selenium-webdriver', '3.0.3'

Selenium

@cassio-maletich
cassio-maletich / heroku-remote.md
Created September 5, 2022 18:41 — forked from randallreedjr/heroku-remote.md
Add a Heroku remote to an existing git repo

Working with git remotes on Heroku

Generally, you will add a git remote for your Heroku app during the Heroku app creation process, i.e. heroku create. However, if you are working on an existing app and want to add git remotes to enable manual deploys, the following commands may be useful.

Adding a new remote

Add a remote for your Staging app and deploy

Note that on Heroku, you must always use master as the destination branch on the remote. If you want to deploy a different branch, you can use the syntax local_branch:destination_branch seen below (in this example, we push the local staging branch to the master branch on heroku.

$ git remote add staging https://git.heroku.com/staging-app.git
@cassio-maletich
cassio-maletich / tmp.rb
Created June 17, 2022 16:12 — forked from rpearce/tmp.rb
Rails – open a file, read it and write it to a temp file
module Tmp
def self.build(src:, name:, ext:, binmode: false)
file = Tempfile.new([name, ext], Rails.root.join('tmp'))
file.binmode if binmode
open(src) { |f| file.write(f.read) }
file.rewind
file.close
file
end
end
@cassio-maletich
cassio-maletich / base64_to_file.rb
Created June 17, 2022 13:14 — forked from simonqian/base64_to_file.rb
base64 to file in rails
module Base64ToFile
extend ActiveSupport::Concern
def base64_to_file(base64_data, filename=nil)
return base64_data unless base64_data.is_a? String
start_regex = /data:image\/[a-z]{3,4};base64,/
filename ||= SecureRandom.hex
regex_result = start_regex.match(base64_data)
@cassio-maletich
cassio-maletich / modal_controller.js
Created November 28, 2021 02:50 — forked from ordinz/modal_controller.js
Extend Modal from "tailwindcss-stimulus-components"
import {Modal} from "tailwindcss-stimulus-components"
export default class extends Modal {
connect(){
this.element[this.identifier] = this
this.toggleClass = 'hidden'
}
}
@cassio-maletich
cassio-maletich / .bash_aliases
Last active October 16, 2025 17:53
.bash_aliases
# To load this file add the following to .bashrc
# if [ -f ~/.bash_aliases ]; then
# . ~/.bash_aliases
# fi
# autojump loader
. /usr/share/autojump/autojump.sh
# some more basic aliases
alias egrep='egrep --color=auto'