Skip to content

Instantly share code, notes, and snippets.

View TomZhuPlanetart's full-sized avatar
💭
I may be slow to respond.

Tom Zhu TomZhuPlanetart

💭
I may be slow to respond.
  • Planetart
  • HangZhou China
View GitHub Profile
@TomZhuPlanetart
TomZhuPlanetart / Dockerfile
Last active July 3, 2024 02:31
Dockerfile for PHP 8.2 + Apache on Amazonlinux2
FROM amazonlinux:2
RUN yum install -y httpd vim
RUN amazon-linux-extras enable php8.2 && yum clean metadata
RUN yum install -y php-bcmath.x86_64 \
php-cli.x86_64 \
php-dba.x86_64 \
php-dbg.x86_64 \
php-devel.x86_64 \
php-enchant.x86_64 \

Key Formats

  • RFC4716: SSH2 public or private key. Begins with -----BEGIN OPENSSH PRIVATE KEY-----
  • PKCS#8: PKCS8 public or private key. Use the -m PKCS8 option of ssh-keygen. Begins with -----BEGIN PUBLIC KEY-----
  • PKCS#1
  • DER: Binary format
  • PEM: PEM public key. This refers to PKCS#8 when it's used in openssl commands.

PKCS8/PKCS1 are specifically for RSA keys.

@TomZhuPlanetart
TomZhuPlanetart / Encrypt_and_Decrypt.md
Last active April 7, 2024 15:09
Encrypt and Decrypt with openssl

Encrypt with AES

Let's encrypt something

echo hello world | openssl enc -aes-256-cbc -pass pass:hello -iter 10 -in - -out - | base64

The output looks like:

@TomZhuPlanetart
TomZhuPlanetart / regexp.md
Created February 21, 2024 09:51
Regular Expression To Match nested function call

With the help of recursion clause (https://www.regular-expressions.info/recurse.html),

(\w*|\w*::\w*)\((?:\s*((?<=\()|(?<!\(),)\s*((?R)|\$\w+)\s*)*\)

This expression matches function calls like below:

Registry::initRegistry(registry( $a, $b, abc( $a, $b, $c), $d));
@TomZhuPlanetart
TomZhuPlanetart / gist:c2505daa4e9b60cc78b4c7100385e38a
Created February 8, 2024 01:24
Control The Terminal With `tput`
### https://linuxcommand.org/lc3_adv_tput.php
# save the content of the screen
tput smcup
tput cup 0 0
for ((i=0; i<10; i++)); do
# set forground color
tput setaf $i
@TomZhuPlanetart
TomZhuPlanetart / async-socket.php
Created October 7, 2022 15:58
Making async TCP connection with PHP
<?php
/**
* User: Tom.Zhu<tom.zhu@planetart.cn>
* Date: 2022/10/7
* Time: 23:34
*/
$base = new EventBase();
$start = microtime(true);
@TomZhuPlanetart
TomZhuPlanetart / php-fiber.php
Last active October 7, 2022 16:01
Implementing Routine with Fiber && Event
<?php
/**
* User: Tom.Zhu<tom.zhu@planetart.cn>
* Date: 2022/9/28
* Time: 22:13
*/
class FiberFactory
{
private static WeakMap $weakMap;