RSS
 

Nginx Access Denied 403

01 Aug

Ran into a 403 error serving up a dynamic PHP script with a non-standard ending. My nginx config correctly passed it to PHP FPM however, the extension needs to be added to security.limit_extensions in the php fpm config.

http://ffct.cc/solving-nginx-php-fpm-access-denied-issue/

 
No Comments

Posted in Nginx

 

jQuery Tools Tooltip Positioning Fix

22 Jun

I started using jQuery Tool’s Tooltip today and ran into a position problem. When using bottom center the tooltip would position offscreen when the target was too close to the edge of the browser.

The following ticket notes include a proposed patch

To quickly update the minified version with the proposed fix replace

g=="left"&&(f-=i);return{top:e,left:f}}

with

g=="left"&&(f-=i); if(f<0){f=0}if(f+c.width()>$(window).width()){f=$(window).width()-c.width()} return{top:e,left:f}}

 
 

Trying to clone an uncloneable object of class stdClass

20 Jun

Ran into the following error recently:

PHP Fatal error: Trying to clone an uncloneable object of class stdClass in /wp-includes/cache.php

Adding the following to the PHP config fixed the error

; Adding for wp-e-commerce plugin
zend.ze1_compatibility_mode = Off

The ze1_compatiblity_mode is removed in PHP 5.3 so in that case I needed to wrap the clone calls with

function clone_it($data)
{
if(get_class($data) != ‘stdClass’)
return clone $data;
else
return unserialize(serialize($data));
}

 
 

Upgrading Ec2 Instance

10 Nov

Okay here’s the steps to upgrade an existing Ec2 EBS instance to a larger box

1) Right click on the instance and select Create Image (EBS AMI). This will take a few minutes
2) Go to your snapshots and right click on the new snapshot you just made select Create Volume from Snapshot
3) Create your new EC2 (larger) Instance.
4) Stop your new EC2 instance
5) Go to volumes, right click on your volume from step 2 and attach it to the new EC2 instance (/dev/sda1)
6) Detach the volume auto assigned to the new EC2 Instance
7) Start your new EC2 instance

 
No Comments

Posted in AWS, EC2

 

999 Tax Calculator

14 Oct

Okay, had some extra time on my hands and I was curious about the 999 Tax plan, so I wrote a calculator that gives you a good idea of your current tax burden vs a 9% sales tax + 9% income tax. http://999calc.com

 
3 Comments

Posted in RIA

 

Setting up Blazeds ( Tomcat ) on Amazon Ec2 à la Ubuntu

08 Oct

We’ll throw in some lamp and phpmyadmin in too for good mesure. These are the steps I recently used to setup an Ec2 box for some dev…

Step 1: Java

#See if we have it already
javac
sudo apt-get install sun-java6-jdk
#if no repo add it...
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
# and try again
sudo apt-get install sun-java6-jdk

Step 2: Tomcat

sudo apt-get install tomcat6 tomcat6-admin tomcat6-common tomcat6-user tomcat6-docs tomcat6-examples
sudo /etc/init.d/tomcat6 start
#modify user rights so you can use the webadmin gui
sudo pico /etc/tomcat6/tomcat-users.xml
sudo /etc/init.d/tomcat6 restart

#And if we want to autostart tomcat...

sudo pico /etc/init.d/tomcat

Insert the following
# Tomcat auto-start
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid

export JAVA_HOME=/usr/lib/jvm/java-6-sun

case $1 in
start)
sh /usr/local/tomcat/bin/startup.sh
;;
stop)
sh /usr/local/tomcat/bin/shutdown.sh
;;
restart)
sh /usr/local/tomcat/bin/shutdown.sh
sh /usr/local/tomcat/bin/startup.sh
;;
esac
exit 0

Now issue
sudo chmod 755 /etc/init.d/tomcat

sudo ln -s /etc/init.d/tomcat /etc/rc1.d/K99tomcat
sudo ln -s /etc/init.d/tomcat /etc/rc2.d/S99tomcat

Step 3: Blazeds

Copy up the blazeds WAR (assuming you’ve already downloaded blazeds on your localmachine)

scp -i ~/pathto/YOURPEM.pem blazeds.war ubuntu@someelasticip
sudo /etc/init.d/tomcat6 restart

Step 4: LAMP

tasksel --list-task
sudo tasksel install lamp-server

Step 5: phpmyadmin

sudo apt-get install phpmyadmin

Add the following line to /etc/apache2/apache2.conf:
Include /etc/phpmyadmin/apache.conf

sudo /etc/init.d/apache2 restart

Extra Credit: Xuggler for kicks

uname -m (verify which version of linux 32/64)

