Skip to content

Instantly share code, notes, and snippets.

💭
Head in yesterday. Hands in today. Heart in tomorrow.

Dustin Oprea dsoprea

💭
Head in yesterday. Hands in today. Heart in tomorrow.
Block or report user

Report or block dsoprea

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dsoprea
dsoprea / ssl_nonblocking_client.c
Created Jan 24, 2019
Non-Blocking SSL Client
View ssl_nonblocking_client.c
//============================================================================
// Name : SSLClient.cpp
// Compiling : g++ -c -o SSLClient.o SSLClient.cpp
// g++ -o SSLClient SSLClient.o -lssl -lcrypto
//============================================================================
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <openssl/ssl.h>
@dsoprea
dsoprea / ssl_server_nonblock.c
Created Jan 24, 2019 — forked from darrenjs/ssl_server_nonblock.c
OpenSSL example using memory BIO with non-blocking socket IO
View ssl_server_nonblock.c
/*
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 / ldap_lookup_with_python.py
Last active Jun 23, 2018
LDAP Lookups Against Active Directory with Python
View ldap_lookup_with_python.py
import logging
import ldap
import collections
# Install:
#
# apt: libsasl2-dev
# pip: python-ldap
#
@dsoprea
dsoprea / strip_extended.py
Created May 22, 2018
Tool to recursively strip all extended characters from all non-hidden files
View strip_extended.py
#!/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():
@dsoprea
dsoprea / git_squash_last.sh
Created May 4, 2018
Script to squash the last Git commit
View git_squash_last.sh
#!/bin/bash -e
HEAD_COMMIT_MESSAGE=$(git log --format=%B -1 HEAD)
# For safety. Our use-case is usually to always just squash into a commit
# that's associated with an active change. We really don't want lose our head
# and accidentally squash something that wasn't intended to be squashed.
if [[ "${HEAD_COMMIT_MESSAGE}" != SQUASH* ]]; then
echo "SQUASH: Commit to be squashed should have 'SQUASH' as its commit-message."
exit 1
@dsoprea
dsoprea / resolve_go_import_url.py
Last active Nov 29, 2016
Resolve a Go import path to the actual URL that hosts that package
View resolve_go_import_url.py
#!/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
@dsoprea
dsoprea / mssql_encryption_backup_restore_encrypt_test.sql
Last active Nov 17, 2016
SQL Server: Backup and Restore Credentials, and Test Encryption
View mssql_encryption_backup_restore_encrypt_test.sql
-- To run this script more than once, make sure to delete c:\temp\test.dmk,
-- c:\temp\test.smk, c:\temp\test.crt, and c:\temp\test.crt.key .
DECLARE @ExpectedSignature VARBINARY(8000);
DECLARE @ActualSignature VARBINARY(8000);
DECLARE @Encrypted VARBINARY(8000);
DECLARE @Decrypted VARBINARY(8000);
DECLARE @TestString VARCHAR(100) = 'protected string';
@dsoprea
dsoprea / Program.cs
Last active Oct 17, 2016
C# code for the properties that can retrieve the version embedded in the executable: http://wp.me/p3Uuaw-Hj
View Program.cs
class Program
{
private string executableVersion = null;
private string ExecutableVersion
{
get
{
if (executableVersion == null)
{
@dsoprea
dsoprea / build.targets
Last active Oct 17, 2016
build.targets file for injecting version from a text-file to the AssemblyInfo.cs file: http://wp.me/p3Uuaw-Hj
View build.targets
<?xml version="1.0" encoding="utf-8" ?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Inject a version from a text-file into AssemblyVersion.cs . We do this
so that it's easier for the application to know its own version [by
reading the text file].
-->
<Import Project="$(ProjectDir)..\packages\MSBuildTasks.1.5.0.196\tools\MSBuild.Community.Tasks.Targets" />
<Target Name="InjectVersion" BeforeTargets="BeforeBuild">
<!-- Read the version from our text file. This appears to automatically
@dsoprea
dsoprea / Vagrantfile
Created Aug 2, 2016
Importing fully-qualified "appengine" package causes unsafe/syscall errors
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
$script = <<SCRIPT
apt-get update
apt-get install -y unzip git
wget -nv https://storage.googleapis.com/appengine-sdks/featured/go_appengine_sdk_linux_amd64-1.9.40.zip
You can’t perform that action at this time.