Skip to content

Instantly share code, notes, and snippets.

View francois's full-sized avatar

François Beausoleil francois

  • Sherbrooke, QC, Canada
View GitHub Profile
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 4. in line 1.
Account;2016-09-01;2016-10-01;Total
Groceries;600,00;700,00;1300,00

The Fastest Ways to Add Data to PostgreSQL

NOTE: This is a companion article to a talk I did at Montreal.rb on September 20th, 2016 titled "PostgreSQL: The Fastest Ways to Add Data".

Everybody knows how to add data to a PostgreSQL cluster:

INSERT INTO table(column0, column1) VALUES (val0, val1)
source "https://rubygems.org"
ruby "2.3.0", engine: "jruby", engine_version: "9.1.2.0"
# If on MRI Ruby
# gem "pg", "0.17.1", platform: :ruby
# If on JRuby
gem "pg", "0.17.1", platform: :jruby, git: "git://github.com/headius/jruby-pg.git", branch: :master
gem "jdbc-postgresql", "!= 9.4.1204", platform: :jruby
gem "rollbar"

Using the Elm 0.17 REPL, sorting is not in the expected order (Ubuntu 15.10):

$ elm repl
---- elm repl 0.17.0 -----------------------------------------------------------
 :help for help, :exit to exit, more at <https://github.com/elm-lang/elm-repl>
--------------------------------------------------------------------------------
> import List
> import String
> List.sortBy String.toLower ["R", "É", "D"]
@francois
francois / 0001-schema.sql
Last active November 7, 2015 15:38
Setup code to find a way to test constraint triggers on PostgreSQL 9.4 using pgprove
CREATE TABLE accounts(
account text not null
, account_kind text not null
, account_id serial not null unique
, primary key(account)
);
CREATE TABLE transactions(
transaction_id uuid not null
@francois
francois / elevator-sol-6-and-less.js
Created August 16, 2015 18:35
These represent successive solutions to the [Elevator Saga](http://play.elevatorsaga.com/)
{
init: function(elevators, floors) {
var waitingFloors = [];
floors.forEach(function(floor) {
floor.on("up_button_pressed", function() {
waitingFloors.push(floor.floorNum());
});
floor.on("down_button_pressed", function() {
waitingFloors.push(floor.floorNum());
Boot Error
Something went wrong while loading /vagrant/config.ru
TypeError: can't convert into Integer
/home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/lotus-utils-0.4.2/lib/lotus/utils/kernel.rb:339:in `rescue in Integer'
/home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/lotus-utils-0.4.2/lib/lotus/utils/kernel.rb:332:in `Integer'
/home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/lotus-model-0.3.1/lib/lotus/model/mapping/coercions.rb:112:in `Integer'
/home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/lotus-model-0.3.1/lib/lotus/model/mapping/coercer.rb:70:in `from_record'
/home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/lotus-model-0.3.1/lib/lotus/model/mapping/collection.rb:355:in `block in deserialize'
~/logstash-1.4.2 $ cat source.mjson
{"script": "update-community-metrics-twitter", "duration": 358.9, "rows": 6372}
{"script": "update-community-metrics-facebook", "duration": 398.9, "rows": 6429}
{"script": "update-community-metrics-followers", "duration": 1358.9, "rows": 6372}
~/logstash-1.4.2 $ cat source.mjson | bin/logstash -e 'input{stdin{codec=>json}}'
{
"script" => "update-community-metrics-twitter",
"duration" => 358.9,
"rows" => 6372,
francois@francois:/home/francois $ ssh mike "git ls-remote git@github.com:seevibes/engine.git"
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
francois@francois:/home/francois $ ssh -A mike "git ls-remote git@github.com:seevibes/engine.git" | head
c8db3ccc1257ad1f2ed63aa1bbb3a00704d0ab61 HEAD
0d28f804a58a28134255eb71b3b540bb4724acd1 refs/heads/add-brand-affinity-tables
370f61ba196180e2b3aefa65d521ed02d33c7a63 refs/heads/add-end-at-to-airtime-reports
e0e2d3d56e66b9b44571f74b39c550c16a90559a refs/heads/add-sampling-to-airtime-and-persona-followers
4b84c8bc958c0a9a1c499bc749d2338d31e756cf refs/heads/adding-back-interacted-or-follows-at-binding
913ee41a529472f662f4f9b9997d8e66473454fe refs/heads/better-gender-cache
NameError - uninitialized constant Representable::Coercion:
/var/lib/gems/1.9.1/gems/reform-1.2.5/lib/reform/form/validate.rb:127:in `block in populate_representer'
/var/lib/gems/1.9.1/gems/reform-1.2.5/lib/reform/representer.rb:45:in `each'
/var/lib/gems/1.9.1/gems/reform-1.2.5/lib/reform/contract.rb:128:in `representer'
/var/lib/gems/1.9.1/gems/reform-1.2.5/lib/reform/form/validate.rb:108:in `populate_representer'
/var/lib/gems/1.9.1/gems/reform-1.2.5/lib/reform/form/validate.rb:94:in `deserialize!'
/var/lib/gems/1.9.1/gems/reform-1.2.5/lib/reform/form/validate.rb:86:in `update!'
/var/lib/gems/1.9.1/gems/reform-1.2.5/lib/reform/form/validate.rb:75:in `validate'
/var/lib/gems/1.9.1/gems/reform-1.2.5/lib/reform/form/multi_parameter_attributes.rb:43:in `validate'
/var/lib/gems/1.9.1/gems/trailblazer-0.2.1/lib/trailblazer/operation.rb:105:in `validate'