Skip to content

Instantly share code, notes, and snippets.

View struct's full-sized avatar

Chris Rohlf struct

View GitHub Profile
@struct
struct / dropbox_scraper.rb
Created April 23, 2011 02:23
dropbox IP scraper
## Disclaimer: This script sucks. It is a simple page
## scraper I wrote in about 10 minutes. Dropbox has no
## API calls for checking what IP addresses have accessed
## your Dropbox. When they change their website this
## script won't work anymore. It also requires curb
## which you can install with rubygems
## @chrisrohlf
require 'rubygems'
require 'curb'

Keybase proof

I hereby claim:

  • I am struct on github.
  • I am chrisrohlf (https://keybase.io/chrisrohlf) on keybase.
  • I have a public key whose fingerprint is DE1C 04BE 35F8 6A7A 66E2 9CDB D216 3C16 6C5A B908

To claim this, I am signing this object:

@struct
struct / pdfium_partitionalloc.patch
Created September 2, 2015 23:08
A patch to add support for PartitionAlloc in PDFIUM
diff --git a/core/include/fpdfapi/fpdf_objects.h b/core/include/fpdfapi/fpdf_objects.h
index c2d838d..099eb62 100644
--- a/core/include/fpdfapi/fpdf_objects.h
+++ b/core/include/fpdfapi/fpdf_objects.h
@@ -39,6 +39,22 @@ class IFX_FileRead;
class CPDF_Object {
public:
+
+#ifdef PDFIUM_PARTITIONALLOC
@struct
struct / partition_alloc_freelist_randomize_dbl_free.patch
Created January 9, 2016 21:47
PartitionAlloc randomization of the freelist and double free protection
diff --git a/PartitionAlloc.cpp b/PartitionAlloc.cpp
index 1215713..3b249e2 100644
--- a/PartitionAlloc.cpp
+++ b/PartitionAlloc.cpp
@@ -32,6 +32,7 @@
#include "PartitionAlloc.h"
#include <string.h>
+#include <vector>
@struct
struct / osquery_smaps.patch
Created August 7, 2016 20:16
Patches OSQuery with support for parsing smaps
diff --git a/osquery/tables/system/linux/processes.cpp b/osquery/tables/system/linux/processes.cpp
index c507b59..3005340 100644
--- a/osquery/tables/system/linux/processes.cpp
+++ b/osquery/tables/system/linux/processes.cpp
@@ -134,6 +134,63 @@ void genProcessEnvironment(const std::string& pid, QueryData& results) {
}
}
+// This constant may change between kernels
+#define SMAPS_FIELDS 19
@struct
struct / find_replace_iso_alloc.sh
Created April 23, 2020 03:00
Open every C source and header file in a directory and replace calls to system malloc with iso_alloc
#!/bin/bash
## See https://github.com/struct/isoalloc
find . -name "*.[c|h]" | xargs sed -i -e 's/ malloc(/ iso_alloc(/g' \
-e 's/ realloc(/ iso_realloc(/g' \
-e 's/ calloc(/ iso_calloc(/g' \
-e 's/ free(/ iso_free(/g' \
-e 's/ strdup(/ iso_strdup(/g' \
-e 's/ strndup(/ iso_strndup(/g'
@struct
struct / rptest.txt
Created December 1, 2021 04:01
rptest output under tsan
root@67dbecee929b:/# clang -o rptest *.c -lpthread -I. -ggdb -fsanitize=thread
root@67dbecee929b:/# ./rptest 2 0 1 2 500 1000 100 8 16000
crt 2 threads random linear size [8,16000] 500 loops 1000 allocs 100 ops: ==================
WARNING: ThreadSanitizer: data race (pid=17173)
Write of size 4 at 0x000000fec030 by main thread:
#0 benchmark_run /code/jmmb/mimalloc-bench/bench/rptest/rptest.c:777:19 (rptest+0x4b51b4)
#1 main /code/jmmb/mimalloc-bench/bench/rptest/rptest.c:901:9 (rptest+0x4b7ba8)
Previous read of size 4 at 0x000000fec030 by thread T1:
#0 benchmark_worker /code/jmmb/mimalloc-bench/bench/rptest/rptest.c:355:10 (rptest+0x4b5a34)
@struct
struct / gist:e45743aaedee4e0d6aab9ef37f5a9a22
Created November 26, 2022 02:10
GPT3 text-davinci-002 model explaining compiler and linker errors
;;; GPT-3 text-davinci-002 model explaining compiler and linker errors 11/25/2022
Explain the following C++ compiler error in plain english: " "std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)", referenced from:"
> The error is saying that the function std::endl is being called with the wrong number or type of arguments.
Explain the following C++ compiler error in plain english: " "error: expected primary-expression before ‘>’ token"
> This error means that the compiler was expecting a primary expression (a value, variable, or function) before it encountered the ">" token. This is likely due to a syntax error earlier in the code.