AS3 XMLSocket : Cannot receive response from socket server…

In XMLSocket documentation you can find few Events. One of them is DataEvent.DATA.
Purpose of it is to inform that data from SocketServer was received.

This event will not be dispatch until message from SocketServer ends with special ending string: \0

Message from SocketServer\0

For testing purpose I have used SocketServer && SocketClient written in Groovy by author of this post. Below SocketServer example returns what received.

SocketServer (with little modification):

import java.net.ServerSocket
def server = new ServerSocket(6667)

while(true) {
    server.accept { socket ->
        println "processing new connection..."
        socket.withStreams { input, output ->
            def reader = input.newReader()
            def buffer = reader.readLine()
            println "server received: $buffer"
            now = new Date()
            output << "echo-response($now): " + buffer + "\0"
        }
        println "processing/thread complete."
    }
}

ClientServer:

s = new Socket("127.0.0.1", 6667);
s.withStreams { input, output ->
  output << "\n"
  buffer = input.newReader().readLine()
  println "response = $buffer"
}

OpenTok


Scripting: Groovy generates CSS

Groovy is awesome for creating scripts in 20s :

["top":"to","bottom":"bo","right":"ri","left":"le"].each{ w ->
    (0..20).each {
      if(it%2==0) println ".${w.value}-${it}{padding-${w.key}: ${it}px;}"
    }
}

In result you retrieve:

.to-0{padding-top: 0px;}
.to-2{padding-top: 2px;}
.to-4{padding-top: 4px;}
.to-6{padding-top: 6px;}
.to-8{padding-top: 8px;}
.to-10{padding-top: 10px;}
.to-12{padding-top: 12px;}
.to-14{padding-top: 14px;}
.to-16{padding-top: 16px;}
.to-18{padding-top: 18px;}
.to-20{padding-top: 20px;}
.bo-0{padding-bottom: 0px;}
.bo-2{padding-bottom: 2px;}
.bo-4{padding-bottom: 4px;}
.bo-6{padding-bottom: 6px;}
.bo-8{padding-bottom: 8px;}
.bo-10{padding-bottom: 10px;}
.bo-12{padding-bottom: 12px;}
.bo-14{padding-bottom: 14px;}
.bo-16{padding-bottom: 16px;}
.bo-18{padding-bottom: 18px;}
.bo-20{padding-bottom: 20px;}
.ri-0{padding-right: 0px;}
.ri-2{padding-right: 2px;}
.ri-4{padding-right: 4px;}
.ri-6{padding-right: 6px;}
.ri-8{padding-right: 8px;}
.ri-10{padding-right: 10px;}
.ri-12{padding-right: 12px;}
.ri-14{padding-right: 14px;}
.ri-16{padding-right: 16px;}
.ri-18{padding-right: 18px;}
.ri-20{padding-right: 20px;}
.le-0{padding-left: 0px;}
.le-2{padding-left: 2px;}
.le-4{padding-left: 4px;}
.le-6{padding-left: 6px;}
.le-8{padding-left: 8px;}
.le-10{padding-left: 10px;}
.le-12{padding-left: 12px;}
.le-14{padding-left: 14px;}
.le-16{padding-left: 16px;}
.le-18{padding-left: 18px;}
.le-20{padding-left: 20px;}

VirtualBox: Shared folders and permission denied

Add group to user:

/usr/sbin/usermod -a -G vboxsf user

List Groups A User Belongs To In Unix:

ubuntu$ groups greys
greys : admin www-data

Windows: List all environment variables

I have just realized there is simple command for listing all environment variables in win7.
Open CMD and type:

ENV

In result you receive:

!::=::\
!C:=C:\Users\USER_NAME
!EXITCODE=00000000
ALLUSERSPROFILE=C:\ProgramData
AMDAPPSDKROOT=C:\Program Files (x86)\AMD APP\
ANT_HOME=G:\base\apps\ant\apache-ant-1.8.1
APPDATA=C:\Users\USER_NAME\AppData\Roaming
CLASSPATH=.;C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip
COMMONPROGRAMFILES=C:\Program Files (x86)\Common Files
COMMONPROGRAMFILES(X86)=C:\Program Files (x86)\Common Files
COMMONPROGRAMW6432=C:\Program Files\Common Files
COMPUTERNAME=DESKTOP
COMSPEC=C:\Windows\system32\cmd.exe
FIREFOX=C:\Program Files (x86)\Mozilla Firefox
FLEX_HOME=G:\base\sdk\flex_sdk_4.0.0.14159
FP_NO_HOST_CHECK=NO
GNUPLOT=D:\apps\gnuplot\binaries\
GRADLE_HOME=G:\base\apps\gradle\gradle-1.0-milestone-3
GRAILS_HOME=G:\base\apps\grails\1.3.3
GROOVY_HOME=C:\Program Files (x86)\Groovy\groovy-1.8.0
HOMEDRIVE=C:
HOMEPATH=\Users\USER_NAME
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_19
LOCALAPPDATA=C:\Users\USER_NAME\AppData\Local
LOGONSERVER=\\DESKTOP
NUMBER_OF_PROCESSORS=8
OS=Windows_NT
PATH=/c/Program Files/Common Files/Microsoft Shared/Windows Live:/c/Program Files (x86)/Common Files/Microsoft Shared/Windows Live:/c/Program Files (x86)/AMD APP/bin/x86_64:/c/Program Files (x86)/AMD APP/bin/x86:/c/Program Files/ImageMagick-6.6.0-Q16:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/c/Program Files (x86)/Java/jdk1.6.0_19/bin:/c/Program Files (x86)/Groovy/groovy-1.8.0/bin:/d/apps/gnuplot/binaries/:/c/Program Files (x86)/QuickTime/QTSystem/:/c/Program Files (x86)/ATI Technologies/ATI.ACE/Core-Static:/g/base/apps/grails/1.3.3/bin:/c/Program Files/TortoiseSVN/bin:/bin:/d/apps/gnuplot/binaries/:/d/apps/play:/g/base/apps/gradle/gradle-1.0-milestone-3/bin:/g/base/apps/ant/apache-ant-1.8.1/lib:/g/base/apps/grails/1.3.3/bin:/c/Program Files (x86)/Java/jdk1.6.0_19/bin:/g/base/sdk/flex_sdk_4.0.0.14159/bin:/c/Program Files (x86)/Calibre2/:/c/Program Files (x86)/Mozilla Firefox:/c/Program Files (x86)/Windows Live/Shared:/g/base/apps/gradle/gradle-1.0-milestone-3/bin:/c/Program Files (x86)/TortoiseSVN/bin:/c/Program Files (x86)/scala/bin:/c/Program Files/Mercurial
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.groovy;.gy
PLAY=D:\apps\play
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_ARCHITEW6432=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 30 Stepping 5, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=1e05
PROGRAMDATA=C:\ProgramData
PROGRAMFILES=C:\Program Files (x86)
PROGRAMFILES(X86)=C:\Program Files (x86)
PROGRAMW6432=C:\Program Files
PROMPT=$P$G
PSMODULEPATH=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC=C:\Users\Public
QTJAVA=C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip
SCALA_HOME=C:\Program Files (x86)\scala
SESSIONNAME=Console
SYSTEMDRIVE=C:
SYSTEMROOT=C:\Windows
TEMP=/tmp
TMP=/tmp
USERDOMAIN=DESKTOP
USERNAME=USER_NAME
USERPROFILE=C:\Users\USER_NAME
VBOX_INSTALL_PATH=C:\Program Files\Oracle\VirtualBox\
WINDIR=C:\Windows
TERM=cygwin

Gradle: Copy dir with ant and groovy

Simple gradle task written in groovy which copy one dir into another and list all files matched by extension.
Inside task you can find one tiny example of formating date in Groovy. Seems to be obvious, but wasn’t for me…

task deploy << {
	def today = new Date().format("dd-MM-yyyy");
	def srcPath= "G:/projects/job/2011/PROJECT_NAME/fb-bin"
	def desPath = "X:/My Dropbox/Public/PROJECT_NAME/"+today

	println "date: " + today;
	ant.copy(todir: desPath) {
		fileset(dir : srcPath )
	}
	new File(desPath).listFiles(
		[accept:{file-> file ==~ /.*?\.swf/ }] as FileFilter
	).toList()
	 .each{
		 f -> println  "$f,"+ Math.floor(f.size()/1024);
	 }
}

Path to SharedObject (Flash Player Cookies) in Windows 7

Path to SharedObject in Win:

%appdata%\Macromedia\Flash Player\#SharedObjects

You can easily create SharedObject.bat file which will open SharedObject directory. See below image:


Portable web server in java used for flash/flex development

Finally I have found very simple web server, which is portable and easy to run.
Hero of the day is Jibble Web Server.
It allows me to workaround problems with SecurityError in Flash Player when try to load local file from flash/flex app.
The most important features for me are:

  • ZERO installation (JVM)
  • simple configuration (path + port)
  • works everywhere (JVM)

You can run it by typing:

java -jar WebServerLite.jar g:\projects\flex 89

Thanks !


Macros in Flash Develop

List all gradle tasks in fast mode (with –daemon arg) directly:

cmd.exe;/k gradle -t --daemon




Flash develop : editing macro which lists gradle tasks


ImageMagick tips

convert -resize 300×175 *.jpg
convert -delay 40 -loop 0 album.gif
mogrify -quality 80% -resize 300×175 *.jpg