Skip to content

Instantly share code, notes, and snippets.

@dsimard
dsimard / test.rb
Created January 3, 2016 20:08
Rails query object
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
@dsimard
dsimard / bug.rb
Created July 14, 2015 17:23
Paranoia
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
# Activate the gem you are reporting the issue against.
@dsimard
dsimard / has_many_through_includes.rb
Created April 8, 2015 16:28
`has_many :through` an association that uses `includes` throws an error
# Activate the gem you are reporting the issue against.
gem 'activerecord', '4.1.1' # as well as '4.2.0'
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.
@dsimard
dsimard / install weechat.sh
Created January 7, 2014 02:42
Install weechat
git clone git://git.sv.gnu.org/weechat.git
git checkout -b v0.4.2 v0.4.2
sudo apt-get install libncursesw5-dev libcurl4-gnutls-dev zlib1g-dev libgcrypt11-dev
mkdir build
cd build
cmake .. -DPREFIX=/path/to/weechat
make
make install
@dsimard
dsimard / ann.sql
Last active December 11, 2015 17:58
Kobo Glo Annotation
select book.contentid as bookid, book.title, b.bookmarkid, b.text, b.annotation
from bookmark b
inner join content c on b.contentid = c.contentid
inner join content book on c.bookid = book.contentid
order by book.datelastread desc, b.datecreated
@dsimard
dsimard / fixed.js
Last active December 4, 2018 19:24
Fixed decimals
(function fixed(float, decimal) {
decimal = decimal==undefined || decimal < 0 ? 2 : decimal;
return Math.round(float*Math.pow(10, decimal)).toString()
.replace((new RegExp("(\\d{"+decimal+"})$")), "$'.$1")
.replace(/^(-?)(\.)/, "$10.")
.replace(/^0$/, '0.00')
})(1.495)
@dsimard
dsimard / array.js
Created May 9, 2012 16:01
Why I love coffeescript
["The value of", property, "is", value].join(" ")
@dsimard
dsimard / sortable.coffee
Created May 1, 2012 16:08
Sortable tables with Twitter Bootstrap 2
$(document).ready ->
$(".table-sortable").dataTable
aaSorting: [] # disable default sort (remove this line to enable it)
bPaginate: false # Remove pagination
bFilter: false # Remove filter
bInfo: false # Remove useless info
# Columns with .unsortable class are not sortable
aoColumnDefs : [
'bSortable': false,
'aTargets': ['unsortable']
program HelloWorld;
begin
if 1 = 1 then
begin
writeln('Hello World');
end
else
begin
writeln('We are in Sonic the Hedgehog''s Twilight Zone');
@dsimard
dsimard / about.html
Created February 13, 2012 23:40
Test for gist.js
<html>
<head>
<title>This is an about page</title>
</head>
<body>
<h1>This is an about page</h1>
</body>
</html>