Skip to content

Instantly share code, notes, and snippets.

View SOF3's full-sized avatar

Jonathan Chan Kwan Yin SOF3

View GitHub Profile
@SOF3
SOF3 / k8s_quantity.jq
Created July 3, 2024 11:14
Parse k8s quantities with jq
def parse_quantity:
{n: -3, u: -2, m: -1, k: 1, M: 2, G: 3} as $units |
if .[-1:] == "i" then
{base: 1024, str: .[:-1]}
else
{base: 1000, str: .}
fi |
.str[-1:] as $unit |
if $units | has($unit) then
pow(10; $units[$unit]) * (.str[:-1] | tonumber)
@SOF3
SOF3 / dynec.rs
Last active February 5, 2022 14:11
fn main() {
let mut world = dynec::World::default();
world.schedule(run);
let farm = world.create::<Node>(
None,
dynec::component_initials![
@CROPS => Capacity(100),
@CROPS => Volume(50),
@SOF3
SOF3 / phar.php
Created December 12, 2021 13:16
My personal phar tool
#!/usr/bin/env php
<?php
//declare(strict_types=1);
const USAGE = /** @lang text */
<<<USAGE
Usage: phar <action> <phar file> ...
- stub : phar s <phar> [value]
set from file: sf <phar> <stub file>
- metadata : phar m <phar> [format: DUMP|Json|Yaml|Serialized|Export|Print]
rustup +nightly component add rust-src rust-analyzer-preview
echo "let g:ycm_rust_toolchain_root = '$HOME/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu'" >> ~/.vimrc
@SOF3
SOF3 / git-mtime
Last active April 28, 2021 07:50
Update the mtime of all files in a git repository to the last commit time instead of checkout time
#!/usr/bin/env sh
# Update the mtime of all files in a git repository to the last commit time instead of checkout time
git ls-files | \
while read file; do
date="$(git log -1 --format="%cD" "$file")"
touch -d"$data" "$file"
done
@SOF3
SOF3 / GitHub Emoji List.md
Last active April 5, 2021 14:51 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
set itemSource nucleus1
ubind @poly
sensor items @unit @totalItems
jump 20 greaterThan items 0
sensor coreX itemSource @x
sensor coreY itemSource @y
ucontrol move coreX coreY 0 0 0
op rand itemId 12 b
jump 13 lessThan itemId 2
jump 15 lessThan itemId 5
# Parameters
set CURSOR_RATIO 2.5
set SCALE 80
set PAD_SIZE 0.1
set X_LEFT 8
set X_RIGHT 168
set BALL_RADIUS 0.05
set INIT_VELOCITY 0.08
set VELOCITY_INCREASE 0.02
set DIFFRACTION_RATIO 0.4

Poggit Try-Plugin Program

Rationale

To allow users to try out plugins without spending the time to install the plugin on their own server, server hosts are encouraged to provide free, temporary servers with the plugins preinstalled and preconfigured. Poggit users will be linked to the server hosts providing this service in the plugin page.

Poggit does not sell ads, so this is a great opportunity if you want to promote your server host through Poggit.

Conditions

This is a voluntary collaboration.

@SOF3
SOF3 / c.cpp
Created October 22, 2020 14:00
#include <iostream>
// #define dbg(x) (cout << #x << ": " << x << endl, x)
#define dbg(x) 0
using namespace std;
typedef long long ll;
ll MIN(ll a, ll b) {