Skip to content

Instantly share code, notes, and snippets.

View AxGord's full-sized avatar
🦄
Pony

Alexander Gordeyko AxGord

🦄
Pony
View GitHub Profile
@city41
city41 / composite.js
Created January 29, 2012 03:33
Alpha compositing in JavaScript
function _composite(under, over) {
var alphaO = over[3],
alphaU = under[3],
invAlphaO = 1 - alphaO,
i,
len;
for(i = 0, len = under.length - 1; i < len; ++i) {
under[i] = Math.round((over[i] * alphaO)
+ ((under[i] * alphaU) * invAlphaO));
@adamawolf
adamawolf / Apple_mobile_device_types.txt
Last active April 30, 2024 11:57
List of Apple's mobile device codes types a.k.a. machine ids (e.g. `iPhone1,1`, `Watch1,1`, etc.) and their matching product names
i386 : iPhone Simulator
x86_64 : iPhone Simulator
arm64 : iPhone Simulator
iPhone1,1 : iPhone
iPhone1,2 : iPhone 3G
iPhone2,1 : iPhone 3GS
iPhone3,1 : iPhone 4
iPhone3,2 : iPhone 4 GSM Rev A
iPhone3,3 : iPhone 4 CDMA
iPhone4,1 : iPhone 4S
@tong
tong / nacl-toolchain.xml
Created February 2, 2013 12:30
NativeClient toolchain file for HXCPP
<!-- NativeClient hxcpp toolchain -->
<xml>
<include name="gcc-toolchain.xml"/>
<path name="${NACL_SDK_ROOT}/toolchain/linux_x86_newlib/bin"/>
<set name="M" value="32" unless="HXCPP_M64" />
@Simn
Simn / AbstractBuilder.hx
Created February 22, 2013 07:48
Haxe abstract builder example
import haxe.macro.Context;
import haxe.macro.Expr;
import haxe.macro.Type;
class AbstractBuilder {
macro static public function build():Array<Field> {
var fields = Context.getBuildFields();
var cCur = Context.getLocalClass().get();
var fieldMap = [for (f in fields) f.name => true];
function loop(c:ClassType) {
@Simn
Simn / Main.hx
Created August 2, 2013 08:32
Haxe generic type parameter construction
typedef Constructible = {
public function new():Void;
}
@:generic
class Gen<T:(Constructible, Main)> {
public function new() { }
public function make() {
return new T();
@nadako
nadako / SchemaTypeBuilder.hx
Last active October 31, 2020 03:34
JSON-schema type builder prototype.
#if macro
import haxe.macro.Context;
import haxe.macro.Expr;
class SchemaTypeBuilder
{
public static function build(ref:String):haxe.macro.Type
{
var schema = haxe.Json.parse(sys.io.File.getContent(ref));
var type:ComplexType = parseType(schema);
import haxe.macro.Expr;
class FTW
{
public static function build()
{
return haxe.macro.Context.getBuildFields().map(transformField);
}
static function transformField(field:Field)
@RealyUniqueName
RealyUniqueName / Exception.hx
Created November 28, 2013 12:09
Simple exception class with stack information
package fst.exception;
import haxe.CallStack;
/**
* Exceptions base
*
*/
class Exception {
@nadako
nadako / DynamicMap.hx
Last active January 2, 2016 22:29
Abstract wrapper for Dynamic objects.
/**
* Simple wrapper for anonymous structures that are meant to be used as a
* keyed collection of objects of the same type (i.e. json object).
*
* Wraps Reflect calls with nice syntax and static typing without any
* runtime overhead.
*/
abstract DynamicMap<V>(Dynamic<V>) from Dynamic<V>
{
/**
@nadako
nadako / Main.hx
Created January 19, 2014 13:29
stack-allocated pair iterator
class Main
{
static function main()
{
var a = ["a", "b", "c"];
for (p in new IndexIter(a))
{
trace(p.idx);
trace(p.val);