Skip to content

Instantly share code, notes, and snippets.

View tmichel's full-sized avatar

Tamás Michelberger tmichel

View GitHub Profile
@tmichel
tmichel / search-engine.js
Created May 2, 2017 13:51
Mass remove Chrome search engines.
document.querySelectorAll('#other-search-engine-list > div.deletable-item').forEach(function(el) {
var url = el.querySelector('.url-column div.static-text');
if (url && ( url.textContent.match(/\.blog\.hu/) || url.textContent.match(/wordpress\.com/) )) {
console.log(url.textContent);
var button = el.querySelector('.row-delete-button');
if (button) {
button.click(button);
}
}
})
@tmichel
tmichel / content.js
Created May 2, 2017 13:47
Disable adding OpenSearch link tags automatically
document.querySelectorAll('[type="application/opensearchdescription+xml"]').forEach(function (e) { e.remove() })
@tmichel
tmichel / env.rb
Created January 27, 2017 13:44
Ruby convenience ENV wrapper
require "delegate"
module MyNamespace
class EnvWrapper < SimpleDelegator
def array(key, default: [], delim: ",")
if value = self[key]
value.split(delim)
else
default
end
@tmichel
tmichel / house.rb
Created November 30, 2016 21:47
The house that Jack built
class House
def self.recite
new.recite
end
attr_reader :start, :glue
def initialize(start: "This is", glue: "that")
@start = start
@glue = glue
@tmichel
tmichel / sidekiq_bulk.rb
Created October 25, 2016 19:28
Push jobs to Sidekiq in bulks
module Sidekiq
module Worker
module Bulk
# Queue a batch of jobs at the same time. The batch is sliced into smaller
# batches. To configure the max batch size that is sent to Redis at once
# set the `max_bulk_size` sidekiq option for the job class. This option
# default to 1000.
#
# @param args_set [Array] an array of arrays with job arguments
# @return [Array] array of the queued job ids
@tmichel
tmichel / go-watch.sh
Last active February 6, 2018 13:00
Watch file changes and run go test (OSX)
#!/bin/bash
echo "Watching for changes..."
red() {
str="$1"
sed "/[[:<:]]$str/s//$(printf "\033[31m$str\033[0m")/"
}
green() {
@tmichel
tmichel / immutable-infrastructure.md
Created September 21, 2016 14:33
Note on immutable infrastructure
@tmichel
tmichel / bot.rb
Created May 26, 2016 07:04
budapest.rb 2016/05 - Bots in Ruby talk
require "socket"
socket = TCPSocket.new('irc.freenode.net', 6667)
def socket.say(message)
write("#{message}\r\n")
end
socket.say("NICK botobot")
socket.say("USER botobot 0 * :botobot")
@tmichel
tmichel / diff.sh
Created December 17, 2015 09:37
Diff output of two commands without temporary files
# source: http://stackoverflow.com/questions/3800202/diff-output-from-two-programs-without-temporary-files
diff -y <(git st | grep rb | cut -c 4-) <(find app -name *product.rb)
@tmichel
tmichel / gb-rename.sh
Last active October 16, 2015 08:58
gb gorename shim
#!/bin/bash
# Usage: gb rename [gorename options]
# Example:
#
# gb rename -from '"mypackage".AwesomeStruct' -to "EvenMoreAwesomeStruct"
#
# Install: drop this file on your $PATH somewhere ($HOME/bin seems cool) and you're done.
if [ "$1" = "help" ]; then
gorename --help