Skip to content

Instantly share code, notes, and snippets.

View zwetan's full-sized avatar
🌀
getting shit done

Zwetan Kjukov zwetan

🌀
getting shit done
View GitHub Profile
@zwetan
zwetan / index3.as3
Created November 2, 2014 23:41
debugging CGI
try
{
import C.stdio.*;
import flash.utils.ByteArray;
function write( message:String = "" ):void
{
var bytes:ByteArray = new ByteArray();
bytes.writeUTFBytes( message );
#!/usr/bin/as3shebang --
/* Note:
Again the joy of using POSIX from AS3 :p
see:
Copy a file in an sane, safe and efficient way
http://stackoverflow.com/questions/10195343/copy-a-file-in-an-sane-safe-and-efficient-way
BUFSIZ
@zwetan
zwetan / colored.as
Last active August 29, 2015 14:19
ANSI colors in your AS3 scripts ;)
#!/usr/bin/as3shebang --
// see http://en.wikipedia.org/wiki/ANSI_escape_code
package ansi
{
import flash.utils.describeType;
import shell.Program;
public class controls
{
@zwetan
zwetan / test_mkdirp.as
Created April 22, 2015 11:29
Create a new directory and intermediate directories as required
#!/usr/bin/as3shebang --
/* Note:
mkdir() creates directoy
but can not creates directory tree
the command line "$ mkdir -p" allows that
so here a small util function to emulate that
behaviour
*/
@zwetan
zwetan / test_which.as
Created May 10, 2015 08:55
implementation of the shell utility "which"
#!/usr/bin/as3shebang --
import C.stdlib.*; // getenv, exit, EXIT_SUCCESS, EXIT_FAILURE
import C.unistd.*; // access, X_OK, getlogin
import C.sys.stat.*; // stat, status, S_ISREG, S_IXUSR, S_IXGRP, S_IXOTH
/* NOTE:
Inside Bash scripts you often encounter
svn = ${`which svn`}
to get the full path of an executable
#!/usr/bin/as3shebang --
import flash.utils.*;
import shell.*;
import C.stdlib.*;
/* NOTE:
how to embed binaries in plain text
in our case how to embed ABC libraries in shell scripts
@zwetan
zwetan / test_binembed.as
Created May 10, 2015 14:13
how to embed an ABC library as string into a shell script
#!/usr/bin/as3shebang --
import flash.utils.*;
import shell.*;
function ansilib():*
{
var hex:String = "10002e00000000990100054172726179066c656e6774680c616e73696c69622e617324310d656e636f";
hex += "64696e672e616e736921687474703a2f2f61646f62652e636f6d2f4153332f323030362f6275696c74";
hex += "696e05726573657406537472696e6716656e636f64696e672e616e73693a636f6e74726f6c73041b5b";
@zwetan
zwetan / pdf2png.as
Last active August 29, 2015 14:21
build a simple command line tool with as3shebang : a pdf to png converter
#!/usr/bin/as3shebang --
import C.errno.*; // errno CError
import C.stdlib.*; // exit EXIT_SUCCESS EXIT_FAILURE system
import C.stdio.*; // remove
import C.unistd.*; // access F_OK
import C.sys.stat.*;
import shell.*;
@zwetan
zwetan / test_async.as
Created May 29, 2015 03:33
async, event and timers in redtamarin -- alpha quality
#!/usr/bin/as3shebang --
import shell.Program;
import shell.Runtime;
import flash.events.TimerEvent;
import flash.utils.Timer;
Program.atExit( function() { trace( "I'm out" ); } );
@zwetan
zwetan / test_delay.as
Created May 29, 2015 03:42
a basic "forever loop"
#!/usr/bin/as3shebang --
import C.stdlib.*; // exit
import C.unistd.*; // sleep
var i:uint = 0;
function show():void
{
trace( "hello", i );
i++;