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 / rails5-graphql-starter.md
Last active June 18, 2019 01:04
Rails 5 init starter
$ rails new APP_NAME -d postgresql --skip-action-mailbox --skip-action-text --skip-spring --webpack=react -T --skip-turbolinks
# config/application.rb

config.generators do |g|
  g.test_framework  false
 g.stylesheets false
@thadeu
thadeu / polyfill-datetime_local.js
Created April 25, 2019 15:54
Polyfill DateTimeLocal HTML5
if (!Date.prototype.toDatetimeLocal) {
(function () {
Date.prototype.toDatetimeLocal = function () {
var date = this
var ten = function (i) {
return (i < 10 ? '0' : '') + i;
}
if (date == 'Invalid Date') return false
@thadeu
thadeu / erb-to-haml.md
Created April 10, 2019 23:27
Convert all files ERB to HAML within specific folder
for file in app/views/**/*.erb; do html2haml -e $file ${file%erb}haml && rm $file; done
export function deepOmit(obj, excludes) {
const result = {}
excludes = Array.isArray(excludes) ? excludes : [excludes]
for (let i in obj) {
if (Array.isArray(obj[i])) {
const nextValue = obj[i].map(arrItem => {
if (isObject(arrItem)) {
return deepOmit(arrItem, excludes)
}
@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