Skip to content

Instantly share code, notes, and snippets.

View mohiji's full-sized avatar

Jonathan Fischer mohiji

View GitHub Profile
@mohiji
mohiji / JSONTest.m
Created May 15, 2023 21:58
Cheating to get predictable output out of NSJSONSerialization
//
// JSONTest.m
//
#import <Foundation/Foundation.h>
@interface OrderedDictionary : NSDictionary
{
NSDictionary *_dictionary;
NSArray *_orderedKeys;
@mohiji
mohiji / AnimatedSpriteComponent.h
Created March 17, 2018 04:42
Components and delegates
@import GameplayKit;
@import SpriteKit;
@class AnimatedSpriteComponent;
@protocol AnimatedSpriteComponentDelegate
- (void)animatedSpriteComponent:(AnimatedSpriteComponent *)component didUpdateToFrame:(SKTexture *)frame;
- (void)animatedSpriteComponent:(AnimatedSpriteComponent *)component didCompleteAnimation:(NSString *)animationName;
@mohiji
mohiji / main.lua
Created May 23, 2017 18:42
Coroutine test in LÖVE
-- main.lua
-- This file contains the actual demonstration code. The stuff that implements waits and signals
-- is in wait_support.
wait_support = require("wait_support")
local georgeColor = {0, 255, 0, 255}
local bobColor = {255, 0, 255, 255}
local georgeText = ""
@mohiji
mohiji / notes.md
Last active March 14, 2017 16:20
Notes on "Deploying your first Clojure App from the shadows"

In Chapter 1: Set Up a Server and Deploy a Clojure App to it

  • "anotehr" mis-spelling
  • ansible-galaxy install: the requirements file is in infrastructure/ansible, not just ansible/
  • vagrant up fails:

(silly placeholder to get markdown to do what I want)

solace:infrastructure jfischer$ vagrant up

Bringing machine 'default' up with 'virtualbox' provider...

import Foundation
struct Vector3 : Equatable {
let x: Float
let y: Float
let z: Float
func magnitude() -> Float {
return sqrtf(x * x + y * y + z * z)
}
@mohiji
mohiji / Model.java
Created July 8, 2016 22:04
Really basic immutable models for Java/GWT.
import static com.google.common.base.Preconditions.checkNotNull;
public class ImmutableModel {
private final int id;
private final String label;
public ImmutableModel(int id, String label) {
this.id = id;
this.label = checkNotNull(label);
}
@mohiji
mohiji / StateMachineTests.swift
Created March 4, 2016 21:10
GameplayKit style state machines in pure Swift
import XCTest
/********************************************
* The state graph used in these tests
*
* StateOne -----> StateTwo -----> State Three
* ^ | ^ |
* | | | |
* -------------| |----------------|
*
@mohiji
mohiji / StateMachines.swift
Created July 30, 2015 16:22
GKStateMachine in Swift
//: Playground - noun: a place where people can play
import Cocoa
class State {
weak var stateMachine: StateMachine?
func isValidNextState(stateClass: AnyClass) -> Bool {
return true
}
@mohiji
mohiji / gist:5d652540799ee9c74342
Created October 7, 2014 19:28
This confuses me. 127.0.0.1 works, localhost doesn't resolve?
solace:~ jfischer$ curl http://127.0.0.1:4000
Hi there.
solace:~ jfischer$ curl -v http://localhost:4000
* Rebuilt URL to: http://localhost:4000/
* Hostname was NOT found in DNS cache
* Trying ::1...
* connect to ::1 port 4000 failed: Connection refused
* Trying fe80::1...
* connect to fe80::1 port 4000 failed: Connection refused
@mohiji
mohiji / gist:11235244
Created April 23, 2014 22:50
Removes all non-important whitespace from a JSON file.
(require 'st-json)
(defun squish-json-file (filename)
(let ((parsed-json (with-open-file (stream filename)
(st-json:read-json stream))))
(with-open-file (stream (concatenate 'string filename ".squished")
:direction :output
:if-exists :supersede)
(st-json:write-json parsed-json stream))))