Skip to content

Instantly share code, notes, and snippets.

View mk_pkgbuild.rb
require 'erb'
require 'net/http'
DOC_TEXT = <<-DOC
# Get started:
git clone ssh://aur@aur.archlinux.org/docker-rootless-bin.git
cd docker-rootless-bin
curl https://gist.githubusercontent.com/pastleo/d3d0fd02880dbd9b30647c91d1fdb8f9/raw/mk_pkgbuild.rb > mk_pkgbuild.rb
# Update:
@pastleo
pastleo / mk_exfat_usb.sh
Last active Aug 2, 2020
make a exfat usb that can be used in macos and (hopefully) windows
View mk_exfat_usb.sh
#!/bin/bash
set -e
# https://en.wikipedia.org/wiki/ExFAT
# https://unix.stackexchange.com/questions/460155/mac-os-cannot-mount-exfat-disk-created-on-ubuntu-linux
# Preparation:
# pacman -S parted exfat-utils
@pastleo
pastleo / create_arch_media.sh
Last active Jun 19, 2021
create archlinux installation media
View create_arch_media.sh
#!/bin/bash
set -e
# https://wiki.archlinux.org/index.php/USB_flash_installation_medium#Using_manual_formatting
# https://unix.stackexchange.com/questions/38164/create-partition-aligned-using-parted/49274#49274
# https://wiki.archlinux.org/index.php/Parted
# https://wiki.archlinux.org/index.php/Syslinux#Manual_install
# Preparation:
@pastleo
pastleo / setuid-experiment.c
Last active Jul 5, 2020
setuid experiment
View setuid-experiment.c
#include <stdio.h>
// provides printf()
#include <stdlib.h>
// provides system()
#include <unistd.h>
// provides getuid(), geteuid(), setuid()
int main ()
@pastleo
pastleo / fibTco.js
Last active Mar 11, 2020
tail call optimization on fibonacci
View fibTco.js
const fib = n => (n <= 2 ? 1 : fib(n - 1) + fib(n - 2));
const fibTco = (n, a = 1, b = 1) => (n === 1 ? a : fibTco(n - 1, b, a+b));
const nth = 42;
console.log(`fib(${nth}) =`);
console.log(` ${fib(nth)}`);
console.log(`fibTco(${nth}) = `);
console.log(` ${fibTco(nth)}`);
@pastleo
pastleo / gSheetScript.js
Last active Feb 8, 2020 — forked from mhawksey/gist:1276293
Google spreadsheet and App Script as backend - insert data to a google spreadsheet via POST or GET
View gSheetScript.js
/*
Copyright 2011 Martin Hawksey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@pastleo
pastleo / howdy-face-recognition-arch-kde.md
Last active Jun 2, 2021
Setup face recognition authentication on ArchLinux and KDE Plasma using howdy
View howdy-face-recognition-arch-kde.md

Setup face recognition authentication on ArchLinux and KDE Plasma using howdy

This is surprisingly easy...basically following Arch Wiki:

https://wiki.archlinux.org/index.php/Howdy

After some investigation, here is step by step and preferences

Install howdy

@pastleo
pastleo / try-proxy.js
Created Oct 18, 2019
experiments about js proxy api
View try-proxy.js
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
const magicObj = new Proxy({}, {
get: (obj, name) => {
if (obj[name] === undefined) obj[name] = 1;
else obj[name]++;
return obj[name];
},
set: (obj, name, value) => {
if (obj[name] === undefined) return Reflect.set(obj, name, value); // will explain below
else return Reflect.set(obj, name, obj[name] + value);
@pastleo
pastleo / try-event-target.js
Created Oct 18, 2019
experiments about EventTarget and nodejs polyfill
View try-event-target.js
const isBrowser = (function() {
try { return !!window; } catch (_) { return false; }
})();
if (isBrowser) {
window.global = window;
}
const Event = isBrowser ? class extends window.Event {
constructor(type, payload) {
View left-right.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
body {
margin: 0;
height: 100vh;
width: 100vw;