Skip to content

Instantly share code, notes, and snippets.

View jack-pappas's full-sized avatar

Jack Pappas jack-pappas

  • Philadelphia, PA, USA
View GitHub Profile
@pervognsen
pervognsen / shift_dfa.md
Last active January 27, 2024 19:54
Shift-based DFAs

A traditional table-based DFA implementation looks like this:

uint8_t table[NUM_STATES][256]

uint8_t run(const uint8_t *start, const uint8_t *end, uint8_t state) {
    for (const uint8_t *s = start; s != end; s++)
        state = table[state][*s];
    return state;
}
import sys
from ctypes import POINTER, py_object, Structure, c_ssize_t, c_void_p, sizeof
from typing import Any, Iterator, Optional, Sequence, Union
__all__ = ("OpStack", )
class Frame(Structure):
_fields_ = (
@davidfowl
davidfowl / Example1.cs
Last active March 28, 2024 20:36
How .NET Standard relates to .NET Platforms
namespace Analogy
{
/// <summary>
/// This example shows that a library that needs access to target .NET Standard 1.3
/// can only access APIs available in that .NET Standard. Even though similar the APIs exist on .NET
/// Framework 4.5, it implements a version of .NET Standard that isn't compatible with the library.
/// </summary>INetCoreApp10
class Example1
{
public void Net45Application(INetFramework45 platform)
@tanb
tanb / xhyve-freebsd-tutorial-1.md
Last active November 27, 2021 13:07
FreeBSD running on xhyve tutorial. (Appendix: Resize image with qemu. Create FreeBSD VM with qemu).

TL;DR

  • Create 5GB FreeBSD image.
  • Install FreeBSD on xhyve.
  • Mount host directory.

Requisites

@fginter
fginter / test_sm.py
Created May 19, 2014 14:05
test of shared memory array / numpy integration
import multiprocessing
import numpy
#Demonstrates shared memory numpy arrays with no synchronization between processes
def increment(s_arr):
#A function for a single process
#increment every element in s_arr by 1.0
#s_arr is a shared array from multiprocessing
@pabigot
pabigot / rotate.cc
Created November 19, 2013 18:52
C++11 template function to perform integer rotations without invoking undefined behavior. See http://blog.regehr.org/archives/1063
/* See http://blog.regehr.org/archives/1063
*/
#include <type_traits>
#include <cstdint>
#include <limits>
#include <typeinfo>
#ifndef ARGTYPE
#define ARGTYPE uint32_t
#endif /* ARGTYPE */
@axefrog
axefrog / 0.suffixtree.cs
Last active July 12, 2023 01:01
C# Suffix tree implementation based on Ukkonen's algorithm. Full explanation here: http://stackoverflow.com/questions/9452701/ukkonens-suffix-tree-algorithm-in-plain-english
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace SuffixTreeAlgorithm
{
public class SuffixTree
{