Skip to content

Instantly share code, notes, and snippets.

View lavoiesl's full-sized avatar

Sébastien Lavoie lavoiesl

View GitHub Profile
# typed: false
# frozen_string_literal: true
require "bundler"
require "antlr4-native"
require "etc"
require "rubygems/package"
require "zlib"
require "open-uri"
// Adapted from https://developers.google.com/apps-script/articles/vacation-calendar
var TEAM_CALENDAR_ID = 'c_xxxxxxxxxxxx@group.calendar.google.com';
var MONTHS_IN_ADVANCE = 2;
var WHOLE_DAY_HOURS_THRESHOLD = 6;
var USER_EMAILS = [
];
// The maximum script run time under Apps Script Pro is 30 minutes; this setting
// will be used to report when the script is about to reach that limit.
package main
import (
"fmt"
"math/rand"
"strings"
"testing"
)
const alphabet = "abcdefghijklmnopqrstuvwxyz0123456789"
package main
import "testing"
var list []*struct{}
func init() {
for i := 0; i < 1000; i++ {
list = append(list, nil)
}
module KeywordCurry
def initialize
@vars = {}
end
def with_argument(name, val)
d = self.dup
d.bind_argument(name.to_sym, val)
d
end
#!/usr/bin/env ruby
require 'open3'
module CheckGitNoModif
class << self
def call(*argv)
case argv.size
when 1
if system("git rev-parse --git-dir >/dev/null 2>&1")
#!/usr/bin/env ruby
require 'open3'
module CheckstyleToJUnit
# https://github.com/koalaman/shellcheck/wiki/JUnit
XSLT = File.expand_path('../support/checkstyle2junit.xslt', __dir__)
class << self
def call
#!/usr/bin/env ruby
# Input:
# {
# "Issues": [
# {
# "FromLinter": "gofmt",
# "Text": "File is not `gofmt`-ed with `-s`",
# "Pos": {
# "Filename": "shell/shell.go",
@lavoiesl
lavoiesl / bench.rb
Created May 2, 2019 17:15
Ruby each vs each_with_object vs inject
require 'benchmark'
size = 100
list = []
size.times { |i| list << {name: "item #{i}"} }
n = 5000
Benchmark.bmbm(16) do |bm|
bm.report('each_with_object') { n.times { list.each_with_object({}) { |item, map| map[item[:name]] = item } } }
bm.report('inject+merge') { n.times { list.inject({}) { |map, item| map.merge(item[:name] => item) } } }
@lavoiesl
lavoiesl / explode-path.sh
Last active November 23, 2020 16:22
Split paths into each components
#!/bin/bash
# Example:
# $ explode-path ~
# /
# /Users
# /Users/seb
# Great for recursively checking permissions