Skip to content

Instantly share code, notes, and snippets.

View peter279k's full-sized avatar

Chun-Sheng, Li peter279k

View GitHub Profile
peter279k /
Created May 15, 2024 10:52 — forked from drmalex07/
An example with an oneshot service on systemd. #systemd #systemd.service #oneshot


Services declared as oneshot are expected to take some action and exit immediatelly (thus, they are not really services, no running processes remain). A common pattern for these type of service is to be defined by a setup and a teardown action.

Let's create a example foo service that when started creates a file, and when stopped it deletes it.

Define setup/teardown actions

Create executable file /opt/foo/

WeWork WiFi on Linux

When using nmcli device wifi connect 'WeWorkWiFi' password '...', you'll get something like:

Error: Failed to add/activate new connection: Failed to determine AP security information

To actually use it, you need to create a connection first and configure it:

peter279k / Dockerfile
Created May 1, 2024 12:51 — forked from udkyo/Dockerfile
Basic container for X11 forwarding goodness
FROM ubuntu
RUN apt update \
&& apt install -y firefox \
openssh-server \
xauth \
&& mkdir /var/run/sshd \
&& mkdir /root/.ssh \
&& chmod 700 /root/.ssh \
&& ssh-keygen -A \
&& sed -i "s/^.*PasswordAuthentication.*$/PasswordAuthentication no/" /etc/ssh/sshd_config \
peter279k /
Created February 22, 2024 06:38 — forked from jkatz/
Methods to create password verifiers for PostgreSQL
# Copyright 2019-2022 Jonathan S. Katz
# 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:
peter279k /
Created January 25, 2024 14:03 — forked from GAS85/
Activating HTTP Public Key Pinning (HPKP) on Let's Encrypt

Activating HTTP Public Key Pinning (HPKP) on Let's Encrypt


  • Disclaimer: This might break your website, don't preceded if you don't know what you're doing.

Since the letsencrypt seems to create a new private key every time the certificate is renewed and Let's Encrypt requires you to renew you certificate once every ~80 days pinning using your certificate's SPKI is probably not the way to go. So, what should we pin then? Let's Encrypt is currently issuing from Authority X3, and using Authority X4 as a backup, so these two is a great place to start. We should also include the ISRG Root so this might support new Authorities with other SPKIs as well.

Generate HASH of Private Keys

To generate the hash of the SPKI of these certificates run the following commands

peter279k / gen-key-script
Created December 6, 2023 07:53 — forked from woods/gen-key-script
Creating gpg keys non-interactively
Key-Type: 1
Key-Length: 2048
Subkey-Type: 1
Subkey-Length: 2048
Name-Real: Root Superuser
Expire-Date: 0
peter279k / frp
Created March 18, 2023 15:43 — forked from ihipop/frp
FRP systemd 启动脚本 FRP systemd init config
peter279k /
Created December 16, 2022 14:09 — forked from yanqd0/
Python requests download file with a tqdm progress bar
import requests
from tqdm import tqdm
def download(url: str, fname: str, chunk_size=1024):
resp = requests.get(url, stream=True)
total = int(resp.headers.get('content-length', 0))
with open(fname, 'wb') as file, tqdm(
name: build
on: [ push, pull_request ]
runs-on: ${{ matrix.operating-system }}
operating-system: [ ubuntu-latest ]
peter279k / curl_progress.php
Created April 26, 2022 13:48 — forked from bdunogier/curl_progress.php
PHP/cURL download progress monitoring
file_put_contents( 'progress.txt', '' );
$targetFile = fopen( 'testfile.iso', 'w' );
$ch = curl_init( '' );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt( $ch, CURLOPT_NOPROGRESS, false );
curl_setopt( $ch, CURLOPT_PROGRESSFUNCTION, 'progressCallback' );
curl_setopt( $ch, CURLOPT_FILE, $targetFile );