Skip to content

Instantly share code, notes, and snippets.

View hugobarauna's full-sized avatar

Hugo Baraúna hugobarauna

View GitHub Profile
@rodrigues
rodrigues / euro-exchange.livemd
Last active August 10, 2023 13:45
💶 Euro Exchange Rates History 📈

💶 Euro Exchange Rates History

Run in Livebook

Mix.install([
  {:briefly, "~> 0.4.1"},
  {:req, "~> 0.3.10"},
@Sanabria
Sanabria / toggle-applescript-dnd. scpt
Last active September 14, 2021 00:00
Applescript: Toggle Do Not Disturb mode
(* Note 1: The 1 after menu bar may need to be changed to 2 when using multiple monitors *)
(* Note 2: For 10.11 and newer “NotificationCenter” is now spelled “Notification Center”*)
tell application "System Events"
tell application process "SystemUIServer"
try
if exists menu bar item "Notification Center, Do Not Disturb enabled" of menu bar 1 of application process "SystemUIServer" of application "System Events" then
(* It is disabled *)
display dialog "Notifications will be turned on" buttons {"Got it"} default button 1
key down option

Rondy Sousa (@plataforma.rondy): @brunno.santos, puxando o gancho no papo das descrições de MR, uma coisa que a gente costuma fazer é manter a descrição do MR no commit principal (title+descripton do MR batendo com o do commit).

A vantagem é que a motivação/propósito do MR ("pois o bundle da product já tem esse link salvo no banco") fica documentada no histórico do controle de versão (e agnóstico da plataforma de code review).

Brunno dos Santos (@brunno.santos): @plataforma.rondy interessante esse esquema que vcs usam de colocar a descrição no commit, mas o problema é definir qual é o commit principal, as vezes nem temos um. Como vocês lidam com isso?

Rondy Sousa (@plataforma.rondy): @brunno.santos, A gente faz squash dos commits antes de fazer merge no master, com o commit resultante recebendo o título + descrição do MR.

Na grande maioria das vezes, commits separados representam (ou deveriam representar) apenas "snapshots" de work-in-progress do MR. No momento do merge, eles acabam não acre

@pixeltrix
pixeltrix / comparison.rb
Last active December 31, 2015 17:39
Comparison of functional tests vs. integration tests using current implementation and a simple implementation using Rack::Test
require 'benchmark/ips'
require "action_controller/railtie"
class BlogApplication < Rails::Application
config.eager_load = false
config.root = File.dirname(__FILE__)
config.session_store :cookie_store, key: 'session'
config.secret_key_base = 'secret'
end

Devise / Warden Tagged logging

I wrote a middleware (actually two, but they do the same with different implementations) that logs information about signed in scopes in a Rails + Devise application. The solution works with multiple logins (like having a person logged both as an Admin and a User). I tested against Rails 4 and Devise HEAD, but it should work fine in any Rails 3 application.

This solution doesn't use the log_tags configuration option since it isn't very helpful when you need to retrieve information stored in cookies/session. That information isn't 'ready' when the Rails::Rack::Logger is executed, since it happens way down in the middleware chain.

Add one of the following implementations to your application load path and use the following configuration to add the middleware to your application stack:

# application.rb
@SlexAxton
SlexAxton / .zshrc
Last active April 25, 2023 03:57
My gif workflow
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
@brianstorti
brianstorti / gist:3839690
Created October 5, 2012 12:58
Practical Object Oriented Design in Ruby

#Practical Object Oriented Design in Ruby

Design that anticipate specific future requirements almost always end badly.
Practical design does not anticipate what will happen to your application, it merely accepts that something
will and that, in the present, you cannot know what. It does not guess the future; it preserves your options for accommodating the future.
It doesn't choose; it leaves you room to move.
The purpose of design it to allow you to do it later and its primary goal is to reduce the cost of change.

Design is more the art of preserving changeability than it is the act of achieving perfection.

@rtomayko
rtomayko / gist:2601550
Created May 5, 2012 10:58
Open beautiful git-scm.com manual pages w/ git help -w
# The new git-scm.com site includes man pages designed for pleasant viewing in a web browser:
#
# http://git-scm.com/docs
#
# The commands below can be used to configure git to open these pages when
# using `git help -w <command>' from the command line. Just enter the config
# commands in your shell to modify your ~/.gitconfig file.
# Create a new browser command and configure help -w to use it.
git config --global browser.gitscm.cmd "/bin/sh -c 'open http://git-scm.com/docs/\$(basename \$1 .html)' --"
@sj26
sj26 / 0-readme.md
Created May 5, 2012 05:39 — forked from burke/0-readme.md
ruby-1.9.3-p194 cumulative performance patch.

Patched ruby 1.9.3-p194 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p194 with patches for boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84). It also includes the new backported GC from ruby-trunk.

Huge thanks to funny-falcon for the performance patches.