Skip to content

Instantly share code, notes, and snippets.

@jgarzik
jgarzik / patch
Created April 21, 2024 02:10
file(1) magic file patch
diff --git a/file/src/file.rs b/file/src/file.rs
index 39c0aeb..fadce24 100644
--- a/file/src/file.rs
+++ b/file/src/file.rs
@@ -25,6 +25,10 @@ use std::{
#[derive(Parser, Debug)]
#[command(author, version, about, long_about, disable_help_flag = true)]
struct Args {
+ /// Restore --help
+ #[arg(long, action = clap::ArgAction::HelpLong)]
@jgarzik
jgarzik / enum_grp3.rs
Created April 17, 2024 03:18
Enumerate groups, try 3 (working)
extern crate libc;
use libc::{endgrent, getgrent, setgrent, group};
use std::ffi::CStr;
use std::ptr;
struct Group {
name: String,
passwd: String,
gid: libc::gid_t,
members: Vec<String>,
@jgarzik
jgarzik / enum_grp1.rs
Created April 17, 2024 01:45
enumerate groups, Take One (chatGPT edition)
extern crate libc;
use libc::{group, setgrent, getgrent, endgrent, gid_t};
use std::ffi::CStr;
use std::ptr;
struct Group {
name: String,
passwd: String,
gid: gid_t,
members: Vec<String>,
@jgarzik
jgarzik / enum_grp2.rs
Created April 17, 2024 01:43
enumerage groups, Take Two
fn enumerate_groups() {
let mut groupent: *mut libc::group;
unsafe {
setgrent();
groupent = getgrent();
}
while groupent != ptr::null_mut() {
let c_str: &CStr = unsafe { CStr::from_ptr((*groupent).gr_name) };
println!("{}", c_str.to_str().unwrap());
unsafe {
@jgarzik
jgarzik / bip-blkv2.md
Created July 6, 2012 05:21
BIP XX: Block v2, Height in Coinbase

BIP XX: Block v2, Height in Coinbase

BIP: XX
Title: Block v2, Height in Coinbase
Author: Gavin Andresen <gavinandresen@gmail.com>
Status: Draft
Type: Standards Track
Created: 2012-07-06
@jgarzik
jgarzik / ron-shamir-review.md
Created October 16, 2012 20:51
Peer review of "Quantitative Analysis of the Full Bitcoin Transaction Graph"

This is a review of "Quantitative Analysis of the Full Bitcoin Transaction Graph" by Dorit Ron and Adi Shamir.

There are some incorrect details and analyses that warrant attention.

Oct. 31 UPDATE

The authors have introduced several revisions to their paper, available at the same URL as before.

The criticism below may be outdated in part or in full.

@jgarzik
jgarzik / opcount3.txt
Created July 26, 2012 05:54
bitcoin testnet3 opcode counts
OP_BOOLAND 4
OP_ENDIF 37
OP_8 3
OP_NOP1 3
OP_2DUP 6
OP_ROT 9
OP_4 13
OP_5 12
OP_6 5
OP_DEPTH 25
@jgarzik
jgarzik / boostgz.cc
Created May 17, 2012 04:03
Append a line of text to a gzip-compressed text file.
/*
Compile on Fedora 16 Linux:
g++ -O2 -Wall -g -o boostgz boostgz.cc -lboost_iostreams-mt
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fstream>
#include <iostream>
@jgarzik
jgarzik / opcount.txt
Created July 26, 2012 05:48
bitcoin opcode counts
OP_0 104
OP_1 27
OP_2 12
OP_2OVER 182
OP_2SWAP 182
OP_3 16
OP_4 1
OP_CHECKMULTISIG 22
OP_CHECKSIG 12188693
OP_CODESEPARATOR 14