Skip to content

Instantly share code, notes, and snippets.

View IQAndreas's full-sized avatar

Andreas Renberg IQAndreas

View GitHub Profile
@IQAndreas
IQAndreas / MouseEvent.js
Created April 9, 2014 04:39
I hate passing strings as event strings. Only problem is, rather than throw an error, misspelled constants in JavaScript return `undefined`. Damn this weak language!
MouseEvent.CLICK = 'click';
MouseEvent.CONTEXT_MENU = 'contextmenu';
MouseEvent.DOUBLE_CLICK = 'dblclick';
MouseEvent.MOUSE_DOWN = 'mousedown';
MouseEvent.MOUSE_ENTER = 'mouseenter';
MouseEvent.MOUSE_LEAVE = 'mouseleave';
MouseEvent.MOUSE_MOVE = 'mousemove';
MouseEvent.MOUSE_OUT = 'mouseout';
MouseEvent.MOUSE_OVER = 'mouseover';
MouseEvent.MOUSE_UP = 'mouseup';
// I have to create an entirely new Rectangle class from scratch, because 'Rect' doesn't actually have a
// constructor or any other way of creating your own rectangles.
// http://stackoverflow.com/questions/22953073/does-rect-have-a-constructor-function
function Rectangle(x, y, width, height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
@IQAndreas
IQAndreas / request-animation-frame.js
Last active August 29, 2015 13:59
Make sure the `requestAnimationFrame()` function exists in one way or another.
window.requestAnimationFrame ||=
window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function() { console.log("WARNING: 'window.requestAnimationFrame()' not available in this browser."); };
@IQAndreas
IQAndreas / haxeflixel-v.3.0.1-packages.md
Last active August 29, 2015 14:00
HaxeFlixel v.3.0.1 package structure

[root]

FlxBasic
FlxCamera
FlxGame
FlxG
FlxObject
FlxSprite
FlxState
FlxSubState

@IQAndreas
IQAndreas / flixel-power-tools-v.1.9-packages.md
Created April 29, 2014 00:14
Flixel Power Tools v.1.9 package structure

[root]

FlxBar
FlxBitmapFont
FlxButtonPlus
FlxCollision
FlxColor
FlxControl
FlxControlHandler
FlxCoreUtils
FlxDelay

@IQAndreas
IQAndreas / Main.as
Last active August 29, 2015 14:01
Inconsistent Math results between AS3 and Haxe->AS3. See https://groups.google.com/forum/#!msg/haxelang/GHqaYCea8fE/5TJi7Mio0ngJ
package
{
import flash.text.TextField;
import flash.display.Sprite;
public class Main extends Sprite
{
public function Main()
{
traceVisual("TEST #5");
00:00.0 Host bridge [0600]: Intel Corporation Mobile PM965/GM965/GL960 Memory Controller Hub [8086:2a00] (rev 0c)
Subsystem: Hewlett-Packard Company Device [103c:30c8]
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort+ >SERR- <PERR- INTx-
Latency: 0
Capabilities: <access denied>
Kernel driver in use: agpgart-intel
00:02.0 VGA compatible controller [0300]: Intel Corporation Mobile GM965/GL960 Integrated Graphics Controller (primary) [8086:2a02] (rev 0c) (prog-if 00 [VGA controller])
Subsystem: Hewlett-Packard Company Device [103c:30c8]
@IQAndreas
IQAndreas / .bashrc
Created May 20, 2014 09:10
Snippet from "~/.bashrc"
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
RED="\[\033[0;31m\]"
RESET="\[\033[00m\]"
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
#host="@${RED}medtech${RESET}"
host="@\h"
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u${host}\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
@IQAndreas
IQAndreas / replace-html-entities.sh
Created May 31, 2014 03:46
Replace HTML entities with the actual unicode characters with Bash
# There are more, but these were all I needed for the current project
sed -i 's/&ldquo;/“/g' *.md
sed -i 's/&rdquo;/”/g' *.md
sed -i 's/&copy;/©/g' *.md
# Check if we have any HTML entities remaining (requires some manual filtering by eye)
grep '&' *.md