wget http://com.xuggle.s3.amazonaws.com/xuggler/xuggler-3.4.FINAL/xuggle-xuggler.3.4.1012-x86_64-unknown-linux-gnu.sh
mv xuggle-xuggler.3.4.1012-x86_64-unknown-linux-gnu.sh xuggle-xuggler.sh
chmod a+x ./xuggle-xuggler.sh
sudo ./xuggle-xuggler.sh

sudo pico /usr/share/tomcat6/bin/catalina.sh
add
export XUGGLE_HOME=/usr/local/xuggler
export LD_LIBRARY_PATH=$XUGGLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$XUGGLE_HOME/bin:$PATH

 
No Comments

Posted in RIA

 

Streaming Thinkorswim’s CNBC video feed on Mac

03 Nov

I was a bit disspointined to find that when I moved to Mac, I lost the video stream within thinkorswim. To stream the video on Mac a few simple steps are required

1) Install VLC
2) Click on the icon to run the video externally (lower right corner)

 
No Comments

Posted in RIA

 

Pentaho Kettle Scheduled Task: Windows

08 Jul

To run a Spoon/Kettle job from the command line (convenient for creating a scheduled task) use the following syntax:

kitchen.bat /rep:”REPOSITORY NAME” /job:”JOB NAME” /dir:/LOCATION /user:USER_NAME /pass:PASSWORD /level:Basic

Replace /job: with /file: to run a job from a file if you’re not using a repository.

 
3 Comments

Posted in RIA

 

Warehouse Dashboard Architecture

22 Jun

If Flex has a sweet spot, dashboards would be it. The technology provides a richness that makes engaging UIs very easy to implement.

For those evaluating possible solutions, I’m showcasing a simple architecture for a data warehouse / dashboard project. This particular architecture encapsulates the extract / transform so those are the only steps (simple SQL=>CSV) that need to be recreated for each environment (client) that has different source systems.

Warehouse Dashboard Architecture

 
No Comments

Posted in RIA

 

Flex OLAP Take Two

15 Jun

After running some OLAP benchmarks it was obvious that a more scalable OLAP solution was needed.

After some quick searching and downloading, I’ve wired up a scalable Flex OLAP UI.

I downloaded and setup Mondrian from Pentaho for my OLAP server. Mondrian supports XMLA making integration easy.

I found a few Flex projects interfacing to OLAP via XMLA. The most robust appears to be Grebulon by the guys over at Sherlock Informatics

Mondrian setup required a few tweaks, as I’m running Java 6:

Added the following JARs
axis.jar
commons-discovery-0.2.jar (removed commons-logging)
jaxrpc.jar
wsdl4j-1.5.1.jar
xalan.jar

Also set the following parameters in tomcat
-Djavax.xml.soap.MessageFactory=org.apache.axis.soap.MessageFactoryImpl
-Djavax.xml.soap.SOAPConnectionFactory=org.apache.axis.soap.SOAPConnectionFactoryImpl
-Djavax.xml.soap.SOAPFactory=org.apache.axis.soap.SOAPFactoryImpl
-Djavax.xml.transform.TransformerFactory=org.apache.xalan.processor.TransformerFactoryImpl

Using the FoodMart as a reference, the setup was very straight forward.

I had to download the Grebulon source as the .swcs had hardcoded in a few references (PivotGrid) to the FoodMart datasource.

Commercially, I’d check out FlexMonster too :)

 
1 Comment

Posted in RIA

 

Flex OLAP Benchmarks

14 Jun

I ran some benchmarks for the OLAP components in Flex. The OLAP components allow you to perform you’re OLAP operations client side out of the box. You *can* utilize the SDK interfaces and move your processing to the backend, should you have too much data for the browser.

That said, the benchmarks below should help define the line for “too much data.”

Record Structure:

Course:String
School:String
GradeLevel:String
SubjectArea:String
Grade:Number (Our measure)

Records / Processing Time (s)

1,000 / 3 sec
5,000 / 12 sec
10,000 / 22 sec
15,000 / 33 sec
20,000 / 43 sec

The processing times listed above are for the *client* side processing time. The data was loaded from the server before starting the benchmark.

I ran the benchmarks at various rollup depths (multiple hierarchies) which the components actually handled very well, the processing time was not significantly affected.

Extending the dataset to 125K+ records caused errors with the script timeouts occurring.

For datasets above 5-10K records, I’d suggest moving the processing to the server and passing the results to the UI. (assuming you’re looking to leverage the OLAP components as provided)

 
3 Comments

Posted in RIA

 

BlazeDS Custom Authentication

30 Apr

Here are the steps to roll your own BlazeDS Custom Authentication:

You’ll need to write a Java Class that implements the following class(es):

flex.messaging.security.LoginCommand;
flex.messaging.security.LoginCommandExt;

For example:

package com.dl.login;

import flex.messaging.security.LoginCommand;
import flex.messaging.security.LoginCommandExt;

import com.dl.login.UserVO;

public class LoginProxy implements LoginCommand,LoginCommandExt
{
public Principal doAuthentication(String username, Object attributes)
{

String password = (String)attributes;
//At this point you’d typically check against a datastore / LDAP / etc

if(username.equals(“riafan”) && password.equals(“mysecret”))
{
UserVO vo = new UserVO(username);
return vo;
}
return null;
}

public boolean doAuthorization(Principal user, List roles)
{

UserVO u = (UserVO)user;

if(u == null)
return false;

for(int i=0;i<roles.size();i++)
{
String role = (String)roles.get(i);
if(u.hasRole(role))
return true;
}
return false;
}

public boolean logout(Principal arg0) {
// TODO Auto-generated method stub
return false;
}

public void start(ServletConfig arg0) {
// TODO Auto-generated method stub

}

public void stop() {
// TODO Auto-generated method stub

}

public String getPrincipalNameFromCredentials(String arg0, Object arg1) {
// TODO Auto-generated method stub
return null;
}
}

In this example UserVO must implement java.security.Principal

package com.dl.login;

import java.security.Principal;

public class UserVO implements Principal
{

public String [] groups;
public String username;

public UserVO(String username)
{
this.username = username;
// Make sure we apply the array groups (roles) this user belongs to at some point :)
}

public String getName() {

return this.username;
}

public boolean hasRole(String role)
{
for(int i=0;i<groups.length;i++)
{
if(groups[i].equals(role))
return true;
}
return false;
}

}

Okay, now we just need to point the services-config.xml to our class
<security>

<login-command class=”com.dl.login.LoginProxy” server=”all”>
<!– a.k.a. true = per ‘tab’ authentication –>
<!– when set to true a browser refresh will also reset auth –>
<per-client-authentication>false</per-client-authentication>
</login-command>

<security-constraint id=”trusted”>
<auth-method>Basic</auth-method>
<roles>
<role>guests</role>
<role>accountants</role>
<role>employees</role>
<role>managers</role>
</roles>
</security-constraint>

</security>

That’s it.

To actually secure a destination, use the remoting-config.xml

<destination id=”AlertProxy” >
<properties>
<source>com.dl.alerts.AlertDAO</source>
<scope>application</scope>
</properties>

<security>
<security-constraint ref=”trusted”/>
</security>

</destination>

 
No Comments

Posted in Java

 

jQuery, Objective C

23 Apr

I’ve been diving into both as I’m looking to land some more iPhone projects. I’m really excited with the breath of fresh air the platform provides.

The big question this year….

WWDC 2010 or MAX 2010

MAX has been great, I’ve met some really great members of the community. For those of us who are Flex veterans, the conference seems a bit light, at least that’s the impression I’ve had the past two years.

Looking over the 2009 sessions of WWDC, I’m impressed, looks like a lot of great sessions.

Cheers
Josh

 
No Comments

Posted in RIA

 

Debugging Apache

23 Apr

Problem: Apache quit working

Solution: Debug via gdb httpd2

Apache quit working after some network changes. The error log contained numerous

child pid 20038 exit signal Segmentation fault (11) lines.

Running gdb httpd2 along with a backtrace (bt) revealed the function / line of code throwing the error. The problem was quickly tracked down to the LDAP config (ldap.conf).

 
No Comments

Posted in Suse

 

BlazeDS Context.xml

23 Apr

While deploying a BlazeDS project, I ran into a small problem that the META-INF/context.xml was not being loaded by tomcat.

The context.xml has a simple JNDI datasource defined

auth="Container"
type="javax.sql.DataSource"
username="username"
password="password"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://yourhost.com:3306/dbname" />

Reading up on the tomcat docs it became obvious that tomcat was loading the Adobe BlazeDZ tomcat/conf/context.xml.

 
No Comments

Posted in Java

 

Java Soap Client

19 Nov

I ran into a short problem writing a Java SOAP client. I was using the Axis[2] wsdl2java class to generate my Java classes. The latest version of wsdl2java has omitted the -T parameter that’s used to specify the SOAP version for the generate classes. The client’s soap endpoint only accepts SOAP 1.1 (not 1.2) so this proved to be a problem. I downloaded an older version of Axis [1.4] so I could specify the -T 1.1 and build against SOAP 1.1.
Download hip hop songs mp3
Buy Levitra Vardenafil
This time around the generated Java classes are missing the soap envelope headers needed by the service. I found a great article covering this exact problem.

The only change needed from there was in the service stub…

The org.apache.axis.soap.SOAPConstants.SOAP12_CONSTANTS needed to be changed to org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS. I was a bit surpised to see those constants after building w/the wsdl2java -T 1.1 argument.

Disclaimer: I’m not a SOAP *expert* so feel free to provide feedback :-)

 
No Comments

Posted in Java

 

Glassfish LCDS Flex Up Next

19 Nov

It’s been a busy year getting a J2EE and Data Warehousing education. I’m wrapping up the ETL portion of a large Data Warehousing project. The next phase of the project is building a Flex front-end for the warehouse. I’m looking forward to using the Spark Architecture in Flex 4 for the UI, we should be able to generate some amazing UIs.

Cheers
Josh

 
No Comments

Posted in RIA

 

Debug Server/Client LCDS Java Helloworld in Flex Builder

02 Sep

Prerequisites

Install Flex Builder
Install LCDS Data Services
Install WTP in Flex Builder

Here’s a simple project that shows you how to create a simple Hello World for Flex + Java via LCDS. I’ll also show you how to debug the server [java] code as we move along.

File->New->Flex Project

  • For application server type select J2EE
  • User remote object access
  • LiveCycle Data Services
  • Create combined Java/Flex project using WTP
  • 01 Setup

    Select the target runtime. You will need to click ‘New’ to create one if none are available.

    02 Server

    Create a new target runtime if needed.

    03 Tomcat

    04 Tomcat

    05 Server

    Be sure to change your Output URL to match the LCDS [tomcat] config (defaults to 8400)
    06 Setup

    Run->Debug->Other

    Again, make sure the URLs are using the correct port

    07 Debug Server

    Project->Properties->Flex Server

    08 URL Context

    Okay, are setup is complete now we’re ready to code.

    Here’s the MXML

    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

    <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.events.FaultEvent;

    private function sayHello():void
    {
    testService.getOperation('sayHelloTo').send(txtName.text);
    }

    private function onFault(event:FaultEvent):void
    {
    trace(event);
    }

    private function onSayHelloToResult(event:ResultEvent):void
    {
    Alert.show(event.result as String);
    }

    ]]>
    </mx:Script>

    <mx:RemoteObject id="testService" fault="onFault(event)" destination="helloDest">
    <mx:method name="sayHelloTo" result="onSayHelloToResult(event)"/>
    </mx:RemoteObject>

    <mx:TextInput id="txtName" x="10" y="10"/>
    <mx:Button click="sayHello()" x="178" y="10" label="Go"/>
    </mx:Application>

    Note the destination=”helloDest” line, we’ll have to configure a LCDS destination with this name in a few steps…

    Create a simple java class to test against:

    
    public class HelloWorld {
    
    	public String sayHelloTo(String name)
    	{
    		return "Hello " + name;
    	}
    }
    

    And finally, we need to setup the destination

    To do so, edit \WebContent\WEB-INF\flex\remoting-config.xml, adding the following

    <destination id="helloDest">
    <properties>
    <source>HelloWorld</source>
    </properties>
    </destination>

    That’s it, now we are ready to test.

    Set a breakpoint on the on ‘return “Hello ” + name;‘ line in you’re java code.

    Launch the server in debug mode

    09 Server

    Now, launch the flex app [in debug mode if you want to debug the front end as well].

    Type your name in the input box and click ‘Go.’

    You’ll see your breakpoint being caught, both server [java] side and client side :)

    Flex Project Archive

     
    No Comments

    Posted in RIA

     

    Install WTP in Flex Builder

    02 Sep

    A quick walkthrough on installing the Web Tools Platform (WTP) in Flex Builder.

    Help->Software Updates->Find and Install

    Help Software Update

    Search for new features to install

    Search for New

    Select the [Europa] discovery site

    Europa

    Select ‘Web and JEE development’

    You may need to click ‘Select Required’

    WTP

     
    2 Comments

    Posted in RIA

     

    AMFPHP Support for JSON POSTs

    24 Jul

    I found myself wanting to use JSON POSTs (not just GETs) with AMFPHP. Here’s the addition.

    Open up core\json\app\Gateway.php.

    After

    $rawArgs = explode('/', $args);

    add the following

    if(isset($_POST) && count($_POST) > 0)
    {
    $len = count($rawArgs);
    // Check for and remove [last] empty arg from URL '/' explosion
    if($len && trim($rawArgs[$len-1]) == "")
    unset($rawArgs[$len-1]);

    // Append the POST variables
    for($i=0;$i $rawArgs[] = $_POST[$i];
    }

    The format of the post variables would be argNo=value
    Ex.
    Backend Function

    public function ResetPassword($username,$password,$oldpassword)
    {
    // Code HERE
    }

    Javascript POST parameters for the latter

    request.send("0=" + escape(username) + "&1=" + escape(oldpassword) + "&2=" + escape(newpassword));

    Hoping to jump into ZendAMF soon :)

     
    No Comments

    Posted in JSON