Skip to content

Instantly share code, notes, and snippets.

View RafaelOliveira's full-sized avatar

Rafael Oliveira RafaelOliveira

View GitHub Profile
@jgranick
jgranick / MineHX.hx
Created February 7, 2012 21:24
How to switch graphics based on screen density (NME recipe)
package com.eclecticdesignstudio.minehx;
import nme.display.Sprite;
import nme.system.Capabilities;
import nme.Assets;
/**
* ...
@jgranick
jgranick / gist:1763850
Created February 8, 2012 01:05
NMML File Specification
<?xml version="1.0" encoding="utf-8"?>
<project>
<!-- <meta />
Use meta nodes to set metadata for your application. The description is ignored
on most targets, but is useful for packaging like Chrome Apps or Opera Widgets.
For compatibility with Android and webOS, the package name must include at least
@callmephilip
callmephilip / gist:3626669
Created September 4, 2012 21:21
[JavaScript] Lock site in portrait mode in mobile Safari
// Kudos to Grumdrig
// http://stackoverflow.com/questions/1207008/how-do-i-lock-the-orientation-to-portrait-mode-in-a-iphone-web-application
$(document).ready(function () {
function reorient(e) {
var portrait = (window.orientation % 180 == 0);
$("body > div").css("-webkit-transform", !portrait ? "rotate(-90deg)" : "");
}
window.onorientationchange = reorient;
window.setTimeout(reorient, 0);
@flufy3d
flufy3d / readoffset.py
Created November 23, 2012 02:48
gimp tips for read the layers offset
>>> gimp.image_list()[0]
<gimp.Image '无标题'>
>>> gimp.image_list()[0].active_layer
<gimp.Layer 'aaa0002.png'>
>>> gimp.image_list()[0].active_layer.width
276
>>> gimp.image_list()[0].active_layer.height
269
>>> gimp.image_list()[0].active_layer.offset
<built-in method offset of gimp.Layer object at 0x02689C30>
@jgranick
jgranick / Main.hx
Last active December 19, 2015 03:09
Adding controller support for OUYA
package;
import flash.display.Sprite;
import flash.geom.Point;
import openfl.events.JoystickEvent;
#if android
import openfl.utils.JNI;
import tv.ouya.console.api.OuyaController;
@GuillermoPena
GuillermoPena / nodeJs.crypto.calculatingHash.js
Created February 26, 2014 16:30
NodeJS - CRYPTO : How to calculate a hash from file or string
var crypto = require('crypto')
, fs = require('fs')
// Algorithm depends on availability of OpenSSL on platform
// Another algorithms: 'sha1', 'md5', 'sha256', 'sha512' ...
var algorithm = 'sha1'
, shasum = crypto.createHash(algorithm)
// Updating shasum with file content
var filename = __dirname + "/anything.txt"
@cambiata
cambiata / gist:471575a42676b27719e3
Created May 13, 2014 14:32
Haxe BytesLoader - binary data loader that works on Flash, JS, Neko, Cpp - Status: Proof of conept
package cx.data;
import haxe.io.Bytes;
import haxe.io.BytesData;
import haxe.io.BytesInput;
#if js
import js.html.ArrayBuffer;
import js.html.DataView;
import js.html.XMLHttpRequest;
@jasononeil
jasononeil / Metric.hx
Last active November 10, 2016 11:16
Demonstration of using Haxe abstracts to take care of explicit conversions between different units of measurement, with no performance overhead.
class Metric {
static function main() {
var coinRadius:Millimeters = 12;
var myHeight:Centimeters = 180;
var raceLength:Meters = 200;
var commuteDistance:Kilometers = 23;
diff( coinRadius, myHeight ); // 1.788 meters
diff( raceLength, commuteDistance ); // 22800 meters
sum( commuteDistance, coinRadius ); // 23000.012 meters
@Eiyeron
Eiyeron / Rotscale.lua
Created April 22, 2015 20:12
Rotoscale
-- rotoscale!
-- by eiyeron
-- 07/04/2015
-- a good old demo effect! :3
-- retroactive.me/retro-actif
-- thanks zep for everything!:)
-- for pico-8, the code and
-- voxatron!
-- iirc local vars are faster
local t, angle, scale = 0, 0, 1