Skip to content

Instantly share code, notes, and snippets.

View gonchar's full-sized avatar

Sergey Gonchar gonchar

View GitHub Profile
var gulp = require('gulp');
var glob = require('glob');
var path = require('path');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var transform = require('vinyl-transform');
var exorcist = require('exorcist');
var sourcemaps = require('gulp-sourcemaps');
var argv = require('yargs').argv;
var watchify = require('watchify');
/** Parses dates that conform to the xs:DateTime format. */
public static function parse(str : String) : Date {
if (str == null) return null;
var finalDate : Date;
try {
var dateStr : String = str.substring(0, str.indexOf("T"));
var timeStr : String = str.substring(str.indexOf("T") + 1, str.length);
var dateArr : Array = dateStr.split("-");
[alias]
# full status
s = !git status -sb --ignore-submodules=dirty && git submodule foreach --recursive git status -sb --ignore-submodules=dirty
# updates project and all submodules
up = !git submodule foreach --recursive git pull --rebase && git pull --rebase
# updates and creates all submodules (can move sumbmodules from there brunches)
subup = submodule update --init --recursive
# fetches all modules
rfetch = !git fetch && git submodule foreach --recursive git fetch
# mergeBranch(from, to) e.g. git bft master next
@gonchar
gonchar / MethodClosureTest.as
Created April 4, 2015 20:48
methodclosure object is not cleaned from memory
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.utils.getTimer;
public class MethodClosureTest extends Sprite {
public function MethodClosureTest() {
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
@gonchar
gonchar / gist:4eef3c0798a96f6c9530
Created March 29, 2015 10:41
Particle Fire Effect Example
package {
import starling.extensions.sap.ParticleEffect;
import starling.extensions.sap.ParticlePrototype;
import starling.extensions.sap.ParticleTextureAtlas;
import flash.display3D.Context3DBlendFactor;
import flash.geom.Vector3D;
import flash.utils.setTimeout;
@gonchar
gonchar / TextureGenerator.as
Last active August 29, 2015 13:56
generate orientation texture
public static function generateOrientationTexture(size:int):BitmapData {
var half:uint = size / 2;
var bmd:BitmapData = new BitmapData(size, size, false, 0x000000);
for (var i:uint = 0; i < size; i++) {
for (var j:uint = 0; j < size; j++) {
var directionX:Number = i - half;
var directionY:Number = j - half;
var length:Number = Math.sqrt(directionX * directionX + directionY * directionY);
directionX /= length;
directionY /= length;
@gonchar
gonchar / speedTest.cpp
Last active January 2, 2016 21:38
Crossbridge test
//
//
//Time:
//
//0.195312 - All browsers with FlashPlayer 11.9 release http://i.imgur.com/0WrbiVP.png
//0.203 - exe compiled with MSVC in release http://i.imgur.com/9aUm4TZ.png
//
//Download swf - https://www.dropbox.com/s/0vwvvo04d179gef/speedTest.swf
//
//Compile in Crossbridge /cygdrive/c/flascc/sdk/usr/bin/g++.exe speedTest.cpp -O4 -emit-swf -o speedTest.swf
@gonchar
gonchar / trace
Created January 6, 2014 00:14
Trace for VisualStudio
#include <sstream>
#include <thread>
#include <cstdio>
#include <cstdarg>
#include <cwchar>
#include <cstdlib>
#include <windows.h>
struct DebugOutImpl {
DebugOutImpl(const char* location, int line, bool enabled_ = true)
@gonchar
gonchar / ConditionTest.as
Created December 26, 2013 11:28
it's not about a deep optimization. That test shows you that you can freely write more readable code and it will be fast. the winner if(a == null) a = new Object(); don't use a||=new Object(); a = a || new Object(), because it looks like |\||\|\+_)+_)(_(*(^&(*&%&*^%$%^$ :D
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.utils.getTimer;
public class ConditionTest extends Sprite {
public function ConditionTest() {
testTime();
@gonchar
gonchar / ConditionTest.as
Created December 26, 2013 00:57
a||=new Object() a = a || new Object() if(!a) a = new Object();
package {
import flash.display.Sprite;
public class ConditionTest extends Sprite{
public function ConditionTest() {
}
private function func1():void {
var a:Sprite;