Skip to content

Instantly share code, notes, and snippets.

View jbroadway's full-sized avatar

John de Plume jbroadway

View GitHub Profile
@jbroadway
jbroadway / s3backup.sh
Last active March 31, 2019 17:11
A simple Elefant CMS backup script to Amazon S3 (requires s3cmd)
#!/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 February 6, 2018 22:19
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
// 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 August 23, 2017 01:43
Unity3D editor script to remove a component from all children of an object

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.
@jbroadway
jbroadway / Delegates and yielding in Unity.md
Created August 7, 2016 22:49
Delegates and yielding in Unity

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 June 20, 2016 01:25
Image.fillAmount crash info
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)
I/Unity (13321):
@jbroadway
jbroadway / resizing_and_tiling.sh
Created December 12, 2015 21:51
Examples of commands for resizing and tiling images using ImageMagick
# 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 August 14, 2021 22:32 — forked from jeremyworboys/PushId.php
Missing static:: prefix in two places and fixes occasional "Length should be 20" exceptions.
<?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

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 August 29, 2015 14:06
Bootstrap file for the Elefant CMS to hide a site behind HTTP Basic auth.
<?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 August 29, 2015 14:04
Minimal Responsive Grid System.
/**
* Minimal Responsive Grid System.
*
* Usage:
*
* <div class="row">
* <div class="unit-75">
* <h1>Body</h1>
* </div>
* <div class="unit-25">