Skip to content

Instantly share code, notes, and snippets.

View duaneking's full-sized avatar
🏡
Working From Home. Code. Love. Defend.

Duane King duaneking

🏡
Working From Home. Code. Love. Defend.
View GitHub Profile
@duaneking
duaneking / vicsek.py
Created April 24, 2024 20:22 — forked from arshednabeel/vicsek.py
A minimal implementation of the Vicsek model in ~50 lines of code
import numpy as np
from tqdm import trange
def get_neighbour_matrix(x, L, R):
dx = np.subtract.outer(x[:, 0], x[:, 0])
dy = np.subtract.outer(x[:, 1], x[:, 1])
dx[dx > (L / 2) ** 2] -= (L / 2) ** 2
dy[dy > (L / 2) ** 2] -= (L / 2) ** 2
pair_dist = dx ** 2 + dy ** 2
@duaneking
duaneking / derp.cs
Created April 26, 2023 15:35
Auth in old Versions of ASP.Net
// https://stackoverflow.com/questions/31464359/how-do-you-create-a-custom-authorizeattribute-in-asp-net-core?rq=1
public class ClaimRequirementAttribute : TypeFilterAttribute
{
public ClaimRequirementAttribute(string claimType, string claimValue) : base(typeof(ClaimRequirementFilter))
{
Arguments = new object[] {new Claim(claimType, claimValue) };
}
}
@duaneking
duaneking / ubuntu-eol.md
Created March 17, 2023 18:04 — forked from dergachev/ubuntu-eol.md
What to do when your ubuntu distro is End-of-Life

Let's say you're using Ubuntu 13.04 (Raring Ringtail, released in April 2013) and it just went End-of-Life on you, because it's supported for only 6 months, and the deprecated packages are taken down after 12 months.

You'll probably figure this out the hard way. When you run sudo apt-get update, it will eventually report these errors:

Ign http://archive.ubuntu.com raring-updates/universe Sources/DiffIndex
Err http://security.ubuntu.com raring-security/main Sources
  404  Not Found [IP: 91.189.91.15 80]
Err http://security.ubuntu.com raring-security/universe Sources
  404  Not Found [IP: 91.189.91.15 80]
@duaneking
duaneking / main_test.go
Created October 26, 2022 02:06
The best way I have found to test Gin Endpoints in GO-Lang, end to end, I'n a simple and easy to maintain way. I'm doing this pattern + dependency injection + the repository design pattern with data driven and seeded tests on every build.
package main
import (
"fmt"
"io"
"net/http"
"net/http/httptest"
"strings"
"testing"
@duaneking
duaneking / Base64_CheatSheet.md
Created March 8, 2022 20:32 — forked from Neo23x0/Base64_CheatSheet.md
Learning Aid - Top Base64 Encodings Table

Learning Aid - Top Base64 Encodings Table

Base64 Code Mnemonic Aid Decoded* Description
JAB 🗣 Jabber $. Variable declaration (UTF-16)
TVq 📺 Television MZ MZ header
SUVY 🚙 SUV IEX PowerShell Invoke Expression
SQBFAF 🐣 Squab favorite I.E. PowerShell Invoke Expression (UTF-16)
SQBuAH 🐣 Squab uahhh I.n. PowerShell Invoke string (UTF-16) e.g. Invoke-Mimikatz
PAA 💪 "Pah!" <. Often used by Emotet (UTF-16)
@duaneking
duaneking / falsehoods-programming-time-list.md
Created January 16, 2022 19:16 — forked from timvisee/falsehoods-programming-time-list.md
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
export const createSharedStore = (modules) => {
return new createStore(
{
plugins: [
createPersistedState(
{
paths: Object.entries(modules).map(
(
[
moduleName,
@duaneking
duaneking / js_h2o_widget.js
Created October 18, 2021 05:35
JS h2o widget - hydrate initialized
/*
MIT License
Copyright (c) 2021 Duane F. King (https://www.duanefking.com)
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
@duaneking
duaneking / clouds.md
Created September 4, 2021 04:12 — forked from miglen/clouds.md
AWS & GCP explained in simple English

Amazon Web Services (AWS) & Google Cloud Platform (GCP) explained in simple English

This guide is only representative from my point of view and it may not be accurate and you should go on the official AWS & GCP websites for accurate and detailed information. It's initially inspired by AWS in simple English and GCP for AWS professionals. The idea is to compare both services, give simple one-line explanation and examples with other software that might have similiar capabilities. Comment below for suggestions.

Category Service AWS GCP Description It's like
Compute IaaS Amazon Elastic Compute Cloud (EC2) Google Compute Engine Type-1 virtual servers VMware ESXi, Citrix XenServer
  PaaS AWS Elastic Beanstalk Google App Engine Running your app on a platform
@duaneking
duaneking / c99.l
Created June 4, 2017 03:31 — forked from codebrainz/c99.l
C99 Lex/Flex & YACC/Bison Grammars
D [0-9]
L [a-zA-Z_]
H [a-fA-F0-9]
E ([Ee][+-]?{D}+)
P ([Pp][+-]?{D}+)
FS (f|F|l|L)
IS ((u|U)|(u|U)?(l|L|ll|LL)|(l|L|ll|LL)(u|U))
%{
#include <stdio.h>