Skip to content

Instantly share code, notes, and snippets.

View SubOptimal's full-sized avatar
🤓
the joy of coding - happy hacking

Frank Dietrich SubOptimal

🤓
the joy of coding - happy hacking
View GitHub Profile
@SubOptimal
SubOptimal / last_five.py
Created March 2, 2024 20:51
Read last 5 lines from a file of any length
"""
Solution for the challenge https://mastodon.social/@willmcgugan/112025856092773557
How to execute:
1. the very first run of the script generates the example file with
10 million lines, of random lengths
2. drop file system caches [1]
echo 3 | sudo tee /proc/sys/vm/drop_caches
3. run the script to get the time it takes to read the last five lines from
the uncached file
@SubOptimal
SubOptimal / file-timestamps.log
Created December 20, 2022 22:07
Linux file timestamps - birth, atime, mtime, ctime
birth - created - touch
birth 2022-12-20 22:56:54.558640670 +0100
access 2022-12-20 22:56:54.558640670 +0100
modify 2022-12-20 22:56:54.558640670 +0100
change 2022-12-20 22:56:54.558640670 +0100
atime - accessed - cat
birth 2022-12-20 22:56:54.558640670 +0100
access 2022-12-20 22:56:55.570654581 +0100
@SubOptimal
SubOptimal / README.md
Last active September 22, 2024 14:58
create perspective screenshot

On Twitter, Will McGuan posted a perspective screenshot.

This gist provides few basic steps, using ImageMagick, to produce some similar looking.

Following steps were processed.

  • starting with a screenshot of the Rich CLI help in a terminal

image

@SubOptimal
SubOptimal / multicast-rcv.py
Created June 17, 2021 13:09 — forked from dksmiffs/multicast-rcv.py
Python 3 UDP multicast example, with only very minor modifications needed to this guidance: https://stackoverflow.com/a/1794373
# Multicast receiver
# Guidance: https://stackoverflow.com/a/1794373
import socket
import struct
MCAST_GRP = '224.1.1.1'
MCAST_PORT = 5007
IS_ALL_GROUPS = True
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
@SubOptimal
SubOptimal / HttpClient11.java
Last active April 2, 2019 19:49
HTTP 308 - permanent redirect and Java 11 client
/**
demo of Java 11 HttpClient
*/
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpClient.Redirect;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
@SubOptimal
SubOptimal / GitHub Flavored Asciidoc (GFA).adoc
Created February 8, 2019 14:07 — forked from dcode/GitHub Flavored Asciidoc (GFA).adoc
Demo of some useful tips for using Asciidoc on GitHub

GitHub Flavored Asciidoc (GFA)

@SubOptimal
SubOptimal / Tuples.java
Created November 30, 2018 09:11
tuples in Java streams
// as long answer to https://twitter.com/pivovarit/status/1067883547669815296
import java.lang.reflect.Field;
import java.util.Arrays;
class Tuples {
public static void main(String... args) throws NoSuchFieldException, IllegalAccessException {
new Tuples().exec();
}
@SubOptimal
SubOptimal / RomanNumber.java
Created March 8, 2018 23:33
roman numerals converter
import java.util.HashMap;
import java.util.Map;
public class RomanNumber {
static final Map<Character, Integer> ROMAN_NUMERALS;
static {
HashMap<Character, Integer> m = new HashMap<>();
m.put('I', 1);
@SubOptimal
SubOptimal / InterceptorThing.ps1
Created January 31, 2018 06:45
Interceptor - Normal User No Admin Required.
<#
.SYNOPSIS
This script demonstrates the ability to capture and tamper with Web sessions.
For secure sessions, this is done by dynamically writing certificates to match the requested domain.
This is only proof-of-concept, and should be used cautiously, to demonstrate the effects of such an attack.
Function: Interceptor
Author: Casey Smith, Twitter: @subTee
License: BSD 3-Clause