Skip to content

Instantly share code, notes, and snippets.

View marcusvmsa's full-sized avatar
🎯
Focusing

Marcus Sá marcusvmsa

🎯
Focusing
  • Vakinha
  • Porto Alegre - Brazil
View GitHub Profile
@marcusvmsa
marcusvmsa / attr_acessible_security.rb
Created March 6, 2012 01:09 — forked from rafaelp/attr_acessible_security.rb
How to protect against mass assignment attack
# Put this file on config/initializer
# This will create an empty whitelist of attributes available for mass assignment for
# all models in your app. As such, your models will need to explicitly whitelist
# accessible parameters by using an attr_accessible declaration. This technique is best
# applied at the start of a new project. However, for an existing project with a thorough
# set of functional tests, it should be straightforward and relatively quick to insert this
# initializer, run your tests, and expose each attribute (via attr_accessible) as dictated
# by your failing tests.

Fixing Heroku's random queuing router

So Heroku routes their requests to your dynos randomly. While you're enhancing your middleware to log that dyno-level queue time, I have an optimization for you that should help fix the issue outright!

Rails 3 apps, or 2.3 with Bundler, and Ruby 1.9

Gemfile

gem 'rack-timeout'
@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
@dx7
dx7 / gist:5119553
Last active December 14, 2015 16:59
Busca e troca sua senha e token em todo o histórico do repositório git. Útil quando vc faz commit com dados sensíveis e precisa abrir o repositório.
git filter-branch -f --tree-filter "find . -type f -exec sed -e s/your-plain-password/some-string/ -e s/\'your-plain-token\'/ENV[\'ENVIRONMENT_VARIABLE_TOKEN\']/ -i '' {} \;"
@Rich-Harris
Rich-Harris / service-workers.md
Last active November 5, 2024 06:39
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.