Skip to content

Instantly share code, notes, and snippets.

@WagnerMatos
WagnerMatos / stimulus.md
Created October 16, 2022 09:17 — forked from mrmartineau/stimulus.md
Stimulus cheatsheet
@WagnerMatos
WagnerMatos / iterm2.md
Created August 31, 2022 11:06 — forked from squarism/iterm2.md
An iTerm2 Cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
@WagnerMatos
WagnerMatos / MergeSort.markdown
Created August 12, 2022 07:36 — forked from bih/MergeSort.markdown
MergeSort Example in Ruby

MergeSort Algorithm in Ruby

When learning about sorting algorithms, I wanted to implement them to help me understand them better. This algorithm was originally invented by John von Neumann in 1948.

The Ruby script attached explains in real code what is going on. Play about with it.

How does the algorithm work?

Step by step:

  • Pass through an array of unsorted numbers (i.e. [4, 3, 2, 10])
@WagnerMatos
WagnerMatos / benchmark.rb
Created August 12, 2022 07:24 — forked from naveed-ahmad/benchmark.rb
Array duplicates test
require 'benchmark/ips'
def find_one_using_group_by_select(array)
array.group_by{ |e| e }.detect { |k, v| k if v.size > 1 }&.first
end
def find_one_using_chunk_select(array)
array.sort.chunk{ |e| e }.detect { |e, chunk| chunk.size > 1 }&.first
end
@WagnerMatos
WagnerMatos / .editorconfig
Created January 29, 2020 07:49 — forked from thinkinglemur/.editorconfig
.editorconfig file example for js
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
tab_width = 2
end_of_line = lf
charset = utf-8
max_line_length = 80
@WagnerMatos
WagnerMatos / .rubocop.yml
Created May 9, 2019 14:10 — forked from jhass/.rubocop.yml
My preferred Rubocop config
AllCops:
RunRailsCops: true
# Commonly used screens these days easily fit more than 80 characters.
Metrics/LineLength:
Max: 120
# Too short methods lead to extraction of single-use methods, which can make
# the code easier to read (by naming things), but can also clutter the class
Metrics/MethodLength:
@WagnerMatos
WagnerMatos / something.py
Created October 4, 2018 05:49 — forked from kirang89/something.py
Creating a mutable ARRAY data type in sqlalchemy
class Something(Base):
__tablename__ = 'yaddayadda'
id = Column(Integer, primary_key=True)
data = Column(MutableList.as_mutable(ARRAY(String(100))))
@WagnerMatos
WagnerMatos / generate_twitter_bearer_token.rb
Created November 23, 2017 13:15 — forked from jkotchoff/generate_twitter_bearer_token.rb
Example of how to generate and use a Twitter bearer token for the purpose of performing application-only authentication for the Twitter API
# Generate and use an oauth2 bearer token for the Twitter API in Ruby
#
# For Application-Only authentication to the twitter API, a 'bearer token'
# is required to authenticate agains their endpoints for rate limiting
# purposes.
#
# This script generates a bearer token by posting to twitter and then it
# uses that token to poll their API.
#
# Note, the base 64 encoded consumer credentials for the bearer token needs
@WagnerMatos
WagnerMatos / Procfile
Created September 18, 2017 14:45 — forked from pboling/Procfile
sidekiq initializer
web: bundle exec rails server puma -p $PORT -e $RACK_ENV
critical: env HEROKU_PROCESS=critical bundle exec sidekiq -c 2 -q critical,4
default: env HEROKU_PROCESS=default bundle exec sidekiq -c 4 -q default,2
low: env HEROKU_PROCESS=low bundle exec sidekiq -c 1 -q low,1