Skip to content

Instantly share code, notes, and snippets.

View BenMcLean's full-sized avatar

Benjamin McLean BenMcLean

View GitHub Profile
@BenMcLean
BenMcLean / powershell.bat
Last active October 30, 2022 22:57
Launch Powershell script .ps1 from identically named batch script .bat
@ECHO OFF
cd %~dp0
PowerShell.exe -NoProfile -ExecutionPolicy Bypass -Command "& '%~dpn0.ps1' %1 %2 %3 %4 %5 %6 %7 %8"
@PAUSE
@BenMcLean
BenMcLean / cleanDist.ps1
Created November 29, 2017 23:19
Use BFG to strip out old web builds from my repositories that use Github Pages
param ($name)
Set-PSDebug -Trace 2
git clone --mirror https://github.com/BenMcLean/$name.git
java -jar bfg.jar --delete-folders dist "$name.git"
cd ./$name.git
git push
cd..
Remove-Item -Path "$name.git" -Recurse -Force
@BenMcLean
BenMcLean / ref.lua
Created November 9, 2017 20:27
"Assign by reference"-like behavior in Lua
ref=(function(obj,key)
return (function(...)
local p={...}
if select('#',...)==0 then
return obj[key]
else
obj[key]=p[1]
end
end)
end)
private void initialize() {
Coord.expandPoolTo(WIDTH+3, HEIGHT+3);
// Initialize the heightmap generator
ModuleFractal heightFractal = new ModuleFractal (ModuleFractal.FractalType.FBM,
ModuleBasisFunction.BasisType.GRADIENT,
ModuleBasisFunction.InterpolationType.QUINTIC);
heightFractal.setNumOctaves(terrainOctaves);
heightFractal.setFrequency(terrainFrequency);
heightFractal.setSeed(CommonRNG.getRng().between(0, Integer.MAX_VALUE));
ModuleFractal ridgedHeightFractal = new ModuleFractal (ModuleFractal.FractalType.RIDGEMULTI,
@BenMcLean
BenMcLean / tictactoe.bat
Created March 10, 2016 04:32
Windows Batch Tic-Tac-Toe
@echo off
setLocal EnableDelayedExpansion
:newgame
cls
echo TIC-TAC-TOE
echo Written by Benjamin McLean
echo.
echo Controls:
echo|set /p="7 | 8 | 9"
echo.