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
╰─○ curl -o foo.rb 'https://gist.githubusercontent.com/n-b/401518f50a553dc32edad5932872b4f0/raw/da6b298c533f9cd46fe62874646438411f452aa8/utf8.rb'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 140 100 140 0 0 873 0 --:--:-- --:--:-- --:--:-- 875
╰─○ cat foo.rb
#! ruby
module Foo_é
def self.bla
puts "bla"
@francois
francois / gist:f630c8963fc7cb97f2be02f13fc6835d
Created March 20, 2024 17:04
devenv breakage while searching for "postgres"
╰─○ devenv search postgres
error: builder for '/nix/store/76rmja3dxh8609xj01393p7b9sby53zq-llvm-13.0.1.drv' failed with exit code 2;
last 10 log lines:
> [ 4%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/Types.cpp.o
> [ 4%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/X86DisassemblerTables.cpp.o
> [ 4%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/X86EVEX2VEXTablesEmitter.cpp.o
> [ 4%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/X86FoldTablesEmitter.cpp.o
> [ 4%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/X86ModRMFilters.cpp.o
> [ 4%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/X86RecognizableInstr.cpp.o
> [ 4%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/WebAssemblyDisassemblerEmitter.cpp.o
require "benchmark"
srand(42)
ARRAY = 1_000_000.times.map { rand }.freeze
Benchmark.bmbm do |b|
b.report("combined") { ARRAY.select{|val| val < 500 && val > -500 && !val.zero?}.map{|val| -2 * val}.select{|val| val / 2 < 1}.to_a }
b.report("separate") { ARRAY.select{|val| val < 500}.select{|val| val > -500}.reject(&:zero?).map{|val| -2 * val}.select{|val| val / 2 < 1}.to_a }
b.report("lazy-sep") { ARRAY.lazy.select{|val| val < 500}.select{|val| val > -500}.reject(&:zero?).map{|val| -2 * val}.select{|val| val / 2 < 1}.to_a }
b.report("lazy-comb") { ARRAY.lazy.select{|val| val < 500 && val > -500 && !val.zero?}.map{|val| -2 * val}.select{|val| val / 2 < 1}.to_a }
@francois
francois / gist:2dfd9ed91d8078eb143490e3e88d77c7
Created October 6, 2020 11:55
JRuby failure loading ConsoleReporter from metrics-core
[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
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
...
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
#!/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
$ 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
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
isSleeping: function() {
return this.get('state') === 'sleeping';
},
isNapping: function() {
@francois
francois / controllers.application.js
Last active January 8, 2017 21:52
computed-properties
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;