Skip to content

Instantly share code, notes, and snippets.

View thanoskoutr's full-sized avatar

Thanos Koutroubas thanoskoutr

View GitHub Profile
@thanoskoutr
thanoskoutr / check-sha256sum-release.md
Created July 3, 2023 15:34
Compare the sha256sum of a Release from GitHub

About

When we download a release from any project on GitHub we need to verify the integrity of the downloaded artifact. That is way most project come with their SHA256 checksums file, that we can download and compare with the calculated SHA256 checksum of the downloaded artifact.

For example, to download the latest version (3.1.1) of openssl for a Linux 64-bit system and verify its integrity with the SHA256 checksum:

$ curl -OL "https://github.com/openssl/openssl/releases/download/openssl-3.1.1/openssl-3.1.1.tar.gz"
$ curl -OL "https://github.com/openssl/openssl/releases/download/openssl-3.1.1/openssl-3.1.1.tar.gz.sha256"
$ echo "$(cat openssl-3.1.1.tar.gz.sha256)" "openssl-3.1.1.tar.gz" | sha256sum --check
@thanoskoutr
thanoskoutr / jsonf.sh
Created February 16, 2023 12:08
JSON formatter in pure bash
#!/bin/bash
function jsonf() {
file=$1
indent=0
while IFS= read -r -n1 char; do
case $char in
("{" | "[") echo "$char"; ((indent+=4)); printf "%${indent}s";;
("}" | "]") echo ""; ((indent-=4)); printf "%${indent}s$char";;
(",") echo "$char"; printf "%${indent}s";;
(*) printf "%s" "$char";;
@thanoskoutr
thanoskoutr / squashfs-install.md
Last active May 19, 2024 03:14
Fix sasquatch installation for binwalk

Fix sasquatch installation for binwalk

For anynone that is running the latest version of binwalk (Binwalk v2.3.3) and when trying to extract squshfs filesystems, gets the following error:

WARNING: Extractor.execute failed to run external extractor 'sasquatch -p 1 -le -d 'squashfs-root' '%e'': [Errno 2] No such file or directory: 'sasquatch', 'sasquatch -p 1 -le -d 'squashfs-root' '%e'' might not be installed correctly

it might have to do that the sasquatch project is missing or not working correctly.

Install sasquatch

@thanoskoutr
thanoskoutr / download-latest-release.md
Last active August 25, 2022 14:46
Download Latest Release from GitHub

About

Download the latest release of a project for your architecture from any project on GitHub. The only thing you need to know is the project's name, owner and the naming convention for the releases.

For example, to download the latest version of chroma for a Linux 64-bit system:

$ TAG=$(curl -sS https://api.github.com/repos/alecthomas/chroma/releases/latest | jq -r '.tag_name')
$ curl -OL "https://github.com/alecthomas/chroma/releases/download/${TAG}/chroma-${TAG:1}-linux-amd64.tar.gz"

Another example, to download the latest version of protobuf for a Windows 64-bit system:

@thanoskoutr
thanoskoutr / print_array.py
Created April 23, 2021 22:47
A simple python program that initializes a list with 100 elements and prints it.
#!/usr/bin/python3
a = []
for i in range(0,100):
a.append(i)
for i in a:
print(i)
@thanoskoutr
thanoskoutr / print_array.js
Created April 23, 2021 22:42
A simple JavaScript program that initializes an array with 100 elements and prints it.
const a = [];
for (let i=0; i < 100; i++) {
a.push(i);
}
a.forEach(i => console.log(i))
@thanoskoutr
thanoskoutr / print_array.c
Last active April 23, 2021 23:08
A simple C program that initializes an array with 100 elements and prints it.
#include <stdio.h>
int main ()
{
int a[100];
for (int i = 0; i < 100; i++) {
a[i] = i;
}
for (int i = 0; i < 100; i++) {
printf("%d ", a[i]);
@thanoskoutr
thanoskoutr / word_count_pthreads.c
Created April 23, 2021 22:15
A word count tool that uses pthreads to perform parallel operation. Takes a file or a directory as argument.
#include <dirent.h>
#include <fcntl.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
@thanoskoutr
thanoskoutr / flask_mult_thread.py
Created April 23, 2021 22:10
A simple flask app with two endpoints to check the multithread performance of flask.
from flask import Flask, request, jsonify
from math import sqrt
app = Flask(__name__)
def successResponse():
return jsonify(success=True)
@thanoskoutr
thanoskoutr / users.sh
Created April 23, 2021 20:53
A simple script to list all users in a Linux system.
#!/bin/bash
if [[ "$1" == "-h" ]] ; then
echo "usage: `basename $0` [-h]"
echo "Prints all unix users."
exit 0
fi
cut -d: -f1 /etc/passwd