Skip to content

Instantly share code, notes, and snippets.

View lavoiesl's full-sized avatar

Sébastien Lavoie lavoiesl

View GitHub Profile
// 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
@lavoiesl
lavoiesl / clone remote
Created November 22, 2018 15:57
reference vs clone
```
$ time GIT_TRACE=1 git -c http.proxy=http://localhost:8888 clone --mirror https://github.com/Shopify/shopify.git /tmp/g.git
10:45:42.059182 git.c:415 trace: built-in: git clone --mirror https://github.com/Shopify/shopify.git /tmp/g.git
Cloning into bare repository '/tmp/g.git'...
10:45:42.071336 run-command.c:637 trace: run_command: git-remote-galaxy origin Shopify/shopify.git
10:45:42.152772 git.c:415 trace: built-in: git config --get remote.origin.url
10:45:42.168087 git.c:415 trace: built-in: git config --get remote.origin.pushurl
10:45:42.193176 git.c:415 trace: built-in: git config --get user.email
10:45:42.199199 git.c:659 trace: exec: git-remote-http origin https://git-mirror.shopifycloud.com/Shopify/shopify.git
10:45:42.199637 run-command.c:637 trace: run_command: git-remote-http origin https://git-mirror.shopifycloud.com/Shopify/shopify.git