Skip to content

Instantly share code, notes, and snippets.

View breim's full-sized avatar
:shipit:

Henrique Breim breim

:shipit:
  • Barcelona, Spain
View GitHub Profile
@eligrey
eligrey / object-watch.js
Created April 30, 2010 01:38
object.watch polyfill in ES5
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
@peternixey
peternixey / securing_rails_updates.md
Created March 5, 2012 13:10
How Homakov hacked GitHub and how to protect your application by Peter Nixey

##How Homakov hacked GitHub and the line of code that could have prevented it


Please note: THIS ARTICLE IS NOT WRITTEN BY THE GITHUB TEAM or in any way associated with them. It's simply hosted as a Gist because the markdown formatting is excellent and far clearer than anything I could manage on my personal Tumblr at peternixey.com.

If you'd like to follow me on twitter my handle is @peternixey


@mitfik
mitfik / gist:3169039
Created July 24, 2012 09:22
Helper for S3 direct upload file
def s3_form_tag(options = {})
bucket = options[:bucket]
access_key_id = options[:access_key_id]
secret_access_key = options[:secret_access_key]
key = options[:key] || ''
content_type = options[:content_type] || '' # Defaults to binary/octet-stream if blank
redirect = options[:redirect] || '/'
acl = options[:acl] || 'public-read'
expiration_date = options[:expiration_date].strftime('%Y-%m-%dT%H:%M:%S.000Z') if options[:expiration_date]
max_filesize = options[:max_filesize] || 671088640 # 5 gb
@alphazo
alphazo / gist:3303282
Created August 9, 2012 11:03
Clone MiFare cards using chinesse UUID writable cards

libnfc supports UUID writable cards and even has some dedicated tools for them.

However it doesn't work with some of the cards found on eBay that are even simpler to use. Sector 0 is unlocked and can be written without any additional commands. libnfc requires a small patch to get it working.

Following has been tested under ArchLinux with modified libnfc 1.5.1, mfoc 0.10.2 and a SCL3711 dongle.

Patch & recompile libnfc

The patch is fairly simple, open libnfc-1.5.1/utils/nfc-mfclassic.c and comment 2 lines (it was lines 384 and 385 for me):

// Try to write the trailer

@nfo
nfo / README.md
Created September 10, 2012 15:54
A microgem to query the Amazon Web Services (S3/EC2/etc) usage reports.
@okochang
okochang / introduction_ec2.rb
Created February 22, 2013 16:50
AWS SDK for Rubyを使ってEC2を起動して削除するまでの流れ
# -*- coding: utf-8 -*-
## EC2インスタスを起動するまでの流れで、スクリプトではないので注意して下さい
require 'aws-sdk'
ACCESS_KEY = 'set your access key id'
SECRET_KEY = 'set your secret key'
EC2_REGION = 'ec2.ap-southeast-1.amazonaws.com'
ec2 = AWS::EC2.new(
:access_key_id => ACCESS_KEY,
:secret_access_key => SECRET_KEY,
@ryane
ryane / ci_install.sh
Created April 17, 2013 19:38
A script (or just list of commands) to setup a jenkins server on Ubuntu 12.04 hosted at linode. Liberally borrowed from https://gist.github.com/whistler/3179919#file-jenkins_rails_ubuntu-sh
sudo aptitude -y install build-essential libssl-dev libreadline5 libreadline5-dev zlib1g zlib1g-dev
sudo apt-get -y install libxslt-dev libxml2-dev
sudo apt-get -y install libmysqlclient-dev ruby-dev
sudo apt-get -y install libcurl4-openssl-dev
sudo apt-get -y install imagemagick libmagickcore-dev libmagickwand-dev
sudo apt-get -y install libsqlite3-dev
sudo apt-get -y install libreadline-dev
sudo apt-get -y install git
sudo apt-get -y install libicu48
sudo apt-get -y install nodejs
@blaix
blaix / service-objects.md
Created June 12, 2013 11:04
Martin Fowler on Service Objects via the Ruby Rogues Parley mailing list

On Tue, Mar 12, 2013 at 1:26 PM, Martin Fowler martinfowlercom@gmail.com wrote:

The term pops up in some different places, so it's hard to know what it means without some context. In PoEAA I use the pattern Service Layer to represent a domain-oriented layer of behaviors that provide an API for the domain layer. This may or may not sit on top of a Domain Model. In DDD Eric Evans uses the term Service Object to refer to objects that represent processes (as opposed to Entities and Values). DDD Service Objects are often useful to factor out behavior that would otherwise bloat Entities, it's also a useful step to patterns like Strategy and Command.

It sounds like the DDD sense is the sense I'm encountering most often. I really need to read that book.

The conceptual problem I run into in a lot of codebases is that rather than representing a process, the "service objects" represent "a thing that does the process". Which sounds like a nitpicky difference, but it seems to have a real impact on how people us

@j3tm0t0
j3tm0t0 / gist:6496327
Last active April 16, 2017 00:23
ec2 run instance with public ip in vpc
[1] pry(main)> require 'aws-sdk'
=> true
[2] pry(main)> ec2 = AWS.ec2
=> <AWS::EC2>
[3] pry(main)> ec2.client.run_instances(:image_id => 'ami-39b23d38' , :network_interfaces => [{:device_index => 0 , :subnet_id => 'subnet-6fa0f706', :associate_public_ip_address => true }], :min_count => 1, :max_count => 1 );
[4] pry(main)> ec2.instances.create(:image_id => 'ami-39b23d38' , :network_interfaces => [{:device_index => 0 , :subnet_id => 'subnet-6fa0f706', :associate_public_ip_address => true }]);
@esbanarango
esbanarango / gist:6629748
Last active May 8, 2018 18:12
HTML <input> required attribute and Rails form with remote true.

<input> with attribute required

This attribute specifies that the user must fill in a value before submitting a form. It cannot be used when the type attribute is hidden, image, or a button type (submit, reset, or button). The :optional and :required CSS pseudo-classes will be applied to the field as appropriate.

How to show a spinner only when the required validations pass? (Without using any validation plugin, only the required attribute).

Form with a required input

= form_for @person, remote: true do |f|
 = f.text_field, :first_name, required: true