Skip to content

Instantly share code, notes, and snippets.

View IQAndreas's full-sized avatar

Andreas Renberg IQAndreas

View GitHub Profile
@IQAndreas
IQAndreas / gist:5200218
Created March 19, 2013 21:14
Seek and Flee steering behaviors using OpenSteer ("orbiting" result)
// function init()
seekVehicle = new SimpleVehicle();
seekVehicle.setPosition(Math.random() * displayWidth, 0, Math.random() * displayHeight);
seekVehicle.radius = 10;
seekVehicle.maxForce = 800.0; //steering force
seekVehicle.maxSpeed = 300.0; //velocity
seekVehicle.speed = 100;
seekBoid = this.addBoid(seekVehicle, 0x00CC00);
// function update(currentTime:Number, elapsedTime:Number)
@IQAndreas
IQAndreas / gist:5195397
Created March 19, 2013 11:30
Found this HTML comment in the source of a website. Via https://www.udacity.com/
<!-- Fix IE's mind-blowing idiocy -->
<script type="text/javascript" charset="utf-8">
if (!window.console) {
window.console = {};
}
if (!window.console.log) {
window.console.log = function () {};
}
if (!window.console.error) {
window.console.error = function () {};
@IQAndreas
IQAndreas / Playvideo.as
Created March 15, 2013 16:32
See: http://www.gotoandlearn.com/play.php?id=114 Loads the video in at runtime rather than from a SWC.
package {
import com.transmote.flar.FLARManager;
import com.transmote.flar.marker.FLARMarker;
import com.transmote.flar.marker.FLARMarkerEvent;
import flash.display.Sprite;
import flash.events.Event;
import flash.media.Video;
import org.libspark.flartoolkit.support.pv3d.FLARCamera3D;
@IQAndreas
IQAndreas / gist:5036465
Last active November 14, 2016 18:52
Their bracket placement and indentation is like some sick, twisted joke meant to confuse and torment me. (from http://opensteer.svn.sourceforge.net/viewvc/opensteer/trunk/plugins/Soccer.cpp?revision=181&view=markup ) It looks like the only problem is the "else" on line 14. Wrong, keep looking and it will start hurting your eyes.
if(collisionAvoidance != Vec3::zero)
applySteeringForce (collisionAvoidance, elapsedTime);
else
{
float distHomeToBall = Vec3::distance (m_home, m_Ball->position());
if( distHomeToBall < 12.0f)
{
// go for ball if I'm on the 'right' side of the ball
if( b_ImTeamA ? position().x > m_Ball->position().x : position().x < m_Ball->position().x)
{
@IQAndreas
IQAndreas / require-clean-git-index.sh
Created February 16, 2013 21:22
Shell function that requires that a GIT index is clean before running a command. The script allows modified or untracked files to exist in the repository, so long as the index is empty.
function require_clean_index()
{
# TODO: Allow to manually set which git directory
git diff-index --quiet --cached HEAD
if [ $? -ne 0 ]; then
echo "This command requires a clean index. Please reset or commit changes and try again.";
exit 2;
fi
}
@IQAndreas
IQAndreas / EntityFishHook.java
Created February 14, 2013 15:48
Partial from MineCraft decompiled source - `EntityFishHook::onUpdate()`
if (this.ticksCatchable > 0)
{
--this.ticksCatchable;
}
else
{
short var28 = 500;
if (this.worldObj.canLightningStrikeAt(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY) + 1, MathHelper.floor_double(this.posZ)))
{
@IQAndreas
IQAndreas / gist:4579236
Created January 20, 2013 15:01
Odd but valid syntax for retrieving keys or values from an object
// Originally by @pleclech
// via http://pastebin.com/1MDyFVJA
var o:Object = { foo:"bar", hello:"world", one:"one", two:"two" };
var values:Array = [];
for each (values[values.length] in o);
trace(values); // world,one,two,bar
var keys:Array = [];
$ svn checkout -r 958 https://eventlist.svn.sourceforge.net/svnroot/eventlist/trunk
svn: E195012: Unable to find repository location for 'https://eventlist.svn.sourceforge.net/svnroot/eventlist/trunk' in revision 958
$ telnet jw.org 80
Trying 54.246.51.69...
Connected to jw.org.
Escape character is '^]'.
GET / HTTP/1.0
HTTP/1.1 403 Forbidden
Server: Varnish
Content-Type: text/html; charset=utf-8
Content-Length: 318
#!/bin/bash
if [ $# -lt 1 ]; then
echo "[clear-git-directory.sh] Please specify the GIT repository to clear."
exit 1;
elif [ ! -d "$1/.git" ]; then
echo "[clear-git-directory.sh] Cannot find a GIT repository in '$1'."
exit 1;
else
cd "$1";