Skip to content

Instantly share code, notes, and snippets.

View Warrenn's full-sized avatar

Warrenn Enslin Warrenn

  • Busyweb
  • South Africa
View GitHub Profile
@Warrenn
Warrenn / wrenchmonkey.js
Created January 29, 2021 16:20
Makes AWS automatically do a push on DUO
// ==UserScript==
// @name
// @version 1.0
// @description Makes AWS automatically do a push on DUO
// @match https://domain/console/
// @grant GM_addStyle
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require http://static-file-cdn.s3-website.us-east-2.amazonaws.com/js/waitForKeyElements.js
// ==/UserScript==
waitForKeyElements ("#wdc_mfa", actionFunction);
@Warrenn
Warrenn / GetCallingSourceType.cs
Last active January 26, 2021 10:35
stackTraceSource
private static Type GetCallingType()
{
var stack = new StackTrace();
var currentType = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType;
var callingType = currentType;
var frames = stack.GetFrames() ?? new StackFrame[] { };
foreach (var frame in frames)
{
var method = frame.GetMethod();
@Warrenn
Warrenn / dynamicBuilder.cs
Created December 15, 2020 12:35
dynamic type builder
using System;
using System.Reflection;
using System.Reflection.Emit;
namespace TypeBuilderNamespace
{
public static class MyTypeBuilder
{
public static void CreateNewObject()
{
public void InitializeDatabase(YourDbContext context)
{
if (!context.Database.Exists() || !context.Database.CompatibleWithModel(false))
{
var configuration = new DbMigrationsConfiguration();
var migrator = new DbMigrator(configuration);
migrator.Configuration.TargetDatabase = new DbConnectionInfo(context.Database.Connection.ConnectionString, "System.Data.SqlClient");
var migrations = migrator.GetPendingMigrations();
if (migrations.Any())
{
openssl s_client -connect 13.226.49.64:443 -servername api-help.rendrneuro.com
@Warrenn
Warrenn / decimaltoandfrom.cs
Created October 14, 2020 20:02
to and from decimal
int[] parts = Decimal.GetBits(value);
bool sign = (parts[3] & 0x80000000) != 0;
byte scale = (byte) ((parts[3] >> 16) & 0x7F);
Decimal newValue = new Decimal(parts[0], parts[1], parts[2], sign, scale);
@Warrenn
Warrenn / conv.sql
Created September 18, 2020 16:39
SQL UTF8
iconv -f utf-16 -t utf-8 sqlerrors.log > sqlerrors-utf8.log
@Warrenn
Warrenn / AddClientHeader.cs
Last active September 10, 2020 18:04
Add custom client interceptions for any client WebRequest
// <configuration>
// <system.net>
// <webRequestModules>
// <add prefix="http"
// type="UserAgentRequestCreator, namespace, Version=1.0.0.0,
// Culture=neutral, PublicKeyToken=9999999999999999"
// />
// </webRequestModules>
// </system.net>
// </configuration>
Path.GetFullPath(new Uri(Path.Combine(Environment.CurrentDirectory, @"..\..\")).LocalPath);
@Warrenn
Warrenn / locationofscript.sh
Created June 12, 2020 10:22
get the location of the script from wherever
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"