Skip to content

Instantly share code, notes, and snippets.

View theo-bittencourt's full-sized avatar

Theo B theo-bittencourt

  • IBJJF
  • Rio de Janeiro, Brazil
View GitHub Profile
@theo-bittencourt
theo-bittencourt / gist:7467150
Last active December 28, 2015 07:49
.Guarfile
begin
require 'guard/zeus'
guard :zeus do
watch(%r{^config/initializers/.+\.rb$})
watch(%r{^config/environments/.+\.rb$})
watch(%r{^Gemfile.lock$})
end
rescue LoadError
nil
end
@theo-bittencourt
theo-bittencourt / ruby_command_line_constructor_snippet.rb
Last active November 19, 2016 05:40
Snippet to build Ruby command line executables
#!/usr/bin/env ruby
# Snippet to build command line executables like this:
# ./my_script command --opt-a "opt A"
require 'optparse'
require 'singleton'
require 'pry'
class Command
# We can't use dynamic segment for the festivals because ActiveAdmin can't
# include it to default_url_options. So all named routes in admin will break.
Festival::KEYS.each do |festival_key|
scope festival_key do
scope ':locale', defaults: {locale: I18n.locale} do
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
end
end
end
@theo-bittencourt
theo-bittencourt / artists_weight.sass
Last active May 10, 2017 15:17
artists_weight.sass
= attraction-weight($font-size)
&[data-weight="100"]
.name
span
font-size: $font-size * 1
opacity: 1
small
&.size-65
font-size: $font-size * .65

MySQL Snippets

Initial setup

$ mysql_secure_installation

O prompt do mysql deve ser iniciado com -u root para alguns comandos

/**
* This middleware redirects routes without locale to a prefixed ones.
* Useful for links included on email templates.
*/
export default function(context) {
const { route, redirect, app } = context
const { path, query } = route
const previousLocaleCode = app.i18n.getLocaleCookie()
const localeCodes = app.i18n.locales.map(l => l.code)
/**
* from:
* "Decoupling Logic with Domain Events [Guide] - Domain-Driven Design w/ TypeScript"
* https://khalilstemmler.com/articles/typescript-domain-driven-design/chain-business-logic-domain-events/
*/
import { UseCase } from '../../../../core/domain/UseCase';
import { CreateUserDTO } from './CreateUserDTO';
import { Either, Result, left, right } from '../../../../core/logic/Result';
import { UserEmail } from '../../domain/userEmail';
@theo-bittencourt
theo-bittencourt / Active Admin Super Example of Resource Customization.rb
Created September 12, 2012 04:10
Active Admin: Super Example of Resource Customization
ActiveAdmin.register Event do
#Menu display index
menu :priority => 1
#Scopes
scope :all
scope :pending
scope :approved
scope :rejected
scope :cancelled