Skip to content

Instantly share code, notes, and snippets.

Rust/Go notes

  • Rustacean and Gopher

    • quirky mascot, also Deno?
  • Rust has borrow, Go has GC

    • this is like comparing apples to oranges
    • I won't talk about it here
  • similar things

@Jimmy-Z
Jimmy-Z / main.rs
Created March 2, 2022 11:14
rust vec new/fill test
use libc::memset;
use std::mem::size_of;
use std::time::Instant;
use rand::rngs::SmallRng;
use rand::{Rng, SeedableRng};
// test a, each call creates its own vec
fn testa(l: usize, m: usize){
for _ in 0..m {
suba(l);
@Jimmy-Z
Jimmy-Z / pwrctl
Created February 21, 2021 18:16
AMD GPU power control
#!/bin/sh
enum () {
# what happens if you have more than 10 cards?
ls /sys/class/drm/|grep -E '^card[0-9]$'
}
get_hwmon () {
card=$1
# is it possible to have more than 1 hwmon?
@Jimmy-Z
Jimmy-Z / pve-cloud-init-template-debian.sh
Last active April 16, 2024 18:47
create a Debian VM template for Proxmox VE
#!/bin/sh
# apt install curl
# obviously change this per your needs
VMID=9001
STOR=local-lvm
VER=20230124-1270
URL_PATH=https://cloud.debian.org/images/cloud/bullseye/$VER/
IMG=debian-11-genericcloud-amd64-$VER.qcow2
@Jimmy-Z
Jimmy-Z / ssh-agent-bridge-msys2-win32.js
Created December 5, 2019 04:09
bridge msys2/cygwin openssh to win32-openssh's ssh-agent, in node.js
/* fucking ssh-agent, again
we have at least 4 incompatible ssh-agents on windows
there're numerous bridging tools between them but for the love of God I couldn't find the one I need
this thing bridges msys2/cygwin openssh to win32-openssh's ssh-agent
probably the crudest thing you've ever seen, no error handling what-so-ever
if in any rare case you need this too, run this and:
`export SSH_AUTH_SOCK=$LOCALAPPDATA\\ssh-agent-sock`
@Jimmy-Z
Jimmy-Z / ba2totp.py
Created October 11, 2019 09:33
Blizzard Authenticator to TOTP convertor
#!/usr/bin/env python3
# distilled from https://github.com/jleclanche/python-bna
# only remain functionality is blizzard authenticator serial + restore code => TOTP secret conversion
# so you can use 3rd party TOTP applications
# contained in a single file so it could be audited easily and you don't have to use pip
# and support "CN-" serial courtesy of https://github.com/winauth/winauth/
import hmac
from base64 import b32encode
@Jimmy-Z
Jimmy-Z / services-start.sh
Created February 28, 2019 08:42
multi SSID with VLAN script, for ASUS AC86U with merlin
#!/bin/sh
# multi SSID with VLAN script, for ASUS AC86U with merlin
#
# setup before hand:
# set "router" to "AP Mode"
# this will put all ports and wireless in br0
# create 2 guest network
# enable Administration => System => Enable JFFS custom scripts and configs
# put this script in /jffs/scripts/, name should be "services-start"
#!/bin/sh
# call this in cron: /conf/pfsense-dnsmasq-cn.sh > /tmp/dnscn.debug 2>&1
# it would be nice if pfsense provided some kind of ppp post-up hook interface
PATH=/bin:/usr/bin:/usr/local/bin:/usr/local/sbin
WORKDIR="$(mktemp -d)"
OUTDIR="/conf/dnsmasq.d"
@Jimmy-Z
Jimmy-Z / rarbg.meta.js
Last active August 5, 2023 19:39
darken certain results on rarbg
// ==UserScript==
// @name rarbg
// @namespace https://github.com/Jimmy-Z/
// @version 0.2.0
// @description rarbg helper (for Movies/x264/1080 and TV HD Episodes)
// @author JimmyZ
// @match *://rarbg.to/torrent*
// @match *://proxyrarbg.org/torrent*
// @grant none
// @updateUrl https://gist.github.com/Jimmy-Z/f24d5a061ba0f7ad45641fd7ee53d819/raw/rarbg.meta.js
@Jimmy-Z
Jimmy-Z / spotlight-export.js
Created March 23, 2016 12:33
a node.js script to help you make more use of Windows 10 Spotlight lock screen images
/*
* a node.js script to help you make more use of Windows 10 Spotlight lock
* screen images.
*
* Usage:
* node spotlight-export.js <stage dir> <export dir>
*
* What it does:
* ---
* any image in spotlight dir but not in stage dir will be copied to stage dir