Skip to content

Instantly share code, notes, and snippets.

View pmartycz's full-sized avatar

Piotr Martycz pmartycz

View GitHub Profile
@pmartycz
pmartycz / catv-quote.js
Last active October 6, 2020 17:50
Quote of the day
async function randomQuote() {
const quotes = await fetch('http://quotes.cat-v.org/programming/')
.then(response => response.text())
.then(html => new DOMParser().parseFromString(html, 'text/html'))
.then(dom => [...dom.querySelector('body > article').children])
quotes.shift();
const isSeparator = el => el.tagName === 'HR';
@pmartycz
pmartycz / ubuntu-mini-iso-uefi
Last active June 1, 2023 17:35
Ubuntu mini.iso with UEFI support
#!/bin/sh -eu
# Downloads, verifies and unpacks Ubuntu mini.iso fixing lack of UEFI support
# See https://bugs.launchpad.net/ubuntu/+source/debian-installer/+bug/1429030
# Thanks to https://www.nemotos.net/?p=2057
require() {
hash "$@" || die "Some of the required commands are missing"
}
@pmartycz
pmartycz / a-z.md
Last active November 4, 2021 16:37
Debian/Ubuntu Setup
@pmartycz
pmartycz / script.sh
Last active December 20, 2019 18:51
Making Ubuntu Live USB persistent
sudo -i
mount -o remount,rw /cdrom
truncate -s $((4*2**30-1)) /cdrom/casper-rw
mkfs.ext4 -L casper-rw -O ^has_journal /cdrom/casper-rw
sed -i '/casper\/vmlinuz/ s/ ---/ persistent\0/' /cdrom/boot/grub/grub.cfg
reboot
  • Create /efi dir so that systemd-gpt-auto-generator can automount ESP
  • Use bootctl to install/update bootloader in ESP
  • User kernel-install to copy linux image and initrd into ESP, e.g. kernel-install add 4.19.0-0.bpo.5-amd64 /boot/vmlinuz-4.19.0-0.bpo.5-amd64
package com.example.demo;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.UnaryOperator;
public class LogOptional {
public static void main(String[] args) {
UnaryOperator<?> log = x -> {
private Optional<TemplateRule> findBestTemplateRule(List<TemplateRule> list) {
Predicate<TemplateRule> byClientId = r -> Objects.equals(r.getClientId(), shipment.getClientId());
Predicate<TemplateRule> byLastMile = r -> r.getLastMile() == shipment.getLastMileEnum();
Predicate<TemplateRule> byFirstMile = r -> r.getFirstMile() == shipment.getFirstMileEnum();
Predicate<TemplateRule> byFirstMileAndLastMile = byFirstMile.and(byLastMile);
Stream<TemplateRule> one = list.stream().filter(byFirstMileAndLastMile.and(byClientId));
Stream<TemplateRule> two = list.stream().filter(byFirstMile.and(byClientId));
Stream<TemplateRule> three = list.stream().filter(byLastMile.and(byClientId));