Skip to content

Instantly share code, notes, and snippets.

@jaburns
jaburns / gfm-render.sh
Last active August 27, 2023 16:02
Bash script to render github flavoured markdown to HTML
#!/usr/bin/env bash
data="$(
cat "$1" \
| sed 's/"/\\"/g' \
| sed ':a;N;$!ba;s/\n/\\n/g' \
)"
if [[ -z "$2" ]]; then
context=''
@jaburns
jaburns / import-spritesheet.jsfl
Created November 26, 2014 19:18
JSON Spritesheet Import JSFL
/**
* Json Frame Array Sprite Sheet Importer
*
* Creates a new MovieClip in the library, then for each frame in the imported spritesheet
* animation this script will create a bitmap-filled shape on the timeline of the newly-created
* movieclip.
*/
var LIBRARY_FOLDER = 'imported-sprites';
var dom = fl.getDocumentDOM ();
@jaburns
jaburns / game-physics-conversion.md
Last active August 29, 2015 14:14
Game "physics" constants conversion rules

Game "physics" constants conversion rules

Converting from dt=A to dt=B

Per-frame scale values (i.e. vx *= Z)
Z_new = Z ^ (B/A)
Acceleration values (i.e. vx += Z)
Z_new = Z * (B/A)^2
@jaburns
jaburns / index.html
Created February 6, 2015 23:45
Laggy socket.io hello world
<!DOCTYPE html>
<html>
<style>
body { background: #fff; }
#paper { background: #ccc; }
</style>
<body>
<canvas id="paper" width="800" height="600"></canvas>
</body>
<script src="/socket.io/socket.io.js"></script>
@jaburns
jaburns / gist:31f0dfa1af8656de3759
Created February 18, 2015 00:13
Sound detector
'use strict';
var playerModes = require('../../game/player').modes;
/**
* This module exports a single function that checks a game state and
* its latest diff for game sound triggers and plays the appropriate
* sounds on the provided AudioPlayer object.
*/
@jaburns
jaburns / Main.hs
Last active August 29, 2015 14:16
SDL Pixel Pushing comparison
module Main (
main
) where
import Control.Monad.State
import Control.Monad.Reader
import Data.Word
import Foreign
import Graphics.UI.SDL
@jaburns
jaburns / Makefile
Last active August 29, 2015 14:16
:|
default: all
all: public/index.html
public/index.html: index.html
cpp index.html | sed '/^#.*/d' > public/index.html
@jaburns
jaburns / vidup
Last active November 3, 2017 08:02
Script to screengrab video, convert to webm, upload to server, and get link.
#!/usr/bin/env bash
#
# Depends on ffmpeg with libvpx so you'll need to
# brew install ffmpeg --with-libvpx
# or
# brew reinstall ffmpeg --with-libvpx
# if you've already got ffmpeg, but it's not linked against libvpx.
#
vid_name='vidup_tmp'
remote='you@yourdomain.tld:/home/you/vidcaps'
@jaburns
jaburns / gdrive-invert-icons
Created March 30, 2015 21:04
Force inverted tray icons for OSX Google Drive
#!/usr/bin/env bash
cd /Applications/Google\ Drive.app/Contents/Resources
for file in $(find . -depth 1 | grep 'inverse.*png'); do
echo "Fixing $file ..."
cp "$file" "$(printf "$file" | sed 's/-inverse//')"
done
echo 'Done!'
@jaburns
jaburns / StarlingAtlasSlicer.cs
Last active August 29, 2015 14:20
Starling sprite animation atlas slicer for Unity
using System;
using System.Collections.Generic;
using System.Xml;
using UnityEditor;
using UnityEngine;
public class StarlingAtlasSlicer
{
[MenuItem("CONTEXT/TextureImporter/Slice Sprite Using XML")]
static public void SliceUsingXML(MenuCommand command)