Skip to content

Instantly share code, notes, and snippets.

View microwaves's full-sized avatar

Stephano Zanzin Ferreira microwaves

View GitHub Profile
@gleicon
gleicon / cyclone-dropbox-oauth2.py
Last active August 29, 2015 14:06 — forked from andreadipersio/tornado-dropbox-oauth2.py
forked from tornado-dropbox-oauth2
import cyclone.web
import cyclone.auth
from cyclone import escape, httpclient
from cyclone.options import parse_command_line, define, options
from twisted.python import log
from twisted.internet import task, defer, reactor
import sys
try:
import urllib.parse as urllib_parse # py3
@abayer
abayer / jenkins-git-backup.sh
Last active June 7, 2025 03:08
Example of a script for backing up Jenkins config in git.
#!/bin/bash
#
# Copies certain kinds of known files and directories from a given Jenkins master directory
# into a git repo, removing any old ones, adds 'em, commits 'em, pushes 'em.
#
set -ex
if [ $# -ne 2 ]; then
echo usage: $0 root_dir jenkins_master
$VERBOSE = nil
require File.expand_path('../rooby', __FILE__)
Person = Rooby::Class.new 'Person' do
define :initialize do |name|
@name = name
end
define :name do
@tomas-stefano
tomas-stefano / Gemfile
Created November 1, 2012 01:49
Goliath and Routing
source :rubygems
gem 'goliath', '1.0.0'
gem 'rack', '1.4.1'
@psychocandy
psychocandy / URI-monkey-patch.rb
Created July 17, 2012 16:11
Fix ArgumentError invalid %-encoding for malformed URLs
# The following should prevent an ArgumentError "invalid %-encoding (...%)" exception from being raised for malformed URLs.
# To use this code simply drop this in your rails app initializers.
# See: https://github.com/rack/rack/issues/337
# Taken from: http://stackoverflow.com/a/11162317/1075006
module URI
major, minor, patch = RUBY_VERSION.split('.').map { |v| v.to_i }
@garybernhardt
garybernhardt / selectable_queue.rb
Last active November 23, 2022 12:42
A queue that you can pass to IO.select.
# A queue that you can pass to IO.select.
#
# NOT THREAD SAFE: Only one thread should write; only one thread should read.
#
# Purpose:
# Allow easy integration of data-producing threads into event loops. The
# queue will be readable from select's perspective as long as there are
# objects in the queue.
#
# Implementation:
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active November 15, 2025 02:35
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@tomas-stefano
tomas-stefano / model_spec_helper.rb
Created March 20, 2012 14:12
unit_spec_helper.rb
rails_root = File.expand_path('../../', __FILE__)
$LOAD_PATH.unshift(rails_root) unless $LOAD_PATH.include?(rails_root)
require 'bundler/setup'
require 'active_record'
require 'rspec/rails/extensions/active_record/base'
require 'spec/support/require_helper'
require 'spec/support/helpers'
require 'ostruct'
Bundler.require :models
@gleicon
gleicon / tinymq.rb
Created March 19, 2012 23:12
tiny mq
require 'rubygems'
require "bundler/setup"
require 'eventmachine'
require 'sinatra'
require 'redis'
require 'json'
QUEUESET = 'QUEUESET' # queue index
UUID_SUFFIX = ':UUID' # queue unique id
QUEUE_SUFFIX = ':queue' # suffix to identify each queue's LIST

Proposal for Improving Mass Assignment

For a while, I have felt that the following is the correct way to improve the mass assignment problem without increasing the burden on new users. Now that the problem with the Rails default has been brought up again, it's a good time to revisit it.

Sign Allowed Fields

When creating a form with form_for, include a signed token including all of the fields that were created at form creation time. Only these fields are allowed.

To allow new known fields to be added via JS, we could add: