Skip to content

Instantly share code, notes, and snippets.

@rentalcustard
rentalcustard / gist:5524668
Last active January 13, 2022 14:21
Removing all literals from Ruby

Literals are ugly. Let's remove them.

True/false:

2.0.0p0 :001 > !Date
=> false
2.0.0p0 :002 > require Date.to_s.downcase
=> true

Integers and floats:

@vishaltelangre
vishaltelangre / rails_3_insecure_defaults.md
Last active December 15, 2015 15:49
Rails 3 Insecure Defaults (Notes)

Rails 3 Insecure Defaults

By default Rails does not provide CSRF protection for any HTTP GET request
match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
  • Best Practice:
  • Either specify HTTP verbs or use via: :all when adding routes with #match
@desandro
desandro / require-js-discussion.md
Created January 31, 2013 20:26
Can you help me understand the benefit of require.js?

I'm having trouble understanding the benefit of require.js. Can you help me out? I imagine other developers have a similar interest.

From Require.js - Why AMD:

The AMD format comes from wanting a module format that was better than today's "write a bunch of script tags with implicit dependencies that you have to manually order"

I don't quite understand why this methodology is so bad. The difficult part is that you have to manually order dependencies. But the benefit is that you don't have an additional layer of abstraction.


@havvg
havvg / ajax-form.js
Created August 1, 2012 13:20
jQuery AJAX form submit with Twitter Bootstrap modal
jQuery(function($) {
$('form[data-async]').live('submit', function(event) {
var $form = $(this);
var $target = $($form.attr('data-target'));
$.ajax({
type: $form.attr('method'),
url: $form.attr('action'),
data: $form.serialize(),