Skip to content

Instantly share code, notes, and snippets.

View joaomlneto's full-sized avatar

João Neto joaomlneto

View GitHub Profile
root@ubuntu:~# ./a.out
Reading 40 bytes:
Reading at malicious_x = 0xffffffffffdfeba8... Unclear: 0x54='T' score=980 (second best: 0x02 score=706)
Reading at malicious_x = 0xffffffffffdfeba9... Unclear: 0x68='h' score=929 (second best: 0x02 score=709)
Reading at malicious_x = 0xffffffffffdfebaa... Unclear: 0x65='e' score=973 (second best: 0x02 score=786)
Reading at malicious_x = 0xffffffffffdfebab... Unclear: 0x20=' ' score=928 (second best: 0x02 score=784)
Reading at malicious_x = 0xffffffffffdfebac... Unclear: 0x4D='M' score=746 (second best: 0x02 score=730)
Reading at malicious_x = 0xffffffffffdfebad... Unclear: 0x61='a' score=978 (second best: 0x02 score=749)
Reading at malicious_x = 0xffffffffffdfebae... Success: 0x67='g' score=39 (second best: 0x02 score=17)
Reading at malicious_x = 0xffffffffffdfebaf... Unclear: 0x69='i' score=972 (second best: 0x02 score=748)
@joaomlneto
joaomlneto / gist:50b5db37f36ea7117ad55df44f4c913f
Created April 11, 2018 23:23 — forked from psayre23/gist:c30a821239f4818b0709
Runtime Complexity of Java Collections
Below are the Big O performance of common functions of different Java Collections.
List | Add | Remove | Get | Contains | Next | Data Structure
---------------------|------|--------|------|----------|------|---------------
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array
LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array
@joaomlneto
joaomlneto / bibtex.png
Created April 29, 2018 18:48 — forked from max-mapper/bibtex.png
How to make a scientific looking PDF from markdown (with bibliography)
bibtex.png
@joaomlneto
joaomlneto / detect_worker_nodes.c
Last active October 20, 2018 00:19
Quirks of `mbind` `MPOL_INTERLEAVE`
#define _GNU_SOURCE
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <numa.h>
#include <numaif.h>
void printmask(char *name, struct bitmask *mask) {
printf("%s: ", name);
@joaomlneto
joaomlneto / boost_program_options_undecl_env.cpp
Last active May 17, 2023 09:34
Boost Program Options: ignore undeclared when reading environment variables
/* When using Boost's program_options to load environment variables,
* there is no way of telling boost to ignore those that were not
* specified in the `options_description` object.
*
* This snippet shows how to get similar behavior to the
* `allow_unregistered()` option available to command line and
* configuration file parsers.
*
*
* For example, if you try to read MYLIB_ONE by specifying an option
@joaomlneto
joaomlneto / gist:46f82b1f0ed5b4b0a6d0b3ec2ff4d0a5
Created January 2, 2019 15:18
Compile perf from Ubuntu source
################################################
# Stolen from Michal Fapso's answer: #
# https://stackoverflow.com/a/34061874/4288486 #
################################################
sudo apt-get install libiberty-dev binutils-dev
mkdir ~/install
cd ~/install
# If the following apt-get doesn't work on your system,
# uncomment deb-src lines in your /etc/apt/sources.list,
@joaomlneto
joaomlneto / how-to-install-latest-gcc-on-ubuntu-lts.txt
Created January 3, 2019 23:15 — forked from application2000/how-to-install-latest-gcc-on-ubuntu-lts.txt
How to install latest gcc on Ubuntu LTS (12.04, 14.04, 16.04)
These commands are based on a askubuntu answer http://askubuntu.com/a/581497
To install gcc-6 (gcc-6.1.1), I had to do more stuff as shown below.
USE THOSE COMMANDS AT YOUR OWN RISK. I SHALL NOT BE RESPONSIBLE FOR ANYTHING.
ABSOLUTELY NO WARRANTY.
If you are still reading let's carry on with the code.
sudo apt-get update && \
sudo apt-get install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
@joaomlneto
joaomlneto / mprotect_bench.c
Created February 12, 2019 13:05
mprotect benchmarks
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include <unistd.h>
#include <sys/mman.h>
#define SIZE (1ull<<35) // 32GB
#define N (SIZE/sizeof(uint64_t))
#define NTIMES 100
@joaomlneto
joaomlneto / signals.c
Created February 12, 2019 16:14
linux signals benchmarking
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include <unistd.h>
#include <signal.h>
#include <ucontext.h>
#include <fcntl.h>
#include <execinfo.h>
#include <sys/mman.h>
@joaomlneto
joaomlneto / mac-client.sh
Last active July 13, 2023 06:29
Fast NFS volume on macOS
#!/usr/bin/env bash
# mount /home/joaomlneto @ linux-vm
mkdir -p /Users/joaomlneto/nfs/linux-vm
mount -t nfs -o nolocks,locallocks,rw,soft,intr,rsize=8192,wsize=8192,timeo=900,retrans=3,proto=tcp \
linux-vm:/home/joaomlneto \
/Users/joaomlneto/nfs/linux-vm