Skip to content

Instantly share code, notes, and snippets.

@jordanandree
jordanandree / phantomjs_selectable_text.md
Created March 4, 2015 15:31
PhantomJS 1.9.8 - Selectable Text

There is a bug in PhantomJS on Mac OS X that doesn't render an HTML page as selectable text. It will be fixed in PhantomJS 2.0, so for now you'll have to apply a patch when installing with Homebrew.

First, update homebrew formulae:

$ brew update

If you already have PhantomJS installed, then remove it:

$ brew uninstall phantomjs Next, the PhantomJS formula needs to be edited to apply a patch that fixes native text rendering in Mac OS X:

@andkerosine
andkerosine / raskell.rb
Created August 15, 2012 05:56
Haskell-like list comprehensions in Ruby
$stack, $draws = [], {}
def method_missing *args
return if args[0][/^to_/]
$stack << args.map { |a| a or $stack.pop }
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :<
end
class Array
def +@
@enriclluelles
enriclluelles / gist:2229404
Created March 28, 2012 18:53
Amiando hammering script
//This needs to be run when you're on the amiando euruko page, because of the same origin policy on iframes
setTimeout(function rl(){
function aux() {
document.body.innerHTML= '';
document.write("<iframe id='i' src='http://www.amiando.com/euruko2012.html' style='width: 100%;height: 100%'></iframe>");
setTimeout(rl, 1000);
}
console.log('reloading');
var iframe = document.getElementById("i");
if (!iframe) {

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: