Skip to content

Instantly share code, notes, and snippets.

View mavam's full-sized avatar

Matthias Vallentin mavam

View GitHub Profile
@deanberris
deanberris / polymorphism-2.cpp
Created November 9, 2012 13:49
polymorphism-2
#include <iostream>
#include <memory>
#include <vector>
#include <utility>
/* Same definition of Object, Book, and Door as before */
class object_concept_t {
public:
virtual ~object_concept_t() = default;
@disnet
disnet / gist:4489250
Last active August 13, 2019 15:04
osx - force skim to always autoupdate
defaults write -app Skim SKAutoReloadFileUpdate -boolean true
@lava
lava / git_merge_cheatsheet.md
Created January 17, 2020 09:49
Git Merge Commit Cheatsheet

Git Merge Commit Cheatsheet

Show contents of merge commits in git log -p output:

git log -c

Show changes to current branch in the last 24 hours:

git rev-list --no-merges HEAD \

SSL Profiling in Bro

I wrote profiling applications over SSL recently and this is my attempt at doing so in Bro. I haven't written a Bro script before this one so I'm betting I've got a bunch of things wrong here. The code comes in two parts. The first is the main script which has the core logic. The second part is the "local" script which defines the application profiles you are interested in.

The Main Script

@load base/protocols/conn
@load base/protocols/ssl
@load base/frameworks/notice
@johnbaums
johnbaums / iwanthue.R
Last active June 7, 2020 22:48
Palettes of distinct colours, generated through kmeans clustering of LAB colour space
swatch <- function(x) {
# x: a vector of colours (hex, numeric, or string)
par(mai=c(0.2, max(strwidth(x, "inch") + 0.4, na.rm = TRUE), 0.2, 0.4))
barplot(rep(1, length(x)), col=rev(x), space = 0.1, axes=FALSE,
names.arg=rev(x), cex.names=0.8, horiz=T, las=1)
}
# Example:
# swatch(colours()[1:10])
# swatch(iwanthue(5))
@chadbrewbaker
chadbrewbaker / corelight-logs.schema.json
Created October 18, 2021 16:36
Latest Corelight schema - still beta, might be breaking changes
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "https://corelight.com/software-sensor.schema.json",
"title": "Corelight Logs",
"description": "Definition of all of the potential logs for this installation",
"$defs": {
"time": {"type": "string", "pattern": "[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-5][0-9]:[0-5][0-9]\\.?[0-9]{0,6}Z"},
"port": {"type": "integer", "minimum": 0, "maximum": 65535},
"count": {"type": "integer", "minimum": 0, "maximum": 18446744073709551615},
"int": {"type": "integer", "minimum": -9223372036854775807, "maximum": 9223372036854775807},
@lava
lava / tls_reverse_shell.md
Last active June 1, 2022 11:39
CI Debugging with a TLS reverse shell

Interactive Debugging on Github Actions

Did you ever run into some issue where a job would behave slightly different in you CI environment than on your local machine? Did you ever wish you could run just a few commands in a shell on your build machine?

These are, of course rhetorical questions. And if you're using Github Actions to run your CI jobs, you'll have noticed that this use case is not supported at all. There are some workarounds (e.g. https://github.com/nektos/act), but since they're not officially supported they can be a bit unstable. Also, even they usually don't reproduce the exact environment found on github's servers.

Minimal Reverse Shell

@doitian
doitian / Makefile
Last active December 9, 2022 02:31
Forward Makefile to subdirectory `build`
# List targets defined in this file
TARGETS_SELF := cmake
# Exclude targets defined in this file
TARGETS_OTHER := $(filter-out $(TARGETS_SELF), $(MAKECMDGOALS))
# Call all targets using `Makefile` in build directory in one `make` command. It
# can depend on targets defined in this file, e.g., depending on a target to
# create the Makefile.
#
# If no targets are specified, use the dummy `all` target
@NickSeagull
NickSeagull / cheatsheet
Created January 3, 2017 13:48
Cheatsheet for the fugitive.vim VIM-Madrid meetup
# Basic commands
:Git [args] # does what you'd expect
all of your `~/.gitconfig` aliases are available.
:Git! [args] # same as before, dumping output to a tmp file
Moving inside a repo.

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns                     on recent CPU
L2 cache reference ........................... 7 ns                     14x L1 cache
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns                     20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs 4X memory