Skip to content

Instantly share code, notes, and snippets.

@jstaursky
jstaursky / keystone_assembler.py
Last active July 21, 2024 15:15
cmdline keystone assembler
#!/usr/bin/env python3
from keystone import *
import sys
import argparse
import binascii
def main(filename=None, raw=False):
if filename is None:
@jstaursky
jstaursky / c_pipes_ipc.cpp
Created October 11, 2023 01:40
linux pipes example
#include <iostream>
#include <sstream>
#include <cstdio>
#include <string>
#include <unistd.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>
# .tmux.conf
#
# hit C-a as the special tmux prefix then [ for visual mode.
# hit v and use the hjkl keys to select text you want to copy and then hit y to copy the selected text.
# The copied text will be available to the system clipboard.
#
# NOTE for copying to system clipboard xclip must be installed.
#
set -g status off
ACLOCAL_AMFLAGS = -I m4
AM_CPPFLAGS = -I$(top_srcdir)/include \
-I$(top_srcdir)/src
testprojectincludedir=$(includedir)/testproject
testprojectinclude_HEADERS=include/testproject/testproject.hpp
lib_LTLIBRARIES = libtestproject.la
libtestproject_la_SOURCES = src/testproject.cpp
@jstaursky
jstaursky / move_window_left_3rd.sh
Last active December 13, 2022 13:59
bash/zsh scripts to resize and move window apps.
#!/usr/bin/env zsh
# get size and position of window - terminal command: xwininfo
screen_width=3440
screen_height=1411
widthOneThird=$((screen_width/3))
# ### window position ###
# ______+x
@jstaursky
jstaursky / intrusive_list.cpp
Created September 14, 2022 13:00
intrusive linked list example
#include <iostream>
#include <cstring>
#include <string>
struct list_head {
struct list_head *next, *prev;
};
#define INIT_LIST_HEAD(ptr) do { \
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
@jstaursky
jstaursky / hexdump.cpp
Last active September 13, 2022 13:36
hexdump
#include <algorithm>
#include <cctype>
#include <cinttypes>
#include <cstdint>
#include <cstdio>
#include <iostream>
int main(int argc, char *argv[])
{
FILE *fp = stdin;
@jstaursky
jstaursky / alternate_impl.cpp
Last active July 22, 2022 15:34
_DESIGN_PATTERN_state
#include <iostream>
class Context; // fwd declare. User should only deal with the Context class.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class State
{
public:
State (Context *c) : ctx (c) {}
virtual ~State() {};
virtual void handle() = 0;
This file has been truncated, but you can view the full file.
00000000: 213c 6172 6368 3e0a 6465 6269 616e 2d62 !<arch>.debian-b
00000010: 696e 6172 7920 2020 3136 3438 3637 3132 inary 16486712
00000020: 3432 2020 3020 2020 2020 3020 2020 2020 42 0 0
00000030: 3130 3036 3434 2020 3420 2020 2020 2020 100644 4
00000040: 2020 600a 322e 300a 636f 6e74 726f 6c2e `.2.0.control.
00000050: 7461 722e 787a 2020 3136 3438 3637 3132 tar.xz 16486712
00000060: 3432 2020 3020 2020 2020 3020 2020 2020 42 0 0
00000070: 3130 3036 3434 2020 3236 3230 2020 2020 100644 2620
00000080: 2020 600a fd37 7a58 5a00 0004 e6d6 b446 `..7zXZ......F
00000090: 04c0 fa13 8050 2101 1600 0000 0000 0000 .....P!.........
// REQUIRES libuv
#include <assert.h>
#include <iostream>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <uv.h>
#include <string>
#include <string.h>