Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View alanedwardes's full-sized avatar
👋

Alan Edwardes alanedwardes

👋
View GitHub Profile
@alanedwardes
alanedwardes / create_playlist.py
Created April 20, 2024 23:10
Create a simple .m3u file from a folder heirarchy
import os
import sys
import pathlib
if len(sys.argv) < 2:
print("Error - pass the folder(s) you want to index as argument(s)")
exit(1)
directories = sys.argv[1:]
@alanedwardes
alanedwardes / collector.py
Last active May 25, 2021 21:35
Uses the Pimoroni enviroplus board to capture statistics every second, update the screen and send them to a Graphite installation
#!/usr/bin/env python3
import graphyte
import time
import colorsys
import sys
import ST7735
try:
# Transitional fix for breaking change in LTR559
from ltr559 import LTR559
@alanedwardes
alanedwardes / Program.cs
Last active January 26, 2020 14:06
Parse the UE4 Vault API to catalogue it in a spreadsheet (exports the JSON -> CSV)
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace UnrealVaultParser
{
class Program
{
// Checkout and store away result
def checkoutResult = scm checkout
// Build a human readable build label
def buildLabel = [env.EstPlatform, checkoutResult.GIT_COMMIT.substring(0, 6), env.JOB_NAME, env.BUILD_NUMBER].join('-')
// Stamp the build config header file
def configFile = 'Depot/Source/EstCore/EstBuildConfig.h'
def buildConfig = readFile file: configFile
buildConfig += '\n#undef BUILD_COMMIT'
@alanedwardes
alanedwardes / EstScreenshotTaker.cpp
Created December 20, 2017 00:11
Unreal Engine 4 class to take and compress screenshots to a JPEG image, then raise an event with the compressed data.
// Estranged is a trade mark of Alan Edwardes.
#include "EstScreenshotTaker.h"
#include "IImageWrapper.h"
#include "IImageWrapperModule.h"
void UEstScreenshotTaker::RequestScreenshot()
{
if (GEngine == nullptr || GEngine->GameViewport == nullptr || bIsScreenshotRequested)
{
@alanedwardes
alanedwardes / EstPlayer.cpp
Last active March 27, 2022 02:09
A client-side smooth crouching implementation for Unreal Engine 4.
void AEstPlayer::Tick(float DeltaSeconds)
{
Super::Tick(DeltaSeconds);
UpdateCamera(DeltaSeconds);
}
void AEstPlayer::UpdateCamera(float DeltaSeconds)
{
FVector EyeLocation;
@alanedwardes
alanedwardes / s3_backup.sh
Last active August 29, 2015 14:01
Small script for backing up stuff on a linux server.
#!/bin/bash
# Get the day number
day="$(date +'%u')"
echo "Starting backup for day ${day}"
# Sync all data to S3, excluding git and svn folders
/usr/local/bin/aws s3 sync /path/to/folder s3://bucket/folder \
--exclude "*.svn*" --exclude "*.git*" --delete
@alanedwardes
alanedwardes / stringurlencode.c
Created March 14, 2014 00:13
Very simple C method to perform URL encoding on a char buffer. Includes a quick and dity list of characters to exclude. Some compilers will prefer sprintf_s or otherwise.
// ae - takes URL, puts percents in it.
void encodeUrl(char *out, int outSize, char *in, int inSize)
{
// Terminate our buffer
out[0] = '\0';
// Loop the input
for (int i = 0; i < inSize; i++)
{
// Get a char out of it
@alanedwardes
alanedwardes / logic_submerge.cpp
Created July 28, 2013 14:31
A Source Engine entity that fires an output when it's submerged.
//=============================================================================
//
// Purpose: Logic submerge - fires output when submerged in water.
//
//=============================================================================
#include "cbase.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
@alanedwardes
alanedwardes / estranged_materialsystem.cpp
Created June 11, 2013 21:59
A passthru material system for the source engine. Doesn't work very well.
#include "cbase.h"
#include "estranged_materialsystem.h"
#include "materialsystem\itexture.h"
#include "materialsystem/imaterialvar.h"
static void AppendShaderParams(const char* shader, IMaterial *pMat, KeyValues *newParams)
{
int nParams = pMat->ShaderParamCount();
IMaterialVar **pParams = pMat->GetShaderParams();