Skip to content

Instantly share code, notes, and snippets.

View dsoprea's full-sized avatar
💭
Head in yesterday. Hands in today. Heart in tomorrow.

Dustin Oprea dsoprea

💭
Head in yesterday. Hands in today. Heart in tomorrow.
View GitHub Profile
@dsoprea
dsoprea / assert_yaml_uniqueness.py
Last active January 13, 2024 09:32
Assert Uniqueness In YAML dictionaries using PyYAML
import yaml
def load_and_assert_uniqueness(x):
# We'd like to detect duplicates. Since PyYAML both loads things depth-first
# *and* doesn't give us the parent when processing a child node, we'll index
# of all of the object IDs as we're constructing them, and then see which
# are disappeared from the final hierarchy. Since all we can do is pass a
# class, we need to inline the class in order to load into an index within
# our scope.
@dsoprea
dsoprea / ldap_lookup_with_python.py
Last active June 23, 2018 18:51
LDAP Lookups Against Active Directory with Python
import logging
import ldap
import collections
# Install:
#
# apt: libsasl2-dev
# pip: python-ldap
#
@dsoprea
dsoprea / strip_extended.py
Created May 22, 2018 01:08
Tool to recursively strip all extended characters from all non-hidden files
#!/usr/bin/env python3
import sys
import os
import argparse
import shutil
_DESCRIPTION = "Strip extended characters from all non-hidden files in a path."
def _get_args():
@emmanueltissera
emmanueltissera / git-apply-patch.md
Created September 13, 2017 02:34
Generate a git patch for a specific commit

Creating the patch

git format-patch -1 <sha>
OR
git format-patch -1 HEAD

Applying the patch

git apply --stat file.patch # show stats.
git apply --check file.patch # check for error before applying

@darrenjs
darrenjs / ssl_server_nonblock.c
Last active March 22, 2024 08:34
OpenSSL example using memory BIO with non-blocking socket IO
/*
This file had now been added to the git repo
https://github.com/darrenjs/openssl_examples
... which also includes a non blocking client example.
-------------------------------------------------------------------------------
ssl_server_nonblock.c -- Copyright 2017 Darren Smith -- MIT license
@dsoprea
dsoprea / resolve_go_import_url.py
Last active November 29, 2016 17:15
Resolve a Go import path to the actual URL that hosts that package
#!/usr/bin/env python3.5
"""
A simple module to resolve a Go import path to the actual URL that hosts that
package. Sometimes these are not equal and you mustload one URL (and zero or
more redirects) until we encounter a meta tag that specifies the true import
URL.
Requirements:
- requests
- beautifulsoup4
@rogerbush8
rogerbush8 / install-libreswan-ipsec-vpn-regional-vpc-tunnel-on-aws-ec2_aws_linux_ami_201409
Last active April 3, 2022 18:17
install-libreswan-ipsec-vpn-regional-vpc-tunnel-on-aws-ec2_aws_linux_ami_201409
#!/bin/sh
#
# Shell script for installation and setup of L2TP/IPsec VPN tunnel in site-to-site
# mode (e.g. connecting two inter-regional VPCs). VPN software is libreswan.
#
# This should work on linux systems that are RHEL based.
#
# To install directly from this gist, you can curl the "raw" version and pipe that to
# "bash -s" while also defining the environment variables:
#
@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@GraxRabble
GraxRabble / sodium_demo.c
Last active October 28, 2018 03:33
This c file demostrates how to use each libsodium functions and lets you play with them to see their outputs.
/*
* GraxRabble
* 04 MAY 2014
* Note this was created for the 4.5 version of libSodium.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sodium.h" /* library header */