Skip to content

Instantly share code, notes, and snippets.

View thadeu's full-sized avatar
🏠
Working from home

thadeu thadeu

🏠
Working from home
View GitHub Profile
@thadeu
thadeu / @brain-store.js
Last active March 20, 2019 02:32
🧠Brain JS
export function brainstore() {
let store = {}
let listeners = []
let ownProp = Object.prototype.hasOwnProperty
let allowed = {
string: 1,
number: 1,
boolean: 1,
object: 1,
function: 0,
@thadeu
thadeu / sandbox.js
Last active March 19, 2019 15:43
JS: Sandbox Pattern
Sandbox.modules = {}
Sandbox.modules.vnode = function(s) {
s.vnode = {}
}
Sandbox.modules.createElement = function(s) {
s.createElement = function() {}
}
@thadeu
thadeu / import_csv.md
Last active February 7, 2019 13:59
Rake Import CSV with Ruby/Rails
# frozen_string_literal: true

namespace :import do
  desc 'import CSV'
  task csv: :environment do
    csv_file = File.join Rails.root, 'tmp/file.csv'
    counter = 0

 options = {
@thadeu
thadeu / config.rb
Created October 26, 2018 17:22 — forked from javierarques/config.rb
Middleman 4 and Webpack 3 integration. Use Middleman with External Pipeline.
# ...
activate :external_pipeline,
name: :webpack,
command: build? ? "npm run build:assets" : "npm run start:assets",
source: ".tmp/webpack_output",
latency: 1
# ...
@thadeu
thadeu / html2haml.md
Created October 2, 2018 19:59
Convert to files html.erb to haml
for file in app/views/**/*.html.erb; do html2haml -e $file ${file%erb}haml && rm $file; done
@thadeu
thadeu / rebasing.md
Created July 19, 2018 15:55
squash and join commits with git rebase

First Check the commits

git log --pretty=oneline --since=1.day

Second

Choose many commits would should be edits

git rebase -i HEAD~N_COMMITS

Third

@thadeu
thadeu / promise_delayed.md
Last active July 20, 2018 07:42
Promise Reject Delayed
export const getNotifications = async (title) => {
  let ASYNC_TIMEOUT = 10000 // 10s
  let didTimeout = false
  let notifications = []

  const workerDelayedPromise = () => {
    return new Promise(async (resolve, reject) => {

      // timeout in order to send reject if delayed
@thadeu
thadeu / docker-commands.md
Created May 9, 2018 18:50
Docker commands

Docker Commands

Apagando imagens soltas

docker rmi (docker images -f dangling=true -q)

Apagando containers que já morreram

docker rm -v (docker ps -a -q -f status=exited)

Delete all containers

docker rm (docker ps -a -q)

@thadeu
thadeu / sync.md
Last active April 13, 2018 12:10
GIT: Sync (rebase) branch master
git fetch origin master
git checkout master
git merge origin/master
git checkout MY_BRANCH
git rebase master
git push -f origin HEAD
@thadeu
thadeu / user_settings.json
Last active April 10, 2018 18:06
VSCode UserSettings
{
"ruby.rubocop.executePath": "/Users/thadeu/.rbenv/shims/",
"csscomb.formatOnSave": true,
"csscomb.preset": "zen",
"csscomb.preset": {
"sort-order": [
["$variable"],
["$include"]
],
"sort-order-fallback": "abc",