Skip to content

Instantly share code, notes, and snippets.

View fxfactorial's full-sized avatar
🎯
Focusing

@edgararout fxfactorial

🎯
Focusing
View GitHub Profile

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"
)
@fxfactorial
fxfactorial / extract_top_peers.py
Created February 4, 2022 02:47 — forked from bogatyy/extract_top_peers.py
Extract top peers
from collections import defaultdict
GETH_LOGFILE = 'geth-log.txt'
def extract_parameter(source_str, before_str, after_str):
start_pos = source_str.find(before_str) + len(before_str)
return source_str[start_pos:source_str.find(after_str, start_pos)]
@fxfactorial
fxfactorial / ECDSA.sol
Created January 28, 2022 18:45 — forked from BjornvdLaan/ECDSA.sol
Verification of externally created ECDSA signatures in Solidity
pragma solidity ^0.4.24;
contract ECDSA {
function verify() public returns (bool) {
bytes32 message = ethMessageHash("TEST");
bytes memory sig = hex"bceab59162da5e511fb9c37fda207d443d05e438e5c843c57b2d5628580ce9216ffa0335834d8bb63d86fb42a8dd4d18f41bc3a301546e2c47aa1041c3a1823701";
address addr = 0x999471bb43b9c9789050386f90c1ad63dca89106;
@fxfactorial
fxfactorial / StableSwapAaveGetter.sol
Created December 2, 2021 16:56
StableSwapAaveGetter contract mock up
pragma solidity ^0.7.6;
interface IStableSwapAave {
function A_precise() external view returns (uint256);
function balances(uint256 i) external view returns (uint256);
function underlying_coins(uint256 arg0) external view returns (address);
function admin_balances(uint256 arg0) external view returns (uint256);
@fxfactorial
fxfactorial / eth_call.js
Created October 14, 2021 13:04 — forked from RomanFro/eth_call.js
eth_call
'use strict';
const WEB3_URL = process.env.WEB3_URL;
const prom = require('util').promisify;
const ethABI = require('ethereumjs-abi');
const Web3 = require('web3');
const provider = new Web3.providers.HttpProvider(WEB3_URL);
const web3 = module.exports = new Web3(provider);
const sendAsync = prom(web3.currentProvider.sendAsync).bind(web3.currentProvider);