Skip to content

Instantly share code, notes, and snippets.

View fxfactorial's full-sized avatar
🎯
Focusing

@edgararout fxfactorial

🎯
Focusing
View GitHub Profile
@fxfactorial
fxfactorial / lvmrad.sh
Created December 28, 2023 20:27 — forked from ryandotsmith/lvmrad.sh
Setting up Ubuntu LVM Raid 0 with 4 NVMe M.2 Drives
lslbk # find drives to add (eg /dev/nvmeXn1)
pvcreate /dev/nvme1n1
pvcreate /dev/nvme2n1
pvcreate /dev/nvme3n1
pvcreate /dev/nvme4n1
vgcreate vg1 /dev/nvme1n1 /dev/nvme2n1 /dev/nvme3n1 /dev/nvme4n1
lvcreate --type=raid0 -l100%FREE -n rd1 vg1
mkfs.ext4 /dev/vg1/rd1
mkdir /storage #customize your mount point
echo '/dev/vg1/rd1 /storage ext4 defaults 0 0' >> /etc/fstab
@fxfactorial
fxfactorial / generic.org
Created December 8, 2023 15:56 — forked from hrkrshnn/generic.org
Some generic writeup about common gas optimizations, etc.

Upgrade to at least 0.8.4

Using newer compiler versions and the optimizer gives gas optimizations and additional safety checks for free!

The advantages of versions 0.8.* over <0.8.0 are:

  • Safemath by default from 0.8.0 (can be more gas efficient than some library based safemath).
  • Low level inliner from 0.8.2, leads to cheaper runtime gas. Especially relevant when the contract has small functions. For
@fxfactorial
fxfactorial / FileHandle+Z.swift
Created June 19, 2023 00:32 — forked from codelynx/FileHandle+Z.swift
enumerate lines from FileHandle (NSFileHandle) in swift3 – good for enumerating huge text file line by line
//
// FileHandle+Z.swift
// ZKit
//
// The MIT License (MIT)
//
// Copyright (c) 2016 Electricwoods LLC, Kaz Yoshikawa.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@fxfactorial
fxfactorial / logid.cfg
Created February 7, 2023 12:09 — forked from tsnieman/logid.cfg
Logiops (Linux driver) configuration example for Logitech MX Master 3. Includes gestures, smartshift, DPI. Tested on logid v0.2.2-35-g1c209ed. File location: `/etc/logid.cfg`
// Logiops (Linux driver) configuration for Logitech MX Master 3.
// Includes gestures, smartshift, DPI.
// Tested on logid v0.2.2-35-g1c209ed.
// File location: /etc/logid.cfg
devices: ({
name: "Wireless Mouse MX Master 3";
smartshift: {

Build in CMake with these params:

CMAKE_CXX_FLAGS:STRING= -fsanitize=address  -fsanitize=leak -g
CMAKE_C_FLAGS:STRING=-fsanitize=address  -fsanitize=leak -g
CMAKE_EXE_LINKER_FLAGS:STRING=-fsanitize=address  -fsanitize=leak
CMAKE_MODULE_LINKER_FLAGS:STRING=-fsanitize=address  -fsanitize=leak

Which can be done with:

use std::{
fs::File,
io::{Read, Write},
time::Instant,
};
use tokio::task::{self, JoinHandle};
async fn compute() {
let handles: Vec<JoinHandle<_>> = (0..1000)
.map(|_| {
@fxfactorial
fxfactorial / README.md
Created August 13, 2022 02:03 — forked from eduncan911/README.md
Fixing Thermal Throttling on Thinkpad P1 and X1 Extreme - Linux Edition

Fixing Thermal Throttling on Thinkpad P1 and X1 Extreme - Linux Edition

Lenovo messed up with the X1E and P1 Gen 1 versions (and maybe later generations) in that the system boots with a thermal limit (aka Tjunction or tjmax) set to 82C (some report 80C). What this means is that regardless of power draw or under-volting settings, when your CPU hits 82C, it will drop the frequency down to the "Configurable TDP-down" frequency, or even lower. It will also may limits the system power draw.

Thermal Paste and Stress Testing

@fxfactorial
fxfactorial / fix-broken-apt-get-update.sh
Created April 27, 2022 16:54 — forked from rashkopetrov/fix-broken-apt-get-update.sh
Fix `Error: Timeout was reached ` when doing `apt-get update`
#!/bin/bash
# source: https://www.linuxquestions.org/questions/debian-26/apt-get-update-gets-stuck-while-reading-package-list-on-my-slug-795324/
mv /var/lib/dpkg/status /var/lib/dpkg/status.broken.bak
cp /var/lib/dpkg/status-old /var/lib/dpkg/status
rm -rf /var/lib/apt/lists/*
dpkg --configure -a
aptitude update
aptitude upgrade
@fxfactorial
fxfactorial / example.go
Created February 14, 2022 16:22
ABI encode struct in golang
package main
import (
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
)