Skip to content

Instantly share code, notes, and snippets.

View Urethramancer's full-sized avatar
💭
Coding furiously.

Urethramancer

💭
Coding furiously.
  • Norway
View GitHub Profile
@Urethramancer
Urethramancer / addon-slash-addon.go
Last active July 5, 2017 16:16
Simple plugin example for Go 1.8+.
// addon/addon.go
// The definition of a plugin. Each plugin project would include this stub.
package addon
type Addon interface {
Hello()
}
@Urethramancer
Urethramancer / scrollablelist.go
Created October 14, 2016 11:49
Scrollable list for termui (Go). The title shows arrows pointing up and/or down if there are list entries outside the viewable region.
package main
import (
"fmt"
ui "github.com/gizak/termui"
)
type ScrollableList struct {
list *ui.List
@Urethramancer
Urethramancer / progressbar.go
Created October 13, 2016 09:52
A simple progress bar control for termui. See https://github.com/gizak/termui
package main
import (
"fmt"
"strings"
ui "github.com/gizak/termui"
)
type ProgressBar struct {
@Urethramancer
Urethramancer / humannumber.go
Last active November 14, 2016 16:47
Make human-readable number strings.
// humanNumber turns long numbers into sensible units for file sizes etc.
// Converted from C code found on the web.
func humanNumber(n int, si bool) string {
num := float64(n)
var unit float64 = 1024
if si {
unit = 1000
}
if num < unit {
return fmt.Sprintf("%dB", int(num))
@Urethramancer
Urethramancer / State.cs
Created July 21, 2016 03:17
The most basic state machine class and state interface in C#, free of enumeration.
public interface State
{
void Enter();
void Run();
void Exit();
}
public class StateMachine
{
State currentState;
@Urethramancer
Urethramancer / .gitignore
Created July 20, 2016 14:35
A gitignore file for Unity.
# Unity generated
[Tt]emp/
[Oo]bj/
[Bb]uild
[Ll]ibrary/
sysinfo.txt
*.stackdump
# Visual Studio / MonoDevelop
[Ee]xported[Oo]bj/
@Urethramancer
Urethramancer / SaveTesting.cs
Created July 20, 2016 05:18
A simple file saving class for Unity (or really any C# project if you drop the inheriting from MonoBehaviour).
// Class to test that saving/compression works in Unity.
// Largely untested outside of OS X.
using UnityEngine;
using NSC;
public class SaveTesting : MonoBehaviour
{
void Start()
using UnityEngine;
using UnityEngine.EventSystems;
public interface IRightPointerClickHandler : IEventSystemHandler
{
void OnRightPointerClick(PointerEventData data);
}
public interface IRightPointerDownHandler : IEventSystemHandler
using UnityEngine;
using UnityEngine.EventSystems;
public static class ExtraMouseEvents
{
/// <summary>
/// Right mouse-click
/// </summary>
/// <param name="handler">Handler.</param>
/// <param name="data">Data.</param>
// Replacement module for Standalone Input Module
// Up to date for Unity 4.6 beta 19
//
// Usage:
// -Remove the standalone module from your event system
// -Add this instead
// -Include ExtraMouseEvents.cs and IExtraMouseEventsHandler.cs
// -Implement IRightPointerClickHandler, IRightPointerDownHandler, IRightPointerUpHandler, IMiddlePointerClickHandler,
// IMiddlePointerDownHandler and/or IMiddlePointerUpHandler.
//