Skip to content

Instantly share code, notes, and snippets.

View willeccles's full-sized avatar
🖤
probably out driving

Will Eccles willeccles

🖤
probably out driving
View GitHub Profile
@willeccles
willeccles / __cplusplus values.md
Last active March 25, 2024 23:38
__cplusplus values for each C++ standard version

__cplusplus Values

Since it's impossible to find one concise source anywhere, as far as I can tell:

ISO C++ Standard Value
1998/2003 199711L
2011 201103L
2014 201402L
2017 201703L
@marcan
marcan / m1cat.c
Last active October 26, 2023 15:42
m1cat: a PoC for the M1RACLES covert channel vulnerability in the Apple M1
/*
* m1cat: a proof of concept for the M1RACLES vulnerability in the Apple M1.
*
* This program implements a covert channel that can be used to transmit data
* between two processes when run on the Apple Silicon "M1" CPUs.
*
* The channel is slightly lossy due to (presumably) the scheduler sometimes
* scheduling us on the wrong CPU cluster, so this PoC sends every byte twice
* together with some metadata/framing bits, which is usually good enough.
* A better approach would be to use proper FEC or something like that.
@willeccles
willeccles / shellandc.c
Last active February 24, 2023 01:52
A C program which is also a valid bash script, and vice versa.
#include <stdio.h>
#define $x ,x
#define $i ,i
#define eval int
#define read scanf
#define $scanfpat "%d", &
#define $(x) ,(x)
#define $open (
#define $close )
#define do {
/* Compile with -DUSE_READLINE and -lreadline to use readline for input. */
#include <arpa/inet.h>
#include <errno.h>
#include <poll.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active May 3, 2024 06:43
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@willeccles
willeccles / oodle.cpp
Created October 13, 2016 03:00
Replaces every vowel in given phrase(s) with "oodle"
// compile with:
// g++ oodle.cpp -o oodle -std=c++14
#include <iostream>
#include <string>
#include <regex>
#include <vector>
int main(int argc, char* argv[]) {
if (argc == 1) {
@CaBra503
CaBra503 / git-cheat-sheet.md
Created December 23, 2015 01:58 — forked from iansheridan/git-cheat-sheet.md
A cheat sheet for GIT

Setup

git clone <repo>

clone the repository specified by ; this is similar to "checkout" in some other version control systems such as Subversion and CVS

Add colors to your ~/.gitconfig file:

@willeccles
willeccles / methoding.java
Last active August 26, 2015 22:00
an even better way to pass methods as parameters
public static void main(String[] args) {
// this uses a java 8 feature called method references (i think)
// it looks for method "aThingToDo" in class "methoding" (the name of this class)
// aThingToDo must match the pattern, as doAThing says
doAThing(methoding::aThingToDo);
}
// define a pattern for what type of method we want
// we want a method with String s as input and no return (void)
public interface voidMethod {
@willeccles
willeccles / pass a method to a method.java
Created August 14, 2015 22:48
This is how to pass a method to another method in Java 8+.
// while this is not technically a method, a Runnable is close enough for me.
// this method wants a "method" as an input
void canHazMethod(Runnable methodToRun) {
// run the method passed in
methodToRun.run();
}
// this is the method I will use:
Runnable myMethod = () -> {
@need12648430
need12648430 / name.js
Last active December 30, 2022 17:45
Pronounceable Seeded Name Generator
function name (id, l) {
function n(){return id=(399*id)%509}
var r="BDGKNPTVZ"[n()%9]
for (var i=1;i<l;i++) r+=i%2?"aeiou"[n()%5]:"bdgknptvz"[n()%9]
return r
};
// id=seed, l=length
function name (id, l) {
// lcg prng