Skip to content

Instantly share code, notes, and snippets.

View gordonglas's full-sized avatar

Gordon Glas gordonglas

View GitHub Profile
@gordonglas
gordonglas / backup-elden-ring.bat
Last active March 21, 2022 20:25
Backup "Elden Ring" save game folder to a specified location
: Backup "Elden Ring" save game folder to a specified location.
: Requires 7zip.
@echo off
set sevenZipExe=D:\Program Files\7-Zip\7z.exe
set erPath=%appdata%\EldenRing
set backupPath=D:\Users\gglas\Downloads\backup
set cwd=%cd%
@gordonglas
gordonglas / backup-por.bat
Created December 5, 2021 17:31
Windows batch file to backup Pool of Radiance and Gold Box Companion folders
: Backup "Pool of Radiance" and "GBC" (Gold Box Companion) root folders
: to a specified location.
: Requires 7zip.
@echo off
set sevenZipExe=D:\Program Files\7-Zip\7z.exe
set porPath=D:\Program Files (x86)\GOG Galaxy\Games\Pool of Radiance
set gbcPath=D:\Program Files (x86)\GBC
set backupPath=D:\Users\gglas\Downloads\backup
@gordonglas
gordonglas / win32_net.cpp
Last active April 1, 2022 18:37
win32 HTTP GET
#include "win32_net.h"
#include <windows.h>
#include <wininet.h>
#pragma comment (lib, "Wininet.lib")
#include <stdio.h>
#include <wchar.h>
#include <cwctype>
#include <algorithm>
@gordonglas
gordonglas / merge-json.cs
Created August 13, 2019 18:07
JSON.NET - Merge Json #json
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace CommonLib
{
public class JsonHelper
{
/*
string json = JsonHelper.MergeJson(null, @"{
'FirstName': 'John',
@gordonglas
gordonglas / aspnetcore-httpcontext-current.cs
Created August 3, 2019 13:53
ASP.NET Core HttpContext.Current #aspnetcore
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
namespace Common
{
public static class Services
{
@gordonglas
gordonglas / vanilla-ajax.js
Last active August 3, 2019 13:46
Javascript Ajax/Jsonp (no jquery) #js #ajax #jsonp
window.spAjax = (function () {
var that = {};
that.send = function (url, options) {
var onSuccess = options.onSuccess || function () { },
onError = options.onError || function () { },
onComplete = options.onComplete || function () { },
cache = options.cache || false;
if (!cache)
@gordonglas
gordonglas / t-sql-delete-sql-server-plan-cache.sql
Last active June 20, 2019 14:52
T-SQL Delete SQL Server plan cache #tsql
-- get plan_handle(s)
SELECT plan_handle, st.text
FROM sys.dm_exec_cached_plans
CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS st
where text like N'%#raw_searches_to_process%'
-- then pass plan_handle to:
DBCC FREEPROCCACHE (0x05000600AD74597D10E736078B02000001000000000000000000000000000000000000000000000000000000);
GO
DBCC FREEPROCCACHE (0x0600060066FD5913009C389C8C02000001000000000000000000000000000000000000000000000000000000);
@gordonglas
gordonglas / t-sql-chunked-delete-by-time-interval-with-sleep.sql
Created June 19, 2019 17:03
T-SQL chunked delete by time interval with sleep #tsql
/*
Need to delete certain rows out of raw_event table.
but raw_event table is partitioned by timestamp and contains a ton of data,
so need to do chunked deletes by small intervals of the partition key (timestamp)
Will try 1 min intervals.
*/
set nocount on;
set transaction isolation level read uncommitted;
@gordonglas
gordonglas / t-sql-chunked-delete-by-id-with-sleep.sql
Created June 19, 2019 15:59
T-SQL chunked delete by id with sleep #tsql
set nocount on;
set transaction isolation level read uncommitted;
DECLARE @rows_processed INT = 0
DECLARE @row_count INT = 0
DECLARE @max_rows bigint = 1000
-- get bounds
declare @min_id bigint
select @min_id = min(upload_raw_event_id) from raw_data..upload_raw_event (nolock) where event_name = 'update-regex-hit'