Skip to content

Instantly share code, notes, and snippets.

View bartread's full-sized avatar

Bart Read bartread

View GitHub Profile
@bartread
bartread / mostexpensivesprocs.sql
Last active June 14, 2018 02:11
Get most expensive stored procedures in SQL Server
USE [YOUR_DATABASE_NAME]; -- Substitute for your database name
GO
SELECT TOP 10 -- Change as appropriate
t.text ,
s.sql_handle ,
s.plan_handle ,
s.total_worker_time / 1000 AS total_cpu_time_millis ,
s.total_worker_time / s.execution_count / 1000 AS avg_cpu_time_millis ,
s.total_logical_reads,
@bartread
bartread / gist:5d8c09310156b3a37c968b2f6d3a1e79
Last active September 15, 2017 09:43 — forked from tonymtz/gist:d75101d9bdf764c890ef
Fully uninstall nodejs from OSX Yosemite 10.10.5
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.node.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@bartread
bartread / findnodeprocesses.sh
Created January 21, 2017 13:01
Ubuntu 16 - reliably find node processes and take conditional action
#!/bin/sh
NODEPROCESSES=$(ps -aux | grep '[s]udo nohup node index.js' | awk '{print $2}')
if [ -n "$NODEPROCESSES" ]; then
echo "Found node processes $NODEPROCESSES"
else
echo "No node processes found"
fi
@bartread
bartread / arcadely.conf
Created January 21, 2017 22:07
Sample upstart configuration for arcade.ly
description "Arcade.ly node.js server"
author "Bart Read"
# used to be: start on startup
# until we found some mounts weren't ready yet while booting
start on started mountall
stop on shutdown
# automatically respawn
@bartread
bartread / arcadely.service
Created January 21, 2017 22:14
systemd service descriptor for arcade.ly
[Unit]
Description=Arcade.ly Node.js Server
#Requires=After=mysql.service # Requires the mysql service to run first
[Service]
ExecStart=/usr/bin/node /home/ubuntu/arcade/build/production/index.js
Restart=always
RestartSec=10 # Restart service after 10 seconds if node service crashes
StandardOutput=syslog # Output to syslog
StandardError=syslog # Output to syslog
@bartread
bartread / gist:d169a4416cefc306a666e2fec2f62eb3
Last active August 14, 2024 13:10
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
@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 / 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 / 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 / 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;
}