Skip to content

Instantly share code, notes, and snippets.

View rayyee's full-sized avatar
🌴
On vacation

Ray Yee rayyee

🌴
On vacation
View GitHub Profile
@rayyee
rayyee / StructPointerVariable.c
Last active December 10, 2015 23:18
结构指针变量
int main()
{
struct A
{
int a;
}varA,*p;
p = &varA;
p->a = 13;
printf("%d,%d,%d",p->a,(*p).a,varA.a);
return 0;
int main()
{
int i = 0, a[10] = {1,21,54,5848,46,4,15,415,4,45};
int *pa = a+3;
sort(pa, 6);
for (;i < 6; i += 1)
{
printf("%d%s", pa[i], ",");
}
return 0;
@rayyee
rayyee / DynamicMemoryManager.as
Created February 16, 2013 08:26
利用Dictionary的弱引用实现的动态内存管理
/**
* Copyright (c) 2013 Ray Yee. All rights reserved.
*
* @author Ray Yee
* Created 2013-2-16 下午3:37:51
**/
package eg
{
import flash.utils.Dictionary;
package com.rayyee.reflect
{
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.utils.describeType;
import flash.utils.getDefinitionByName;
import flash.utils.getQualifiedClassName;
/**
package utils
{
import com.adobe.utils.AGALMiniAssembler;
import flash.display3D.*;
import flash.geom.*;
import starling.core.RenderSupport;
import starling.core.Starling;
import starling.display.DisplayObject;
@rayyee
rayyee / ReadUtfBytes.as
Created February 11, 2014 14:07
Read utf string from bytes file.
/**
* 从未知编码的二进制流中读取文本
* @param ba
* @param len 读取长度,默认为-1,则读取至文件尾
* @return
*/
public static function readString(ba:ByteArray,len:int = -1):String
{
if ((len != -1 && len > ba.bytesAvailable) || (len == -1)) len = ba.bytesAvailable;
var encode:String = 'gb2312';
@rayyee
rayyee / AsPrototype.as
Created February 11, 2014 14:13
as3 prototype test.
//给数组原型增加一个获取随机数组元素的方法:randomItem
Array.prototype.getRandomItem = function(): *
{
return this[Math.floor(Math.random() * this.length)];
};
//这里设置这个方法不可被(for...in、foreach...in)枚举,非常重要!
Array.prototype.setPropertyIsEnumerable('getRandomItem', false);
var arr:Array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
/**
* User: Ray Yee
* Date: 14-3-6
* All rights reserved.
*/
package
{
import flash.filters.ColorMatrixFilter;
public class ColorMatrixUtility
{
"selector": "source.jsfl",
"cmd": ["Flash" ,"$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)"
}
/**
* Copyright (c) 2013 Amos Laber
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*