Skip to content

Instantly share code, notes, and snippets.

View punmechanic's full-sized avatar

Dan punmechanic

View GitHub Profile
@punmechanic
punmechanic / gist:8296168
Created January 7, 2014 08:16
Tasks in .NET 4.0
_internalTickerTask = new Task(InternalTicker, TaskCreationOptions.LongRunning);
_internalTickerTask.Start();
private void InternalTicker()
{
while (IsAutomaticallyUpdating)
{
if (!(_internalClock.ElapsedMilliseconds >= _ticksIntervalMilliseconds))
continue;
require 'date'
require 'net/http'
# Get arguments from command line
if ARGV.count < 4
puts 'tribalwars world x y radius'
return
end
world = ARGV[0]
x = ARGV[1]
// The main game class, instantiated from Main, takes a scheduler and a display window
// The scheduler supplied should be where anything asynchronous should be executed for
// the game, or any kind of repeatable task. Example - game tick.
// The display window actually displays stuff.
// I was hoping for the injected Scheduler to potentially run on the current thread.
// At the point of inception the Game will have been created on the Main thread, thus,
// the Scheduler would run on the Main thread and prevent the program from immediately
// returning.
@punmechanic
punmechanic / gist:d4836ee7758374448fc3
Created August 30, 2014 16:35
On a scale of 1 to Game of Thrones spoilers, how evil is this Java code?
/**
* A handler specifically for LwjglExceptions.
* This should be injected via Ioc into a LwjglWindow.
*
* Any instance of an exception occuring in Lwjgl should cause the enclosing program to fail.
* @author Dan
*
*/
class LwjglExceptionHandler implements ExceptionHandler {
private final Logger logger;
@punmechanic
punmechanic / Gruntfile.js
Created September 20, 2014 15:30
A template Gruntfile.js template for AngularJS projects
module.exports = function(grunt) {
grunt.initConfig({
revision: {
options: {
short: true,
ref: 'HEAD',
property: 'meta.revision'
}
},
karma: {
@punmechanic
punmechanic / index.html
Last active August 29, 2015 14:16
Responsiveness in Angular. This could be done in pure CSS, but I had a brain fart.
<responsive>
<div ng-switch='screenSize'>
<div ng-switch-when='small'>
<h1>Small Screen</h1>
</div>
<div ng-switch-when='medium'>
<h1>Medium Screen</h1>
</div>
<div ng-switch-when='large'>
<h1>Large Screen</h1>
@punmechanic
punmechanic / overwolf.d.ts
Created February 26, 2015 14:04
Overwolf API definition file
interface OverwolfStatic {
utils: OverwolfUtils;
profile: OverwolfProfile;
extensions: OverwolfExtensions;
games: OverwolfGames;
media: OverwolfMedia;
settings: OverwolfSettings;
streaming: OverwolfStreaming;
windows: OverwolfWindows;
@punmechanic
punmechanic / inject.js
Last active August 29, 2015 14:19
yet another javascript dependency injector
;(function(window, Promise, exports) {
'use strict';
var types = {};
/**
* Register a type with the injector.
* @param {String} name The name of the type to register.
* @param {Function} constructor The constructor for the injector. Constructors can be regular function; `this` will be bound to the constructor function itself. Constructs may register their dependencies by placing an $inject field that is a string array. Each dependency will be resolved before instantiating the constructor. If the dependency cannot be fulfilled, an Error will be thrown.
*/
exports.register = function(name, constructor) {
@punmechanic
punmechanic / champion.js
Last active August 29, 2015 14:19
Riot API champion concept
'use strict';
/**
* A factory for creating access to the riot champion API.
* @param {http} http The object to send HTTP GET requests with. This is not a node
* http instance. It must respond to a get method with the signature (region, version, pathname, querystring).
* @param {String} version The version of the API to query.
*/
function champions(http, version) {
/**