Skip to content

Instantly share code, notes, and snippets.

@sify21
sify21 / pwdx_for_mac.bash
Last active Sep 15, 2021 — forked from tobym/pwdx_for_mac.bash
pwdx for mac. Usage: pwx pid
View pwdx_for_mac.bash
function pwdx {
lsof -a -d cwd -p $1 -n -Fn | awk '/^n/ {print substr($0,2)}'
}
@sify21
sify21 / aes.js
Last active Sep 2, 2021
aes-gcm-siv implementation using node-forge. A direct translation of https://github.com/bjornedstrom/aes-gcm-siv-py
View aes.js
const forge = require('node-forge');
forge.options.usePureJavaScript = true;
class Field {
static _MOD = [0n, 121n, 126n, 127n, 128n].map(i => 1n << i).reduce(((previousValue, currentValue) => previousValue + currentValue));
static _INV = [0n, 114n, 121n, 124n, 127n].map(i => 1n << i).reduce(((previousValue, currentValue) => previousValue + currentValue));
static add(x, y) {
return x ^ y;
}
@sify21
sify21 / howToModifyOvaFile.md
Created Aug 29, 2021 — forked from goodjob1114/howToModifyOvaFile.md
how to modify .ova file on linux/Mac using terminal....export vm (OVF 1.0) from virtualbox, then modify some tag and hash value for import vm to ESXi
View howToModifyOvaFile.md

extract ova files from an archive

$ tar -xvf vmName.ova

modify ovf for some invalid tag

$ vi vmName.ovf
@sify21
sify21 / pyproject.toml
Last active Apr 15, 2021
pyproject.toml
View pyproject.toml
[tool.poetry]
name = "test"
version = "0.1.0"
description = ""
authors = ["sify21 <sify1221@gmail.com>"]
[tool.poetry.dependencies]
python = ">=3.6,<4.0"
jsonschema = "^3.2.0"
@sify21
sify21 / build.sh
Last active Jul 15, 2021
build static native image with graal
View build.sh
# build gcc toolchain targeting x86_64-linux-musl with https://github.com/richfelker/musl-cross-make
# don't use master branch which uses musl v1.2.1(the new malloc implementation has deadlock problems, v1.2.2 fixes it, v1.2.0 doesn't have it)
cd ~
git clone https://github.com/richfelker/musl-cross-make -b v0.9.9
cd musl-cross-make
cp config.mak.dist config.mak
# edit config.mak: TARGET = x86_64-linux-musl
make -j`nproc`
make install
ln -s output/bin/x86_64-linux-musl-gcc output/bin/musl-gcc
View casbin-rs-custom-func
#[cfg(test)]
mod test {
use casbin::{CoreApi, DefaultModel, Enforcer, MemoryAdapter, MgmtApi};
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct Claims {
pub id: i64,
pub username: String,
pub resources: Vec<String>,
View middleware_full.go
package main
import (
"fmt"
"log"
"net/http"
)
func init() {
log.SetFlags(log.Lshortfile)