Development – DanDev.com http://www.dandev.com Tidbits about software development Sat, 26 Oct 2013 00:24:13 +0000 en-US hourly 1 Compiling php-python on Fedora Linux http://www.dandev.com/2012/11/compiling-php-python-on-fedora-linux/ http://www.dandev.com/2012/11/compiling-php-python-on-fedora-linux/#respond Tue, 13 Nov 2012 04:25:17 +0000 http://www.dandev.com/?p=354 So, I haven’t posted in a while, and I felt it was about time to get some fresh content up here so what follows is the result of some research […]

The post Compiling php-python on Fedora Linux appeared first on DanDev.com.

]]>
So, I haven’t posted in a while, and I felt it was about time to get some fresh content up here so what follows is the result of some research and testing I did as a result of re-visiting a question on SuperUser that I responded to over a year ago that was never fully resolved.

So, you want to run python code in PHP, eh? Why you might ask? Well, I’m not quite sure. I haven’t run in to a use case for it myself, but I can see where you might need to do some heavy-duty maths or maybe there is a python library that you require for some custom algorithm or something.

Good news! There is a PECL library you can use for this task: http://pecl.php.net/package/python
Unfortunately, it hasn’t been updated in over 4 years at the time of this writing and was in alpha at the time of the last release.
However! The maintainer appears to still be working on the package, but over a GitHub: https://github.com/jparise/php-python
Unfortunately, it still doesn’t compile on PHP 5.4 (in Fedora at least)
However! I got it to work with some minor tweaks.

Here is the process that works with the current PHP version (5.4.8 at the time of this writing) linking to python 2.7:

Install build tools and minimum deps:

yum groupinstall "Development Tools"
yum install php-common php-pear php-devel python python-devel wget

Get a copy of the latest version of php-python:

git clone https://github.com/jparise/php-python.git php-python

Apply the patch to fix C syntax errors. Note that this patch is likely to be broken and/or not necessary some time in the future when php-python is updated. But the changes are simple so you can apply them manually if they are still needed in future versions. Gist also available here: https://gist.github.com/drener/7149541

wget http://www.dandev.com/other/post_content/php-python_20121112.diff
patch -p0 < php-python_20121112.diff

Build the module

cd php-python
phpize
./configure
make
make install

After this is complete you need to edit your php.ini to enable the new module. Add a line like this:

extension=python.so

Once php.ini is updated you should be able to see the "python" module listed in the "php -m" modules list, and you should be able to use the python functions. Restart Apache if you are using mod_php to load the updated php.ini file. The examples folder on GitHub has some code you can use to see the Python features in action: https://github.com/jparise/php-python/tree/master/examples

Good luck!

The post Compiling php-python on Fedora Linux appeared first on DanDev.com.

]]>
http://www.dandev.com/2012/11/compiling-php-python-on-fedora-linux/feed/ 0
Displaying the version number in Adobe AIR http://www.dandev.com/2011/10/displaying-the-version-number-in-adobe-air/ http://www.dandev.com/2011/10/displaying-the-version-number-in-adobe-air/#respond Wed, 12 Oct 2011 04:00:55 +0000 http://www.dandev.com/?p=220 In the Adobe AIR application descriptor file there are many options you can set. One of which is the tag(or in Flex SDK v4.1 and below), which lets you differentiate […]

The post Displaying the version number in Adobe AIR appeared first on DanDev.com.

]]>
In the Adobe AIR application descriptor file there are many options you can set. One of which is the tag(or in Flex SDK v4.1 and below), which lets you differentiate your release as well as utilize the Adobe AIR updater library.

It can be useful to display your version number inside of your app to inform the user as well as help with bug reports among other reasons. In order to prevent you from having to update the version number in multiple places you can use AS3 to grab it from the application descriptor and update your text for your app on the fly, as it loads. Here is an example of how to do that:


		

Flex Builder Project

The post Displaying the version number in Adobe AIR appeared first on DanDev.com.

]]> http://www.dandev.com/2011/10/displaying-the-version-number-in-adobe-air/feed/ 0 Add a click event to a BitmapImage in Adobe Flex/AIR http://www.dandev.com/2011/10/add-a-click-event-to-a-bitmapimage-in-adobe-flexair/ http://www.dandev.com/2011/10/add-a-click-event-to-a-bitmapimage-in-adobe-flexair/#respond Wed, 05 Oct 2011 04:00:29 +0000 http://www.dandev.com/?p=215 You may have noticed MouseEvent.Click is not an event available to be set on the BitmapImage Spark primitive(in the current Flex SDK). But, there is a simple workaround for this. […]

The post Add a click event to a BitmapImage in Adobe Flex/AIR appeared first on DanDev.com.

]]>
You may have noticed MouseEvent.Click is not an event available to be set on the BitmapImage Spark primitive(in the current Flex SDK). But, there is a simple workaround for this. All you have to do is place it inside of a Graphic primitive wrapper. In MXML it would look like this:



	
	
		
	
	
		
	
	
	
		
			
		
	
	

Flex Builder Project

In AS3 it looks like this:



	
	
		
	
	
		
	
	
	
	
	

Flex Builder Project

The post Add a click event to a BitmapImage in Adobe Flex/AIR appeared first on DanDev.com.

]]>
http://www.dandev.com/2011/10/add-a-click-event-to-a-bitmapimage-in-adobe-flexair/feed/ 0
VerifyError: Error #1014: Class IIMEClient could not be found. http://www.dandev.com/2010/07/verifyerror-error-1014-class-iimeclient-could-not-be-found/ http://www.dandev.com/2010/07/verifyerror-error-1014-class-iimeclient-could-not-be-found/#comments Mon, 12 Jul 2010 03:49:55 +0000 http://www.dandev.com/?p=189 If you have run across this error recently: VerifyError: Error #1014: Class IIMEClient could not be found. You may be wondering what it means, and more importantly how to fix […]

The post VerifyError: Error #1014: Class IIMEClient could not be found. appeared first on DanDev.com.

]]>
If you have run across this error recently: VerifyError: Error #1014: Class IIMEClient could not be found.

You may be wondering what it means, and more importantly how to fix it. What appears to be the sole cause of this error is your versions not matching up between your Flex/AIR SDK and the AIR application descriptor file. This can happen after you update/reinstall Flash Builder, or the SDK folder manually.

The fix is pretty easy: Just open your AIR descriptor file(generally the only XML file in the project src folder) and change the xmlns to the current version of the SDK you are using(1.5.3 => 2.0 for instance). See screenshot below for an example(warning: it’s big):

The post VerifyError: Error #1014: Class IIMEClient could not be found. appeared first on DanDev.com.

]]>
http://www.dandev.com/2010/07/verifyerror-error-1014-class-iimeclient-could-not-be-found/feed/ 13
Flex HDividedBox/VDividedBox divider double-click event oddity http://www.dandev.com/2009/12/hdividedbox/ http://www.dandev.com/2009/12/hdividedbox/#comments Wed, 02 Dec 2009 02:30:05 +0000 http://www.dandev.com/?p=171 I ran across an interesting case today while looking into an issue for someone else related to capturing the double-click event on the divider for a HDividedBox. It’s a little […]

The post Flex HDividedBox/VDividedBox divider double-click event oddity appeared first on DanDev.com.

]]>
I ran across an interesting case today while looking into an issue for someone else related to capturing the double-click event on the divider for a HDividedBox. It’s a little tricky to get the event to be captured by Flex. A quick search of the interwebs turned up nothing but people with the same issue. There is even an open bug in the Adobe Flex bug tracker(you have to login) that seems to be the exact issue, but there is no resolution named. Through some quick experimentation I figured out you can get it to work like so:



    
          
          		
          
          
          		
	      
     
     
          

The specific resolution was to enable liveDragging and add the event to the divider itself(most people try to set it on the doubleClick property of the DividerBox).

Hopefully this post will be helpful to some people out there with the same issue!

The post Flex HDividedBox/VDividedBox divider double-click event oddity appeared first on DanDev.com.

]]>
http://www.dandev.com/2009/12/hdividedbox/feed/ 7
GAIQ Certified! http://www.dandev.com/2009/11/gaiq-certified/ http://www.dandev.com/2009/11/gaiq-certified/#respond Sun, 15 Nov 2009 23:39:50 +0000 http://www.dandev.com/?p=169 So, I took the GAIQ certification test the other day and passed. It was a little harder than I expected, but not too crazy. I definitely recommend you watch all […]

The post GAIQ Certified! appeared first on DanDev.com.

]]>
So, I took the GAIQ certification test the other day and passed. It was a little harder than I expected, but not too crazy. I definitely recommend you watch all of the Google Conversion University videos about GA and be ready to look things up if you aren’t sure. A lot of the questions were common sense, but there were a few tricky ones that required some advanced knowledge.

The post GAIQ Certified! appeared first on DanDev.com.

]]>
http://www.dandev.com/2009/11/gaiq-certified/feed/ 0
Flex Tip: Accessing your AS functions/properties from imported classes http://www.dandev.com/2009/05/flex-tip-accessing-your-as-functionsproperties-from-imported-classes/ http://www.dandev.com/2009/05/flex-tip-accessing-your-as-functionsproperties-from-imported-classes/#comments Mon, 25 May 2009 22:54:10 +0000 http://www.dandev.com/?p=151 Every once in a while you might run across a case where you need to access a property or method from the parent application, and you don’t have the ability […]

The post Flex Tip: Accessing your AS functions/properties from imported classes appeared first on DanDev.com.

]]>
Every once in a while you might run across a case where you need to access a property or method from the parent application, and you don’t have the ability to pass the value you need to the class. Or, for example, you’re debugging and you don’t want to write a bunch of code that you’ll have to remove later just to test the value of a variable.

So, with that said the process is fairly simple. The following is a hypothetical example of a class you have imported into your application:

package com.example.scope
{
    private var myVar:String = "This is NOT the value we're trying to get";

    public class scopeExample
    {
        public function scopeExample()
        {
            // Flex 4
            import mx.core.FlexGlobals; // make "FlexGlobals" available in the current scope
            trace(FlexGlobals.topLevelApplication.myVar); // outputs the value of myVar in the main application

            // Flex 3
            import mx.core.Application; // make "Application" available in the current scope
            trace(Application.application.myVar); // outputs the value of myVar in the main application
        }
    }
}

You could also use:

trace(parentDocument.myVar); // if the component is a child of the main application

I ran across a post on Holly Schinsky’s blog the other day that had good descriptions of the various scope keywords, and a few tips. All of which is good knowledge to possess, so check it out.

The post Flex Tip: Accessing your AS functions/properties from imported classes appeared first on DanDev.com.

]]>
http://www.dandev.com/2009/05/flex-tip-accessing-your-as-functionsproperties-from-imported-classes/feed/ 1
Flex/AIR Tips: Keyboard Codes http://www.dandev.com/2009/03/flex-tips-keyboard-codes/ http://www.dandev.com/2009/03/flex-tips-keyboard-codes/#respond Tue, 10 Mar 2009 09:40:22 +0000 http://www.dandev.com/?p=132 If you ever have the urge to capture a specific key pressed in Flex or AS3 in general, there is an excellent list of the keycodes, and costants you can […]

The post Flex/AIR Tips: Keyboard Codes appeared first on DanDev.com.

]]>
If you ever have the urge to capture a specific key pressed in Flex or AS3 in general, there is an excellent list of the keycodes, and costants you can use to represent them in your code here: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/ui/Keyboard.html

3-10-2009-5-36-24-am

You can use them statically(without instantiating an object) like so:

trace(Keyboard.TAB); // 9

The post Flex/AIR Tips: Keyboard Codes appeared first on DanDev.com.

]]>
http://www.dandev.com/2009/03/flex-tips-keyboard-codes/feed/ 0
Optimizing the SWF filesize for your Flex App http://www.dandev.com/2009/03/optimizing-the-swf-filesize-for-your-flex-app/ http://www.dandev.com/2009/03/optimizing-the-swf-filesize-for-your-flex-app/#comments Sun, 08 Mar 2009 14:32:20 +0000 http://www.dandev.com/?p=118 While wandering through the ginormous forest that is Flex I’ve noticed how the filesize grows exponentially when you start to add a lot of content, or some external libraries. This […]

The post Optimizing the SWF filesize for your Flex App appeared first on DanDev.com.

]]>
While wandering through the ginormous forest that is Flex I’ve noticed how the filesize grows exponentially when you start to add a lot of content, or some external libraries. This is annoying, especially when the app I’m making is supposed to be used by a large group of people at the company I work for. So, I went looking for ways to slim it down, and I have found a couple of gems that work really well. First of all there is an excellent video posted by Serge Jespers of the Adobe Platform Evangelism – European team that gives some detailed tips with an example of how to make your application smaller with Flex Builder.

Namely:

  1. Use “Release” build — by default the SWF is built with Debug mode and has debug & profiler code in it that your application doesn’t need.
  2. Move your panels into modules(see movie)
  3. Use the RSLs instead of compiling the Flex framework into your SWF

Using these suggestions has removed over 500K from my app.

The video shows you how to do all of these in Flex Builder.


Here is how you can perform the same optimizations in FlashDevelop:

Number 1 is fairly easy: Just find the only drop-down menu in the main interface, and change it from “Debug” to “Release”.

tip1

With number 2 you follow the same instructions, but you can get to the menu to add an item by right-clicking on your project in the “Project” pane of the right column, or by going to “File”->”New”.

tip2

Number 3 is slightly more complicated. First you need to get to your project’s properties menu, which you can do one of several ways. Here is a screenshot of going through the “Project” menu:

tip3-1

Then, click on the “Compiler Options” tab, and select the “Advanced Compiler Options” by clicking on it and clicking the “…” button. Then add the line “-static-rsls=false” to it as shown(or append it on a new line if you have other options set already).

tip3-3

Now, you have to copy the “framework_3.2.*.swf” and “framework_3.2.*.swz” files to the “bin” directory in your project, and upload them to your site when you upload your app. These contain the Flex framework that will be cached by the Flash Player when you run your app. They are located in “flex_sdk_3\frameworks\rsls” in the Flex 3 SDK folder. Note that whatever version of the SDK you compiled your app with is the version you have to use the RSLs from. If you compile your app on on build, and then try to use the RSLs from another one(ie. you switched machines/reinstalled the sdk/use another ide that uses a different sdk version, etc.) you will get a message when your app loads about RSL 1 loading(but it never will). So, if you reinstall the SDK, or any of the things I mentioned recompile your app with the new version. *phew*

I hope these tips are helpful to you!

The post Optimizing the SWF filesize for your Flex App appeared first on DanDev.com.

]]>
http://www.dandev.com/2009/03/optimizing-the-swf-filesize-for-your-flex-app/feed/ 2
Flex: getType() schmettype http://www.dandev.com/2009/03/flex-gettype-schmettype/ http://www.dandev.com/2009/03/flex-gettype-schmettype/#comments Sun, 08 Mar 2009 00:31:54 +0000 http://www.dandev.com/?p=112 I’ve started dabbling in Flex recently, and something that was apparent(and annoying at times) to me  early on was it’s strongly-typed nature. Not type as in a keyboard, but variable […]

The post Flex: getType() schmettype appeared first on DanDev.com.

]]>
I’ve started dabbling in Flex recently, and something that was apparent(and annoying at times) to me  early on was it’s strongly-typed nature. Not type as in a keyboard, but variable types. Flex cares very much whether your variable is an Array, or ArrayCollection as it’s knowledge of types is key to it’s processing. This is quite the converse to a language like PHP, which is loosely-typed to say the least.

Anyway, I came upon a case where I needed to know the type a variable was so I could cast it properly(and for debugging), and I found that Flex doesn’t have a function to simply return a variable’s type. There is describeType(), but this returns an XML object with all of the information about the variable — not just the type. Plus you have to import the proper class to use it. So, I threw together this function quickly that will perform the import, and return/alert the type as needed:

private function getType(value:*, alert:Boolean = false):String
{
	import flash.utils.*;
	var description:XML = describeType(value);
	if(alert)
		Alert.show(description[0].@name);
	return description[0].@name;
}

I hope someone else can find it useful. 🙂

The post Flex: getType() schmettype appeared first on DanDev.com.

]]>
http://www.dandev.com/2009/03/flex-gettype-schmettype/feed/ 9