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
on run {input, parameters}
set paths to ""
repeat with i from 1 to length of input
set cur to item i of input
set paths to paths & " " & quote & POSIX path of cur & quote
end repeat
set cmd to "vim -p" & paths
tell application "iTerm"
set created to false
if not (exists current window) then
@thadeu
thadeu / named_route.rb
Created October 16, 2019 14:48
Named Route Rails 5+
# Return a named route to current url requested
def route_name
Rails.application.routes.router.recognize(request) do |route, _|
return route.name.to_sym
end
end
@thadeu
thadeu / README.md
Created September 25, 2019 21:50
Active Storage Remove Attachments

ActiveStorageRemove

Do you need remove files in the active_storage rails?

Use this files :)

@thadeu
thadeu / readme.md
Created August 15, 2019 15:59
Elastic Beanstalk Rails

Iniciar um configuracao EB

eb init --profile thadeu

Criar um Environment pra aplicação

eb create fielservicos-production --profile thadeu

Criar um SECRET_KEY_BASE

eb setenv SECRET_KEY_BASE=(rails secret)

Criar um RDS para aplicação e colocar as variaveis no database.yml

@thadeu
thadeu / promise-race.md
Last active June 28, 2019 18:04
Timeout Promise with race promises
const race = (milliseconds, ...promises) => {
  const timeout = new Promise((resolve, reject) => {
    setTimeout(() => reject(`Limit operation excedded (limit: ${milliseconds} ms)`), milliseconds)
  })

  return Promise.race([timeout, ...promises])
}
@thadeu
thadeu / pick.md
Last active June 26, 2019 15:51
Nested Pick Object

Patch

export function pick(o, ...keys) {
  return keys.reduce((acc, k) => (Boolean(acc[k]) ? acc[k] : ''), o)
}

Example Use

@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)
}