Skip to content

Instantly share code, notes, and snippets.

View haggen's full-sized avatar

Arthur Corenzan haggen

View GitHub Profile
@haggen
haggen / bug.rb
Created February 8, 2014 21:33
Rails' ActiveModel#create returns truthy value even when the model is invalid
gem 'activerecord', '4.1.0.beta1'
require 'active_record'
require 'minitest/autorun'
require 'logger'
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
@haggen
haggen / dabblet.css
Created March 31, 2014 13:02
Untitled
div {
/* Change it to 5%, then 10%, then 50% */
width: 11%;
display: table-cell;
background-color: pink;
}
@haggen
haggen / dabblet.css
Created March 31, 2014 18:54
Untitled
body {
font: 16px/1.4 sans-serif;
}
div {
width: 6em;
height: 12em;
background: pink;
font-size: 0;
letter-spacing: -1px;
@haggen
haggen / dabblet.css
Created April 15, 2014 17:54
Untitled
body {
font: 20px/1.4 Helvetica Neue, sans-serif;
}
p {
width: 24em;
padding: 1em 2em;
}
a {
@haggen
haggen / dabblet.css
Created April 15, 2014 17:54
Untitled
body {
font: 20px/1.4 Helvetica Neue, sans-serif;
}
p {
width: 24em;
padding: 1em 2em;
}
a {
(function($, undefined) {
'use strict';
function Repeating(container) {
this.container = $(container);
this.template = this.items().first().clone();
this.template.find('input, select, textarea').val('');
}
@haggen
haggen / autoareasize.js
Last active August 29, 2015 14:03
Auto size (height) for <textarea>
;(function() {
var sham = $('<pre></pre>');
sham.appendTo('body');
$(document).on('input change focus', 'textarea', function() {
var textarea = $(this);
sham.css('width', textarea.outerWidth());
@haggen
haggen / palette.scss
Created August 2, 2014 03:17
Palette from Apple Keynote
// Shades from brightest to darkest
// Aqua
rgb(80, 167, 249)
rgb(4, 101, 192)
rgb(21, 79, 134)
rgb(4, 36, 82)
// Fern
@haggen
haggen / aliased_relation_bug.rb
Created August 10, 2014 18:30
ActiveRecord relation with an aliased model doesn't work
# Activate the gem you are reporting the issue against.
gem 'activerecord', '~> 4.1'
require 'active_record'
require 'minitest/autorun'
require 'logger'
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
# This connection will do for database-independent bug reports.
@haggen
haggen / application.html.erb
Created August 21, 2014 23:34
Auto refresh CSS on Rails+turbolinks
...
<%= javascript_tag do %>
// Auto refresh CSS every 2s, only on development, turbolinks ready
!this.REFRESHER && (this.REFRESHER = setInterval(function() {
$('link[rel="stylesheet"]').attr('href', function(index, value) {
return value.replace(/\?.+|$/, '?' + Math.random());
});
}, 2000));
<% end if Rails.env.development? %>