Skip to content

Instantly share code, notes, and snippets.

View demonixis's full-sized avatar

Yannick Comte demonixis

View GitHub Profile
@demonixis
demonixis / testWindowProperty.js
Created November 26, 2012 16:14
JavaScript is funny...
function r (e) {
if (typeof(e.window) == "undefined") {
return "ok you're done";
}
return r(e.window);
}
r(this); // RangeError: Maximum call stack size exceeded
@demonixis
demonixis / MathHelper.js
Created December 4, 2012 10:38
JavaScript Math helper
var MathHelper = {
// Get a value between two values
clamp: function (value, min, max) {
if (value < min) {
return min;
}
else if (value > max) {
return max;
}
@demonixis
demonixis / remove-ati-amd-watermark.sh
Created December 23, 2012 21:16
A simple script to remove the watermark of beta catalyst driver on Fedora x64
#!/bin/sh
DRIVER=/lib64/xorg/modules/drivers/fglrx_drv.so
for x in $(objdump -d $DRIVER|awk '/call/&&/EnableLogo/{print "\\x"$2"\\x"$3"\\x"$4"\\x"$5"\\x"$6}'); do
sed -i "s/$x/\x90\x90\x90\x90\x90/g" $DRIVER
done
@demonixis
demonixis / YnQuadTreeTest.cs
Created February 6, 2013 20:47
YnQuadTree in action with 50 sprites. This gist demonstrate you how it is simple to use a QuadTree structure in a game using Yna Engine. More information on the project page http://yna.codeplex.com
public class TestYnQuadTree
{
private List<YnSprite> sprites;
private YnSprite heroSprite;
private YnQuadTree quadTree;
public TestGame()
{
// Init some Sprites
sprites = new List<YnSprite>();
@demonixis
demonixis / ColorboxIframeFullScreen.js
Last active December 12, 2015 06:29
Gets fullscreen (HTML5 API) to work with an iframe with colorbox.js
// Gets the iframe created by colorbox
var iframe = $("#colorbox").find("iframe");
// Gets focus on iframe
iframe.focus();
// Allow fullscreen on iframe
iframe.attr({
webkitAllowFullScreen : true,
mozAllowfullscreen : true,
@demonixis
demonixis / active-wifi.sh
Created February 10, 2013 21:32
Command line script for wifi
#!/bin/bash
ifconfig wlan0
iwconfig wlan0 essid YOUR_NETWORK_NAME key YOUR_KEY
dhclient wlan0
@demonixis
demonixis / toggleFullscreen.js
Created March 18, 2013 16:07
A simple function to toggle fullscreen in JavaScript. It work well on Firefox and Webkit browsers.
/**
* Toggle fullscreen function who work with webkit and firefox.
* @function toggleFullscreen
* @param {Object} event
*/
function toggleFullscreen(event) {
var element = document.body;
if (event instanceof HTMLElement) {
element = event;
@demonixis
demonixis / isDefine.js
Created April 5, 2013 13:51
Simple function that determine if a variable is define or not.
/**
* Determine if a variable is define or not.
*
* @method isDefine
* @param {Object} a variable to test.
* @return {Boolean} Return true if the parameter is defined, otherwise return false.
*/
function isDefine (value) {
return value != void(0);
}
@demonixis
demonixis / Person.dart
Last active December 16, 2015 02:39
Small comparison between Dart and TypeScript languages to create class with inheritance.
import 'dart:html';
// A base class for a person
class Person {
String name;
String toString() => "Hi ! " + this.name;
Person(String name) {
this.name = name;
}
@demonixis
demonixis / AtlantisGame.cpp
Created June 6, 2013 07:08
A simple game class with Atlantis Framework C++ version. It's XNA like :)
#include "SDL.h"
#include "Game.h"
#include "Graphics/SpriteBatch.h"
#include "Vector2.h"
using namespace Atlantis::Framework;
class Game1 : public Game
{
private: