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 / gist:9304943
Created March 2, 2014 11:01
listing directories with redtamarin
import C.errno.*;
import C.dirent.*;
trace( "----" );
var dirp:DIR = opendir( "." );
if( !dirp )
{
trace( "Could not open directory \".\"" );
}
@zwetan
zwetan / gist:9307610
Created March 2, 2014 14:46
more advanced example to list directories with redtamarin
import C.errno.*;
import C.stdlib.*;
import C.dirent.*;
import C.fcntl.*;
import C.sys.stat.*;
trace( "----" );
/* note:
@zwetan
zwetan / gist:9330194
Created March 3, 2014 17:36
custom directory listing with redtamarin
import C.errno.*;
import C.stdlib.*;
import C.dirent.*;
import C.sys.stat.*;
trace( "----" );
function getFilesBySize( dirname:String, smallerFirst:Boolean = true ):Array
{
var entries:Array = [];
@zwetan
zwetan / gist:9378352
Last active August 29, 2015 13:57
All about listing files and directories with redtamarin
import C.dirent.*;
import C.sys.stat.*;
import C.unistd.*;
/**
* Returns a list of files.
*/
public function getfiles( path:String = "." ):Array
{
var files:Array = [];
@zwetan
zwetan / test_getsockopt.c
Last active August 29, 2015 14:07
strangely getsockopt() return 4 instead of 1 for some options
//...
struct addrinfo hints, *res;
int sockfd;
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;
int result = getaddrinfo(NULL, "3490", &hints, &res);
@zwetan
zwetan / getaddrinfo usage
Last active August 29, 2015 14:07
obtain all the IP addresses of a hostname
import C.errno.*;
import C.arpa.inet.*;
import C.netdb.*;
import C.sys.socket.*;
import C.stdlib.*;
import C.unistd.*;
var hostname:String = "www.google.com";
trace( "hostname = " + hostname );
@zwetan
zwetan / getaddrinfo usage2
Created October 14, 2014 15:58
obtain all the IP addresses of the localhost
import C.errno.*;
import C.arpa.inet.*;
import C.netdb.*;
import C.sys.socket.*;
import C.stdlib.*;
import C.unistd.*;
var hostname:String = gethostname();
trace( "hostname = " + hostname );
@zwetan
zwetan / index.as
Created October 31, 2014 19:00
CGI example 1
/* build:
import redbean.*;
import shell.FileSystem;
compile( "src/index.as" );
if( FileSystem.exists( "index.abc" ) )
{
@zwetan
zwetan / index.as
Last active August 29, 2015 14:08
CGI example 2
/* build:
import redbean.*;
import shell.FileSystem;
compile( "src/index.as" );
if( FileSystem.exists( "index.abc" ) )
{
@zwetan
zwetan / display.as
Created October 31, 2014 20:13
CGI example 3
import C.stdio.*;
import flash.utils.ByteArray;
import shell.FileSystem;
import shell.Program;
/* NOTE:
trace() add a carriage return
better use Program.write() to
control exactly the char return at end of line
*/