Skip to content

Instantly share code, notes, and snippets.

Avatar

François Beausoleil francois

View GitHub Profile
@francois
francois / gist:2dfd9ed91d8078eb143490e3e88d77c7
Created Oct 6, 2020
JRuby failure loading ConsoleReporter from metrics-core
View gist:2dfd9ed91d8078eb143490e3e88d77c7
[1] pry(main)> RUBY_VERSION
=> "2.5.7"
[2] pry(main)> JRUBY_VERSION
=> "9.2.9.0"
[3] pry(main)> RUBY_ENGINE
=> "jruby"
[4] pry(main)> require "java"
=> true
[5] pry(main)> require "./app/vendor/metrics-core-4.1.12.1.jar"
=> true
View a.txt
Table "public.stops"
Column | Type | Collation | Nullable | Default
--------------------------------+-----------------------------+-----------+----------+-----------------------------------
id | integer | | not null | nextval('stops_id_seq'::regclass)
order | integer | | not null | 1
stop_type_id | integer | | not null |
bus_route_id | integer | | not null |
location_id | integer | | |
delay_in_seconds | integer | | not null | 0
duration_in_seconds | integer | | not null | 0
View a-results.txt
...
2017-07-14 12:52:00+00 | 2
2017-07-14 12:53:00+00 | 2
2017-07-14 12:54:00+00 | 2
2017-07-14 12:55:00+00 | 2
2017-07-14 12:56:00+00 | 2
2017-07-14 12:57:00+00 | 2
2017-07-14 12:58:00+00 | 2
2017-07-14 12:59:00+00 | 2
2017-07-14 13:00:00+00 | 3
View pre-commit-hook.sh
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
View real-life.txt
$ psql --version
psql (PostgreSQL) 9.6.2
$ psql -h localhost
psql (9.6.2)
francois@localhost francois # select version();
version
----------------------------------------------------------------------------------------------------------------
PostgreSQL 9.6.2 on x86_64-apple-darwin15.6.0, compiled by Apple LLVM version 8.0.0 (clang-800.0.42.1), 64-bit
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
isSleeping: function() {
return this.get('state') === 'sleeping';
},
isNapping: function() {
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
// exposes the problem I was seeing on
// http://stackoverflow.com/q/41515493/7355
averageNapDuration: function() {
console.log('nap called');
return 124;
View a.rb
NewFamilyForm = Dry::Validation.Form do
required(:email).filled(format?: /.@.+[.][a-z]{1}/i)
# I've tried various things here, all to no effect
# required(:adult).filled(:array?, min_size?: 1)
required(:adult).value(:array?, :filled?, min_size?: 1)
required(:adult).each do
none? | (str? & min_size?(1))
end
View a.csv
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
View 2016-09-20--fastest-ways-to-add-data-to-postgresql.markdown

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)