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
x-app: &default-app
build:
context: "."
target: "app"
args:
- "UID=${UID:-1000}"
- "GID=${GID:-1000}"
- "RAILS_ENV=${RAILS_ENV:-production}"
- "NODE_ENV=${NODE_ENV:-production}"
depends_on:
@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
# controller
class MyController < ApplicationController
TEMPLATE_ID = "TEMPLATE_ID"
def create
authorize ...
if send_email
redirect_to @referer, success: success_message
else
@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
<template>
<v-container fluid store grid-list-sm>
<!-- <h1 class="main-title-name uppercase">{{first_name}} {{last_name}}</h1>-->
<div class="logo">
<svg
class="Icon Icon--logo"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="195.722"
height="25"
export default {
data: () => ({
isShowing: false,
confirmButtonIsDisabled: false,
moment: moment,
date: [],
time: [],
dateTime: [],
dateValue: "",
harper_cart_id: "",