Skip to content

Instantly share code, notes, and snippets.

@alexeiz
alexeiz / borrow.cpp
Created February 22, 2023 05:42 — forked from foonathan/borrow.cpp
Quick'n'dirty implementation of Rust's borrow checker for a C++Now Lightning Talk - not supposed to be used
#include <iostream>
#include "borrow_checker.hpp"
int main()
{
auto i = 42;
// borrow `i` under name `ref`
borrow_var(ref, i)
@alexeiz
alexeiz / activity.py
Created September 22, 2018 04:33
Simulate desktop user activity
#!/usr/bin/env python
import sys
import pyautogui
from datetime import datetime, timedelta
pyautogui.FAILSAFE = False
def move_rel(dx, dy, dur):
pyautogui.moveRel(dx, dy, dur, pyautogui.easeInQuad)
@alexeiz
alexeiz / desktop_activity.py
Created April 13, 2018 02:45
Simulate desktop activity
#!/usr/bin/env python
import sys
import pyautogui
from datetime import datetime, timedelta
def move_rel(dx, dy, dur):
pyautogui.moveRel(dx, dy, dur, pyautogui.easeInQuad)
def square(side, dur):
@alexeiz
alexeiz / spectre.c
Created January 5, 2018 06:52 — forked from ErikAugust/spectre.c
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
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)
@alexeiz
alexeiz / avahi-browse.diff
Created July 31, 2017 05:38
Avahi-browse continue on error
diff --git a/avahi-utils/avahi-browse.c b/avahi-utils/avahi-browse.c
index 4101895..ab56eaa 100644
--- a/avahi-utils/avahi-browse.c
+++ b/avahi-utils/avahi-browse.c
@@ -375,8 +375,12 @@ static void browse_service_type(Config *c, const char *stype, const char *domain
service_browser_callback,
c))) {
- fprintf(stderr, _("avahi_service_browser_new() failed: %s\n"), avahi_strerror(avahi_client_errno(client)));
- avahi_simple_poll_quit(simple_poll);
@alexeiz
alexeiz / proc-affinity.sh
Created July 25, 2017 17:21
List affinities of process threads
#!/usr/bin/env bash
set -euo pipefail
[[ $# == 0 || $1 == '-h' ]] && {
bn=$(basename $0)
echo "$bn: list affinities of process threads"
echo "usage: $bn [pid|-p name]"
exit
}
@alexeiz
alexeiz / add_file_content.log
Last active June 9, 2017 05:43
Add a file content to a compiled binary to read at runtime.
$ cat myasmfile.S
.global MyAwesomeBinary, MyAwesomeBinaryEnd
.data
.align 8
MyAwesomeBinary:
.incbin "file.txt"
MyAwesomeBinaryEnd:
.zero 1
@alexeiz
alexeiz / pip-upgrade.sh
Created March 7, 2017 16:47
Upgrade outdated pip modules
#!/bin/sh
pip list --outdated --format=legacy | \
sed -E 's/^(\S+)(.*)$/\1/' | \
xargs pip install -U
@alexeiz
alexeiz / stones.py
Last active August 22, 2016 21:08
stones game
#!/usr/bin/env python3
from pprint import pprint
from copy import deepcopy
import functools
import sys
import re
def hash_game(game):
return game.get_hash()