Skip to content

Instantly share code, notes, and snippets.

View mepcotterell's full-sized avatar
💭
I may be slow to respond.

Michael Cotterell mepcotterell

💭
I may be slow to respond.
View GitHub Profile
@mepcotterell
mepcotterell / LICENSE
Last active August 19, 2023 16:44
Simple Python Plugin Manager
The MIT License (MIT)
Copyright (c) 2013 Michael E. Cotterell
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

%eflags

Flags

Flag Description
CF Carry Flag
PF Parity Flag
AF Adjust Flag
ZF Zero Flag
@mepcotterell
mepcotterell / README.md
Last active March 5, 2023 17:06
Implementing a Mutex

Implementing a Mutex

Use the following commands to compile and link the examples:

$ gcc -std=c17 -pedantic-errors -O0 -g -S mutex.c
$ as --gstabs -o mutex.o mutex.s 
$ gcc -o mutex mutex.o -lpthread

This implementation makes use of the C11 Atomic Operations Library.

@mepcotterell
mepcotterell / README.md
Last active July 27, 2022 02:09
Implementing a Semaphore

Implementing a Semaphore

Use the following commands to compile and link the examples:

$ gcc -std=c17 -pedantic-errors -O0 -g -S sem.c
$ as --gstabs -o sem.o sem.s 
$ gcc -o sem sem.o -lpthread

This implementation makes use of the C11 Atomic Operations Library.

Setup Oracle JDK 8 on MacOS

  1. Download the .dmg file for "macOS x64" here. Due to licensing, you will need to login to start the download. Creating an account is free.

  2. Install the JDK on your system by double clicking the .dmg file, then running the installer.

{
"@context": "https://schema.org/docs/jsonldcontext.json",
"@graph": [
{
"@id": "#issue4",
"@type": "PublicationIssue",
"datePublished": "2006-10",
"issueNumber": "4"
},
{
.rendered_html .text-muted {
color: #6c757d!important;
}
.rendered_html .lead {
font-size: 1.25rem;
font-weight: 300;
}
.rendered_html h1 a.anchor-link {
.bd-callout-info {
border-left-color: #5bc0de;
}
.bd-callout {
padding: 1.25rem;
margin-top: 1.25rem;
margin-bottom: 1.25rem;
border: 1px solid #eee;
border-left-width: .25rem;
@mepcotterell
mepcotterell / README.md
Last active July 14, 2020 17:28
Fun with tcpdump and hexdump...

Fun with tcpdump and hexdump

Here is some information that I've found/discovered from playing around with packets. The following is presented in an adhoc tutorial style. Hopepully you find it interesting.

tcpdump

Something that I found useful was the ability to actually capture the raw UDP packet using tcpdump utility. In the following example, we'll capture a DNS query packet and save it to a file.

Open up two terminal windows. In one window, type the following:

@mepcotterell
mepcotterell / Search.java
Created October 28, 2012 23:56
Generic Binary Search in Java
public class Search {
public static <T extends Comparable<T>> int binarySearch(T[] array, T value, int lo, int hi) {
if (lo < hi) {
int mid = (lo / 2) + (hi / 2);
int cmp = array[mid].compareTo(value);
if (cmp < 0) return binarySearch(array, value, lo, mid - 1);
if (cmp > 0) return binarySearch(array, value, mid + 1, hi);
return mid;
} // if