Skip to content

Instantly share code, notes, and snippets.

View bartread's full-sized avatar
😀
Learning

Bart Read bartread

😀
Learning
View GitHub Profile
'use strict';
(function (){
const RADIANS_IN_A_CIRCLE = 2 * Math.PI;
const ONE_DEGREE = RADIANS_IN_A_CIRCLE / 360;
let lookup = [];
for (let index = 0; index < 360; ++index) {
lookup[index] = Math.sin(index * ONE_DEGREE);
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/phaser@3.15.1/dist/phaser-arcade-physics.min.js"></script>
</head>
<body>
<script>
var config = {
type: Phaser.AUTO,
@bartread
bartread / primitivesdllbuilderrorfix.bat
Last active December 19, 2017 17:41
Fix for a boring Visual Studio build error you don't care about because it's just in the way - run this if you get an error similar to "Unable to copy file "[project location]\packages\Microsoft.Net.Compilers.2.3.0-beta2\tools\System.Security.Cryptography.Primitives.dll" to "bin\roslyn\System.Security.Cryptography.Primitives.dll". Access to the …
taskkill /IM iisexpress.exe /F
taskkill /im msbuild.exe /f /t
taskkill /im VBCSCompiler.exe /f /t
@bartread
bartread / service.objectPool.js
Last active October 15, 2020 16:43
Simple JavaScript object pool implementation with some validation in place - depends on pinjector.js
(function () {
'use strict';
pinjector
.module('starCastle')
.factory(
'objectPool',
[
objectPool
]);
@bartread
bartread / pinjector.js
Created February 11, 2017 15:19
Pinjector injector - somewhat Angular 1.x-ish, but I was too lazy to support modules properly
'use strict'; // jshint ignore:line
var pinjector = {};
(function () {
pinjector.module = module;
var modules = {};
function module(name) {
@bartread
bartread / arcadely-play-sfx.js
Created February 11, 2017 15:13
Playing a sound effect in arcade.ly games
function _play(effect) {
if (!areSfxEnabledFlag || !effect) {
return;
}
var buffer = effect.buffer;
if (!buffer) {
return;
}
@bartread
bartread / loading-arcadely-game-sounds-music.js
Created February 11, 2017 15:09
Asynchronously loading music and sound effects to play via Web Audio API for arcade.ly games
function _initialiseSoundEffects() {
_loadSounds(soundConfiguration.sounds, true);
_loadSounds(soundConfiguration.music, false);
}
function _loadSounds(sounds, areSfx) {
for (var soundIndex = 0, soundCount = sounds.length; soundIndex < soundCount; ++soundIndex) {
var sound = sounds[soundIndex];
if (areSfx) {
@bartread
bartread / example-sfx-music-configuration.js
Created February 11, 2017 15:02
Example sound and music configuration for games on arcade.ly
(function () {
'use strict';
pinjector
.module('starCastle')
.factory(
'soundConfiguration',
[
'baseAsteroidsStarcastleSoundConfiguration',
soundConfiguration
@bartread
bartread / getlongestrunningtransactionsfromtrace.sql
Last active January 30, 2017 04:13
Gets transaction details from trace ordered by longest running to shortest running; includes stats for reads, writes, scans
SELECT TOP 30 -- You can alter or ditch this if needs be
d.[TransactionID],
MIN(d.[StartTime]) AS StartTime,
MAX(
CASE
WHEN d.[EndTime] IS NULL
OR d.[StartTime] > d.[EndTime] THEN d.[StartTime]
ELSE d.[EndTime]
END) AS EndTime,
DATEDIFF(
@bartread
bartread / gist:d169a4416cefc306a666e2fec2f62eb3
Last active March 23, 2023 17:32
Bash script for installing systemd service on Ubuntu
#! /bin/sh
# Other deployment actions here. Want to install (or bounce) service last.
if [ -f /etc/systemd/system/arcadely.service ]; then
sudo systemctl stop arcadely.service
sudo systemctl disable arcadely.service
else
sudo \cp -f ./arcadely.service /etc/systemd/system/arcadely.service
fi