Skip to content

Instantly share code, notes, and snippets.

View BenMcLean's full-sized avatar

Benjamin McLean BenMcLean

View GitHub Profile
@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.
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 / 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)
@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 / 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 / movegit.bat
Last active May 27, 2022 15:19
Batch file to transfer a Git repository to a different remote repo
cd %~dp0
for %%g in ("%1") do set "Folder=%%~ng"
mkdir %Folder%
cd %Folder%
git clone --mirror %1
cd %Folder%.git
git config --unset core.bare
git remote remove origin
git remote add origin %2
git push -u origin --all
@BenMcLean
BenMcLean / TestApp.java
Last active October 6, 2018 04:40
Simple libGDX app
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.viewport.FitViewport;
@BenMcLean
BenMcLean / darkplaces.service
Last active October 25, 2018 03:03
darkplaces-server as a systemd service on Ubuntu
[Unit]
Description=This service spawns a Darkplaces Quake dedicated server.
# Place this file in /lib/systemd/system
# To enable this service to launch at boot time, enter in a terminal: systemctl enable darkplaces.service
# To disable this service from launching at boot time, enter in a terminal: systemctl disable darkplaces.service
# To check the state of all existing unit files, enter in a terminal: systemctl list-unit-files
# I followed these instructions to install Darkplaces, except for the parts about starting the dedicated server on boot because those parts don't work anymore: https://ubuntuforums.org/showthread.php?t=2095900
# I based this service on https://github.com/cdev-tux/q3lite/blob/ba3f578b0dc93f2af645724fad283e7484b8d77e/misc/q3lite/pi/q3lite_ded.service
[Service]
@BenMcLean
BenMcLean / .gitconfig
Created February 14, 2019 22:53
apply-gitignore alias for Git
[alias]
                apply-gitignore = !git ls-files -ci --exclude-standard -z | xargs -0r git rm --cached
@BenMcLean
BenMcLean / VirtualBoyGo.ps1
Last active July 12, 2019 01:19
VirtualBoyGo powershell
<#
.SYNOPSIS
Downloads VirtualBoyGo source code
.DESCRIPTION
Gathers all dependencies and places them in the correct folders!
.NOTES
Author : Benjamin McLean mclean.ben@gmail.com
.LINK
https://github.com/CidVonHighwind/VirtualBoyGo
#>