Skip to content

Instantly share code, notes, and snippets.

@TwitchBronBron
TwitchBronBron / TrackDuration.ts
Last active December 21, 2023 16:19
TrackDuration
let durationSequence = 1;
function TrackDuration(options?: { enabled?: boolean; excludes?: Array<string> }) {
return function TrackDuration(target: any, propertyKey?: string, descriptor?: PropertyDescriptor) {
if (options?.enabled === false) {
return;
}
let methods: any[];
//is a method
if (propertyKey) {
methods.push(propertyKey);
@TwitchBronBron
TwitchBronBron / reboot.sh
Created September 27, 2023 02:11
reboot computer if network is unavailable
# Define the log file path
log_file="$(dirname "$0")/reboot.sh.log"
# Define a function to log messages with date stamps
log_message() {
local message="$1"
local timestamp=$(date +"%Y-%m-%d %H:%M:%S")
# Use tee to echo the message to both the console and the log file
echo "[$timestamp] $message" | tee -a "$log_file"
@TwitchBronBron
TwitchBronBron / ActionQueue
Created August 31, 2022 14:47
A typescript queue that runs async actions one at a time
/**
* Run one action at a time. Will run until all pending actions are complete.
*/
export class ActionQueue {
private queueItems: Array<{
action: () => Promise<any>;
resolve: (value: any) => void;
reject: (error: any) => void;
promise: Promise<any>;
}> = [];
@TwitchBronBron
TwitchBronBron / index.js
Created September 23, 2020 19:51
benchmark various for loop implementations
"use strict";
(function (factory) {
if (typeof Benchmark !== "undefined") {
factory(Benchmark);
} else {
factory(require("benchmark"));
}
})(function (Benchmark) {
var suite = new Benchmark.Suite;
@TwitchBronBron
TwitchBronBron / execute_stored_procedure.sql
Created December 17, 2019 16:01
How to execute a stored procedure in sqldeveloper
exec dbms_output.enable(10000);
SET SERVEROUTPUT ON;
var myCursor REFCURSOR;
begin
--Schema.Package.Procedure(Parameters);
SCHEMA_NAME.PACKAGE_NAME.PROCEDURE_NAME(10,'',:myCursor );
END;
/
@TwitchBronBron
TwitchBronBron / AppConfig.cs
Created October 3, 2019 17:15
dotnet framework base url
public class AppConfig
{
public string GetBaseUrl()
{
var req = HttpContext.Current.Request;
return $"{req.Url.Scheme}://{req.Url.Authority}{req.ApplicationPath.TrimEnd('/')}/";
}
}
@TwitchBronBron
TwitchBronBron / usersettings.json
Created May 10, 2019 18:08
Example of how to customize specific textmate rutes
//https://stackoverflow.com/questions/46034188/add-an-operator-to-visual-studio-code-theme-in-settings-json
{
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "keyword.operator.word",
"settings": {
"foreground": "#569BD2"
}
}
@TwitchBronBron
TwitchBronBron / clearCredentials.bat
Created February 27, 2019 13:13
A windows script to clear all windows credentials (uses powershell internally)
powershell -Command "cmdkey /list | ForEach-Object{if($_ -like '*Target:*' -and $_ -like '*'){cmdkey /del:($_ -replace ' ','' -replace 'Target:','')}}"
@TwitchBronBron
TwitchBronBron / Timer.cs
Created March 23, 2018 13:06
A simple timer for .net
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
public class Timer
{
public static List<Action> Callbacks = new List<Action>();
private static bool IsRunning = false;
public static void Register(Action callback)
@TwitchBronBron
TwitchBronBron / virtuawin.cfg
Last active September 27, 2018 10:42
virtuawin config file
ver# 2
hotkeyCount# 16
hotkey1# 49 1 7 1
hotkey2# 50 1 7 2
hotkey3# 51 1 7 3
hotkey4# 52 1 7 4
hotkey5# 81 1 7 5
hotkey6# 87 1 7 6
hotkey7# 69 1 7 7
hotkey8# 82 1 7 8