Skip to content

Instantly share code, notes, and snippets.

View michel-zimmer's full-sized avatar

Michel Zimmer michel-zimmer

View GitHub Profile
@michel-zimmer
michel-zimmer / Lens.java
Created May 18, 2021 08:50 — forked from mathieuancelin/Lens.java
Lenses with Java 8
package bar.foo.lenses;
import java.util.function.BiFunction;
import java.util.function.Function;
public class Lens<A, B> {
private final Function<A, B> getter;
private final BiFunction<A, B, A> setter;
@michel-zimmer
michel-zimmer / readme.md
Last active September 25, 2024 10:26
Add a guest for sddm (tested under KDE neon)

Add a guest user for sddm

The objective is to create a passwordless login for a user named guest, whose home directory is cleared on logout.

This was tested under KDE neon (which is based on Ubuntu 16.04).

The following script clears the home directory of a user and replaces it with a tmpfs containing the contents of /etc/skel:

#!/bin/sh -e
#!/bin/bash
set -o nounset
set -o errexit
DELETE_ORIG=true
DELETE_FLAG=""
RECURSIVE=false
@michel-zimmer
michel-zimmer / test.rake
Created September 18, 2017 14:45
Rake task to run all tests in test folder including system ones
# lib/tasks/test.rake
namespace :test do
desc 'Runs all tests in test folder including system ones'
task all: :environment do
Rake::Task['test'].invoke
Rake::Task['test:system'].invoke
end
end
@michel-zimmer
michel-zimmer / db.rake
Created May 30, 2017 20:32
Rails task printing tables sorted by foreign key dependencies
namespace :db do
desc "Prints tables sorted by foreign key dependencies"
task fk: :environment do
connection = ActiveRecord::Base.connection
ignored_tables = [ActiveRecord::Base.schema_migrations_table_name, ActiveRecord::Base.internal_metadata_table_name]
fs_names = connection.tables.sort - ignored_tables
foreign_keys = fs_names
.map { |table_name| connection.foreign_keys(table_name) }.flatten
.map { |foreign_key| { 'from': foreign_key.from_table, 'to': foreign_key.to_table } }.uniq
@michel-zimmer
michel-zimmer / wait.js
Created March 28, 2017 23:46
Timeout the Promise chain
module.exports = ms => res => new Promise(resolve => setTimeout(() => { resolve(res) }, ms || 500))
@michel-zimmer
michel-zimmer / iserv-focusable-links.user.js
Created February 5, 2017 17:10
Restore dotted line focus indicator on IServ
// chrome://settings/searchEngines
var chromeSearchEngineCleaner = window.setInterval(function () {
var button = document.querySelector('#other-search-engine-list .row-delete-button');
if (button) {
button.click();
} else {
window.clearInterval(chromeSearchEngineCleaner);
}
}, 100);
@michel-zimmer
michel-zimmer / README.md
Last active April 27, 2021 11:36
Docker Swarm inside LXC 2.0

Docker Swarm inside LXC 2.0

sudo lxd init

./swarm-manager-create.sh
./swarm-agent-create.sh swarm-agent-{0..9}

lxc exec swarm-manager -- docker -H localhost:3375 info
@michel-zimmer
michel-zimmer / myhomework.com-ad-removal.user.js
Last active February 5, 2017 17:11
Removes ads on myhomework.com and and allows display of third column
// ==UserScript==
// @name myHomework Ad removal
// @namespace https://www.mzimmer.net/
// @version 1.0.1
// @description Removes ads on myhomework.com and and allows display of third column
// @author Michel Zimmer <[email protected]> (https://www.mzimmer.net)
// @match https://myhomeworkapp.com/*
// @grant none
// ==/UserScript==