Skip to content

Instantly share code, notes, and snippets.

View BuonOmo's full-sized avatar
🥊
—(ಠ益ಠ)ノ

Ulysse Buonomo BuonOmo

🥊
—(ಠ益ಠ)ノ
View GitHub Profile
@BuonOmo
BuonOmo / container-provider.zsh
Last active January 17, 2018 12:27
A tiny script to provide a container
#!/bin/zsh
# Copyright (c) 2016 Ulysse Buonomo <buonomo.ulysse@gmail.com> (MIT license)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
@BuonOmo
BuonOmo / 0-good-old-way.rb
Last active October 23, 2018 16:23
A headache in Ruby: Hash default values
students_by_option = {}
[["gym", "eddy"], ["theater", "john"], ["gym", "ned"]].each do |option, student|
students_by_option[option] = [] if students_by_option[option].nil?
students_by_option[option] << student
end
p students_by_option["theater"] # ["john"]
p students_by_option # { "gym" => ["eddy", "ned"], "theater" => ["john"] }
@BuonOmo
BuonOmo / fold-string.rb
Last active December 6, 2018 23:25
Fold a string in ruby
# inspired by: https://stackoverflow.com/a/11934977/6320039
# proof of concept: https://regex101.com/r/RkHel3/2
def fold(str, length: 80, sep: "\\s")
return str if str.length < length
regexp = /((^[^#{sep}]{#{length - 1}})?(?(2)|^.{1,#{length - 2}}#{sep}))(.*)/
_, folded, _, rest = *str.match(regexp)
"#{folded}⤶\n#{fold("⤷" + rest, length: length, sep: sep)}"
@BuonOmo
BuonOmo / so-comment-newbie.md
Last active March 19, 2019 09:11
Some good way to reroute a newbie on stack overflow

The posted question does not appear to include any attempt at all to solve the problem. StackOverflow expects you to try to solve your own problem first, as your attempts help us to better understand what you want. Please edit the question to show what you've tried, so as to illustrate a specific roadblock you're running into in a mcve. For more information, please see ask and take the tour.

@BuonOmo
BuonOmo / most-starred-repos.sh
Last active January 16, 2020 14:51
Most starred public repositories on GitHub.
# Forked from: https://gist.github.com/jdennes/7013672.
#
# I improved the request output!
curl -G https://api.github.com/search/repositories \
--data-urlencode 'q=stars:>1000' \
--data-urlencode 'sort=stars' \
--data-urlencode 'order=desc' \
-H 'Accept: application/vnd.github.preview' \
| jq --raw-output '.items | .[] | (.full_name + " (" + (.stargazers_count | tostring) + ")")' \
| cat -n
@BuonOmo
BuonOmo / install-ungit.sh
Last active March 2, 2020 07:10
install ungit on Ubuntu 16.04
sudo apt-get install nodejs-legacy nodejs npm
npm config set prefix ~/npm
sudo ln -s /usr/bin/nodejs /usr/bin/node
sudo -H npm install -g ungit
@BuonOmo
BuonOmo / talkie.js
Last active April 10, 2020 14:39
Hangout push to talk.
// ==UserScript==
// @name talkie
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Safe talking on hangout
// @author You
// @match https://hangouts.google.com/u/*/call/*
// @grant none
// ==/UserScript==
  1. Install the ruby extension pack.
  2. bundle install --binstubs to have bin/<executable>
  3. create a launch.json and add the configuration:
    {
      "name": "TODO",
      "type": "Ruby",
      "request": "launch",
      "program": "${workspaceRoot}/bin/TODO",

"cwd": "${workspaceRoot}",

@BuonOmo
BuonOmo / scrap-heroku-dataclips.js
Last active October 16, 2020 11:08
Retrieve every Heroku dataclips at once.
// Go to the dataclip listing (https://data.heroku.com/dataclips).
// Then execute this script in your console.
// Be careful, this will focus a new window every 4 seconds, preventing
// you from working 4 seconds times the number of dataclips you have.
// Retrieve urls and titles
let dataclips = Array.
from(document.querySelectorAll('.rt-td:first-child a')).
map(el => ({ url: el.href, title: el.innerText }))
@BuonOmo
BuonOmo / mass-archive-trello-columns.js
Last active November 5, 2020 17:56
Archive trello columns all at once (using web, or api)
function timeout(time = 200) {
return new Promise((resolve) => {
setTimeout(resolve, time);
})
}
/**
* Prepare archiving, making sure columns are the correct ones.
*
* @param contents every column names to treat (may be only a part)