Skip to content

Instantly share code, notes, and snippets.

View jbroadway's full-sized avatar

John de Plume jbroadway

View GitHub Profile
@jbroadway
jbroadway / Slimdown.md
Last active February 5, 2024 10:43
Slimdown - A simple regex-based Markdown parser.
@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 / URLify.php
Created May 18, 2012 18:34
Illustrating problems with iconv() vs URLify::transliterate() for PHP.
<?php
/**
* A PHP port of URLify.js from the Django project
* (https://github.com/django/django/blob/master/django/contrib/admin/static/admin/js/urlify.js).
* Handles symbols from Latin languages, Greek, Turkish, Russian, Ukrainian,
* Czech, Polish, and Latvian. Symbols it cannot transliterate
* it will simply omit.
*
* Usage:
@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
@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 / app.js
Created June 27, 2012 18:05
Simple History.js-based client-side router
var app = (function ($) {
var self = {};
// change pages via app.go('/new/page') or app.go(-1)
self.go = function (url) {
if (url === parseInt (url)) {
History.go (url);
} else {
History.pushState (null, null, url);
}
@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 / .htaccess
Last active June 6, 2016 19:14
Elefant CMS Subfolder Proxy
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} \.(js|css)$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . subfolder.php [L]
</IfModule>