Skip to content

Instantly share code, notes, and snippets.

@Equinox-
Equinox- / StringMasks.py
Last active October 6, 2015 04:18
Added support for back conversion.
#!/usr/bin/python
def stringToInt(name):
name=name[::-1]
val=0
offset=0
for char in name:
val = val + ((ord(char) & 0xff) << offset)
offset = offset + 8
return val
@Equinox-
Equinox- / SMF Newsreel
Created July 3, 2012 19:21
Fetches all the topics in the given forum.
<?php
$mysql_host = "";
$mysql_database = "devoxstu_smf391";
$mysql_user = "";
$mysql_password = "";
$forum = 1;
mysql_connect($mysql_host, $mysql_user, $mysql_password)or die("cannot connect");
mysql_select_db($mysql_database)or die("cannot select DB");
//Grab the topics
@Equinox-
Equinox- / JavaConventions2.xml
Created July 3, 2012 19:48
Westin's java conventions
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="12">
<profile kind="CodeFormatterProfile" name="Java Conventions 2" version="12">
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
#ifndef __1983DEFINES_H
#define __1983DEFINES_H
#define PRACTICE_BOT 1
#define PRACTICE_OI 0
#define REGULAR_OI 0
#define JOYSTICK_CONTROL 1
//PewPew Start
#define DEADBAND 0.04
@Equinox-
Equinox- / gist:4010095
Created November 4, 2012 03:55
readin.sh
#!/bin/bash
while :
do
read line
if [ "$line" ]; then
echo $line
fi
done < $1
@Equinox-
Equinox- / injector.js
Created December 9, 2012 02:12
tw-lib.js
var fileList = {
"mp_res":"media/icons_context-0.png",
"mp_attack":"media/icons_context-1.png",
"mp_lock":"media/icons_context-2.png",
"mp_star":"media/icons_context-3.png",
"mp_message":"media/icons_context-4.png",
"mp_profile":"media/icons_context-5.png",
"mp_village":"media/icons_context-6.png",
"mp_recruit":"media/icons_context-7.png",
"mp_winadd":"media/icons_context-8.png",
@Equinox-
Equinox- / gist:5127232
Last active December 14, 2015 18:09
Object cloning in javascript
Object.prototype.clone = function () {
var obj = {};
for (key in this) {
obj[key] = this[key];
}
return obj;
}
Object.prototype.deepClone = function () {
var obj = {};
@Equinox-
Equinox- / gist:5127682
Created March 10, 2013 08:48
Basic structure of a time based termination command.
class CommandThing ... {
private:
long startTime;
//classy stuff
}
void CommandThing::Initialize() {
startTime = GetFPGATime(); // Get a reference point
}
@Equinox-
Equinox- / KittensBookmarklet.js
Last active December 30, 2015 05:29
Floating kittens bookmarklet.
javascript:(function(){if ((typeof spawnKitten) === "function") {spawnKitten();} else {var element = document.createElement("script");element.type = "text/javascript";element.src = "https://gist.github.com/Equinox-/7783216/raw/TheScript.js";document.head.appendChild(element);}})();
@Equinox-
Equinox- / Simulation.java
Created December 10, 2013 06:24
Java implementation of an N-Body simulation; main loop code.
// Lets go
for (int i = 0; i < bodies.size(); i++) {
Body b = bodies.get(i);
for (int w = i + 1; w < bodies.size(); w++) {
Body with = bodies.get(w);
double dist2 = // The distance between the two bodies
with.getPosition().dist(
b.getPosition());
double mag = // The force between the two bodies
Constants.GRAVITATIONAL_CONSTANT