Skip to content

Instantly share code, notes, and snippets.

View micrypt's full-sized avatar

Seyi Ogunyemi micrypt

View GitHub Profile
@marceloalcocer
marceloalcocer / nat.sh
Created April 23, 2021 15:09
1:1 TCP NAT using nftables
#!/usr/bin/env bash
#
# 1:1 TCP NAT using nftables
#
# Implementation of 1:1 network address translation (NAT) between WAN/LAN
# on a Raspberry Pi 4B using nftables. NAT is performed;
#
# * for a single host on the LAN
# * for TCP traffic only
# * to specified ports on the LAN host

Viral Tracing Bluetooth Protocol

Background

  • We use [Ed25519] for creating digital signatures. Public keys are 32 bytes in length, and signatures are 64 bytes.

  • We will start out with support for BLE (Bluetooth Low Energy) and add support for older versions later.

@shaneutt
shaneutt / LICENSE
Last active May 14, 2024 15:02
Golang: Demonstrate creating a CA Certificate, and Creating and Signing Certs with the CA
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit

If .DS_Store was never added to your git repository, simply add it to your .gitignore file.

If you don't have one, create a file called

.gitignore

In your the root directory of your app and simply write

@rluts
rluts / token_auth.py
Last active October 13, 2023 20:56
Token authorization middleware for Django Channels 2
from channels.auth import AuthMiddlewareStack
from rest_framework.authtoken.models import Token
from django.contrib.auth.models import AnonymousUser
from django.db import close_old_connections
class TokenAuthMiddleware:
"""
Token authorization middleware for Django Channels 2
"""
@tricoder42
tricoder42 / 00_GraphQL_Subscriptions.md
Last active February 22, 2023 12:40
GraphQL Subscriptions with django-channels

GraphQL Subscription with django-channels

Django channels are official way for implementing async messaging in Django.

The primary caveat when working with GraphQL subscription is that we can't serialize message before broadcasting it to Group of subscribers. Each subscriber might use different GraphQL query so we don't know how to serialize instance in advance.

See related issue

@Ghosthree3
Ghosthree3 / vpnns.sh
Last active January 1, 2024 11:21
Script for setting up locked down Network Namespaces with a different VPN in each
#!/usr/bin/env bash
set -o pipefail
# This script sets up an additional network namespace for every VPN you wish so that you may
# use any VPN at any time for any program without tunneling everything else on your system.
# Usage:
# Review and edit every line of this script not in a function, then run it as root
# on system startup (yes every reboot), eg. crontab @reboot /root/bin/vpnns.sh
# It is recommended that you run this script manually at least once as you will
@crucialfelix
crucialfelix / graphql_auth.py
Created August 4, 2017 19:03
django-graphene auth decorator
from decorator import decorator
def _check_auth(args, pred):
_, _, context, _ = args
if not pred(context):
raise Exception("Unauthorized")
@decorator
def is_user(fn, *args, **kwargs):

Getting Started in Scala

This is my attempt to give Scala newcomers a quick-and-easy rundown to the prerequisite steps they need to a) try Scala, and b) get a standard project up and running on their machine. I'm not going to talk about the language at all; there are plenty of better resources a google search away. This is just focused on the prerequisite tooling and machine setup. I will not be assuming you have any background in JVM languages. So if you're coming from Python, Ruby, JavaScript, Haskell, or anywhere…  I hope to present the information you need without assuming anything.

Disclaimer It has been over a decade since I was new to Scala, and when I was new to Scala, I was coming from a Java and Ruby background. This has probably caused me to unknowingly make some assumptions. Please feel free to call me out in comments/tweets!

One assumption I'm knowingly making is that you're on a Unix-like platform. Sorry, Windows users.

Getting the JVM

@jasondavis
jasondavis / php_array_table.php
Created June 30, 2016 07:15
PHP Array to HTML Table
<?php
function html_table($data = array())
{
$rows = array();
foreach ($data as $row) {
$cells = array();
foreach ($row as $cell) {
$cells[] = "<td>{$cell}</td>";
}