Skip to content

Instantly share code, notes, and snippets.

View mandarinx's full-sized avatar

Thomas Viktil mandarinx

View GitHub Profile
@mandarinx
mandarinx / starstruck.js
Created October 13, 2014 10:26
Phaser 2.1.0 removeTile()
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
var map;
var tileset;
var layer;
var player;
var facing = 'left';
var jumpTimer = 0;
var cursors;
var jumpButton;
@mandarinx
mandarinx / portforwarding.md
Last active August 29, 2015 14:07
Port forwarding on OS X

Edit the hosts file

sudo nano /etc/hosts

Add this line somewhere after 127.0.0.1 localhost:

127.0.0.1       your.domain.com

Save and exit (Ctrl + O, Ctrl + X). Flush the DNS cache:

@mandarinx
mandarinx / ten_commandments.md
Last active August 29, 2015 14:19
The ten commandments of egoless programming

Taken from Jerry Weinberg's book The Psychology of Computer Programming

  1. Understand and accept that you will make mistakes. The point is to find them early, before they make it into production. Fortunately, except for the few of us developing rocket guidance software at JPL, mistakes are rarely fatal in our industry. We can, and should, learn, laugh, and move on.
  2. You are not your code. Remember that the entire point of a review is to find problems, and problems will be found. Don’t take it personally when one is uncovered.
  3. No matter how much “karate” you know, someone else will always know more. Such an individual can teach you some new moves if you ask. Seek and accept input from others, especially when you think it’s not needed.
  4. Don’t rewrite code without consultation. There’s a fine line between “fixing code” and “rewriting code.” Know the difference, and pursue stylistic changes within the framework of a code review, not as
@mandarinx
mandarinx / Comments.md
Last active August 29, 2015 14:26
Marquee selection in Unity3D

This script requires the Nine Slice Scaling script from https://gist.github.com/mandarinx/06192ee17d68c528edb9

How this works

Each update a ray is cast on a plane, based on the mouse cursor position. The hit point is snapped to a grid defined by unitSize and gridSize. The distance between the grid index of mouse click and index of mouse release is used to calculate the area of selection.

Note

@mandarinx
mandarinx / performance.md
Created August 18, 2015 08:35
Unity3D performance notes
@mandarinx
mandarinx / GearRotator.cs
Last active August 29, 2015 14:28 — forked from LordNed/GearRotator.cs
A quick example of creating a gear or object that can spin with mouse cursor. Expects object to rotate along its Forward vector.
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
public class GearRotator : MonoBehaviour
{
[SerializeField] private float m_radiusThreshold = 4f;
private float m_startingAngle;
private Quaternion m_startingRotation;
@mandarinx
mandarinx / as3_remove_all_children
Created April 30, 2012 08:54
Remove all children (AS3)
while (this.numChildren > 0)
{
removeChild(this.getChildAt(0));
}
// Remove children as part of an event handler
private function eventHandler(e:Event):void
{
e.target.parent.removeChild(e.target);
@mandarinx
mandarinx / CustomEditorBase.cs
Created April 3, 2016 15:29 — forked from t0chas/CustomEditorBase.cs
Default Custom Inspector-Editor for Unity3D with ReorderableLists for arrays handling
using UnityEngine;
using UnityEditor;
using UnityEditorInternal;
using System.Collections.Generic;
using UnityEditor.AnimatedValues;
[CustomEditor(typeof(UnityEngine.Object), true, isFallback = true)]
[CanEditMultipleObjects]
public class CustomEditorBase : Editor
{
@mandarinx
mandarinx / log.txt
Created June 14, 2016 06:35
Build report #7
[Unity] Initialize engine version: 5.3.5p2 (3103edb99077)
[Unity] Assets/Rocks and Boulders 2/Shaders/RotateGameObject.cs(18,35): warning CS0618: `UnityEngine.Transform.RotateAroundLocal(UnityEngine.Vector3, float)' is obsolete: `use Transform.Rotate instead.'
[Unity] Assets/UBER/Scripts/UBER_GlobalParams.cs(323,24): warning CS0618: `UnityEngine.ParticleSystem.emissionRate' is obsolete: `emissionRate property is deprecated. Use emission.rate instead.'
[Unity] Assets/UBER/Scripts/UBER_GlobalParams.cs(326,40): warning CS0618: `UnityEngine.ParticleSystem.emissionRate' is obsolete: `emissionRate property is deprecated. Use emission.rate instead.'
[Unity] Assets/Rocks and Boulders 2/Shaders/RotateGameObject.cs(18,35): warning CS0618: `UnityEngine.Transform.RotateAroundLocal(UnityEngine.Vector3, float)' is obsolete: `use Transform.Rotate instead.'
[Unity] Assets/UBER/Scripts/UBER_GlobalParams.cs(323,24): warning CS0618: `UnityEngine.ParticleSystem.emissionRate' is obsolete: `emissionRate property is deprecated. Use
@mandarinx
mandarinx / SimpleGeo.cs
Created September 14, 2016 13:55 — forked from phosphoer/SimpleGeo.cs
Simple Geometry Painter for Unity
// The MIT License (MIT)
// Copyright (c) 2016 David Evans @phosphoer
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR