Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <stdbool.h>
#include <string.h>
bool palendrome (char* const word)
{
size_t len = strlen (word);
char *start = word,
*end = start + len - 1;
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <vector>
using namespace std;
vector<bool> getbase2rep (uint64_t ninput)
{
vector<bool> result;
#include <stdio.h>
#include <stdint.h> // uint64_t
#include <stdlib.h> // realloc
#include <stdbool.h> // bool
// How to use:
// ./left2right_pow <num> <power>
typedef struct { bool* array; size_t size; } boolarray;
@jstaursky
jstaursky / Disassembler.c
Last active October 4, 2019 00:56
Bare bones linear disassembler
// Compile
// gcc -Wall Disassembler.c -lbfd -lcapstone -o Disassembler
// Usage
// ./Disassembler <binary>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h> // uint8_t, etc.
#include <inttypes.h> // PRI{fmt}{type}
#include <string.h>
#include <errno.h>
@jstaursky
jstaursky / mp3toYoutube.org
Last active November 19, 2019 21:12
Use ffmpeg to convert mp3 to youtube format

ffmpeg can be used to convert mp3’s into a format suitable for uploading to youtube. The following works best for me when converting class mp3 recordings to youtube.

ffmpeg -loop 1 -framerate 2 -i pic.png -i audio.mp3 -c:v libx264 -preset medium -tune stillimage -crf 18 -c:a aac -shortest -movflags +faststart -pix_fmt yuv420 -threads 16 output.mp4

Notes:

  • Might run into issues with pic.png (not 100% sure necessary to add a picture to fool youtube into thinking upload is a video) The issue will probably warn you about not being a multiple of 2 or something to that effect.
@jstaursky
jstaursky / Binary-Playground.org
Last active February 19, 2021 13:13
reverse-engineering

BINARY PLAYGROUND (LINUX IA32)

NOTE! some of this contains inaccurate material. In particular the “ROP” section while it does illustrate a facet of ROP it also does it in a way that does not go around Data Execution Prevention(DEP)–which is the entire point. I realized this after noticing that I had to add the following compiler flags in order to ensure DEP is enables -Wa,--noexecstack -z noexecstack. I have since updated the gcc command below but I also think it breaks the example. A will get around to fixing this at some point but a bit too busy atm. This page still contains some useful tidbits however, so I will keep it up in the meantime.

Below is my attempt to make as simple of a binary as possible for exploring.
I recommend playing using the setup found here (Not particularly useful for this binary anymore, (albeit I might add more features and this could be useful again in the

How to use different bibliography styles

This will depend on whether you want to use one of the bibtex styles or natbib styles or biblatex styles.

Using a bibtex style

This is the simplest as this was the original system the author of org-ref was targeting. The style of your references page can be selected using only the following.

bibliographystyle:<style>
bibliography:<biblio-file>.bib
;; Adapted from https://github.com/rurban/picat-lang/blob/master/picat-mode.el
;; mostly the same but this one works..
;;
(eval-when-compile
(require 'generic)
(require 'font-lock)
(require 'regexp-opt))
(defmacro picat-match-symbol (&rest symbols)
@jstaursky
jstaursky / gcc-info.org
Last active January 4, 2020 11:10
How to view gcc/g++ macros, search-paths, ...

How to view __cplusplus macro definition

g++ -x c++ -std=c++17 -dM -E - </dev/null | grep __cplusplus

useful for optioning c++17 features like so,

#if __cplusplus >= 201703L
        auto fsize = filesystem::file_size(argv[1]);
#else
        struct stat filestatus;
#!/bin/sh
# Useful for debugging a process that gets initialized from another process.
# credit to https://stackoverflow.com/questions/4382348/is-there-any-way-to-tell-gdb-to-wait-for-a-process-to-start-and-attach-to-it
progstr=$1
progpid=`pgrep -o $progstr`
while [ "$progpid" = "" ]; do
progpid=`pgrep -o $progstr`
done
gdb -ex 'break <function signature>' -ex 'starti' -p $progpid