Skip to content

Instantly share code, notes, and snippets.

🎧
lost in vr

Johnny Broadway jbroadway

🎧
lost in vr
Block or report user

Report or block jbroadway

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jbroadway
jbroadway / s3backup.sh
Last active Mar 31, 2019
A simple Elefant CMS backup script to Amazon S3 (requires s3cmd)
View s3backup.sh
#!/bin/bash
# modify these as needed
BUCKET=bucketname
HOSTNAME=example.com
ROOT=/usr/share/nginx/html
BACKUP=/usr/share/nginx/backup
# ensure backup folder exists
mkdir -p $BACKUP
@jbroadway
jbroadway / TutorialActions.cs
Last active Feb 6, 2018
How unidirectional data flow in pure Unity might work (inspired by Redux, Vuex, etc.), minus UniRx. Assumes Zenject for dependency injection. Latest: https://github.com/lux/reactive-tests
View TutorialActions.cs
// Business logic
public class TutorialActions {
private State _state;
[Inject]
private void Init (TutorialState state) {
_state = state;
// Fetch latest from database then call _state.SetSteps()
// and _state.SetCurrentStep()
@jbroadway
jbroadway / Remove Component.md
Created Aug 23, 2017
Unity3D editor script to remove a component from all children of an object
View Remove Component.md

Unity3D editor script to remove a component from all children of an object

Usage:

  1. Save the file to your Assets/Editor folder.
  2. Modify the classes to refer to the ComponentName you want removed.
  3. Attach RemoveComponentName component to the root GameObject the components should be removed from.
  4. Click the "Remove ComponentName" button in the inspector.
  5. Remove the RemoveComponentName component when you're done.
View Delegates and yielding in Unity.md

Delegates and yielding in Unity

I discovered something interesting in C#'s event delegate system when combined with coroutines.

First, I started with a simple event delegate example:

using UnityEngine;
using System.Collections;
@jbroadway
jbroadway / Crash.log
Created Jun 20, 2016
Image.fillAmount crash info
View Crash.log
This file has been truncated, but you can view the full file.
--------- beginning of main
I/Unity (13321): Timer at: 0.0583331
I/Unity (13321): UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
I/Unity (13321): UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
I/Unity (13321): UnityEngine.Logger:Log(LogType, Object)
I/Unity (13321): UnityEngine.Debug:Log(Object)
I/Unity (13321): GazeCursor:Update() (at /Users/lux/projects/Unity/scout-unity/Assets/Scripts/Objects/GazeCursor.cs:96)
I/Unity (13321):
I/Unity (13321): (Filename: /Users/lux/projects/Unity/scout-unity/Assets/Scripts/Objects/GazeCursor.cs Line: 96)
@jbroadway
jbroadway / resizing_and_tiling.sh
Created Dec 12, 2015
Examples of commands for resizing and tiling images using ImageMagick
View resizing_and_tiling.sh
# Crop all pngs to 192x192 offset to 348x55:
mogrify -crop 192x192+348+55 +repage *.png
# Tile them all into one sprite sheet:
montage *.png -geometry 192x192 -tile 5x5 -background none ../sprite_sheet.png
@jbroadway
jbroadway / PushId.php
Last active Nov 28, 2017 — forked from jeremyworboys/PushId.php
Missing static:: prefix in two places and fixes occasional "Length should be 20" exceptions.
View PushId.php
<?php
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
View keybase.md

Keybase proof

I hereby claim:

  • I am jbroadway on github.
  • I am lux (https://keybase.io/lux) on keybase.
  • I have a public key whose fingerprint is 660A 7F28 50B0 3F3F 05F4 49A6 EC45 0C7F AD47 AB33

To claim this, I am signing this object:

@jbroadway
jbroadway / bootstrap.php
Last active Aug 29, 2015
Bootstrap file for the Elefant CMS to hide a site behind HTTP Basic auth.
View bootstrap.php
<?php
/**
* Implements HTTP Basic auth to hide your site
* until it's ready to go live. Based on:
*
* https://gist.github.com/jbroadway/9a18f84ad6be671eb22d
*/
if (! $controller->cli) {
conf ('General', 'master_username', 'USERNAME');
@jbroadway
jbroadway / style.css
Last active Aug 29, 2015
Minimal Responsive Grid System.
View style.css
/**
* Minimal Responsive Grid System.
*
* Usage:
*
* <div class="row">
* <div class="unit-75">
* <h1>Body</h1>
* </div>
* <div class="unit-25">
You can’t perform that action at this time.