2009
09.19

PHP: CodeIgniter: Send image response with mime header

By Satish Natarajan

function send_image {
$imageString
= file_get_contents('you image path goes here...');
header("Content-Type: image/gif");
echo
$imageString;
}
2009
09.12

Flex: Using Alert Box as Confirmation Dialog

By Satish Natarajan

I am sure most of you know this. I am writing this one for reference.

Suppose you want to delete something…

Alert.show(”Do you want to delete ? “, “Delete Confirmation”,  Alert.OK|Alert.CANCEL, this, action_function, null, Alert.CANCEL);

Variables: Message, Window title, What options to Show, Who is the parent, Handler function, Icon?, Default Option

the action function looks like this

public function action_function(eventObj:CloseEvent):void {
if(eventObj.detail == Alert.OK){
//Selected OK
}

if(eventObj.detail == Alert.CANCEL){
//Selected Cancel
}
}

2009
09.11

Flex: Adding Custom Component within a Datagrid – Nice!

By Satish Natarajan

<mx:DataGrid id=”myGrid” dataProvider=”{dataAC}”>
<mx:columns>
<mx:DataGridColumn dataField=”id” headerText=”ID” />
<mx:DataGridColumn  dataField=”description” headerText=”Description Detail” headerWordWrap=”true”/>
<mx:DataGridColumn headerText=”Action”>
<mx:itemRenderer>
<mx:Component>
<mx:Text text=”Delete” textDecoration=”underline” click=”outerDocument.delete_function(data.id)”/>
</mx:Component>
</mx:itemRenderer>

</mx:DataGridColumn>

</mx:columns>
</mx:DataGrid>

Ok some assumptions

  • dataAC is an Array Collection – Note you can have objects who have public variables like id and description (nice)
  • Define a new column in the datagrid – DataGridColumn and using a itemrenderer
  • Check out the use of mx:Component and scope limitation – if you want to access the variables outside this scope you can use outerDocument (NICE!) but remember the variable or functions(nice!) should be public.

Overall I like this – Lot of neat uses….

2009
09.11

Ruby on Rails: Strip HTML tags

By Satish Natarajan

The regex below removes html tags from a given string

str = <<HTML_TEXT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
  <h1>Title</h1>
  <p>Blah Blah Blah!</p>
</body>
</html>
HTML_TEXT

puts str.gsub(/<\/?[^>]*>/, "")
2009
09.07

We recommend using OpenInviter at http://openinviter.com. We have tried it in a recent project and we like it for ease of integration and their updates.

2009
09.06

Flex: Popup Manager Sample

By Satish Natarajan

In your application create a function that will be called when an event like click on link or button happens

import mx.managers.PopUpManager;

private function showTestPopup():void {
var win:TestPopup = PopUpManager.createPopUp(this.parent, TestPopup, true) as TestPopup;
PopUpManager.centerPopUp(win);
}

TestPopup.mxml will look like this:

<?xml version=”1.0″ encoding=”utf-8″?>
<!– TestPopup.mxml –>
<mx:TitleWindow xmlns:mx=”http://www.adobe.com/2006/mxml”
layout=”vertical”
title=”Test Popup”
showCloseButton=”true”
width=”400″
height=”300″
close=”titleWindow_close(event);”>

<mx:Script>
<![CDATA[
import mx.events.CloseEvent;
import mx.managers.PopUpManager;

private function titleWindow_close(evt:CloseEvent):void {
PopUpManager.removePopUp(this);
}

]]>
</mx:Script>

<mx:Text text=”This is a test 12345″>
</mx:Text>

</mx:TitleWindow>

Hope this helps…

2009
09.05

Flex: How to – Set global custom font within your application

By Satish Natarajan

Add the following section to you <Application> block. The key is “global” style.

<mx:Style>
@font-face{
src:url(’assets/fonts/arial.ttf’);
font-family:myArial;
font-weight:normal;
}
@font-face{
src:url(’assets/fonts/arialbd.ttf’);
font-family:myArial;
font-weight:bold;
}
global
{
font-family:myArial;
}
</mx:Style>

2009
09.05

Flex: Howto hide graph legend display

By Satish Natarajan

Remove the <mx:Legend> element from within your chart ;-)

2009
09.03

Linux: Cron Job format

By Satish Natarajan

.---------------- minute (0 - 59)
|  .------------- hour (0 - 23)
|  |  .---------- day of month (1 - 31)
|  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
|  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7)  OR sun,mon,tue,wed,thu,fri,sat
|  |  |  |  |
*  *  *  *  *  command to be executed
2009
09.01

I found this this morning..

Object doesn’t support this property or Method. This turned out to be that in IE7 all javascript variables need to declared before use. So if you have say my_var1 you would want to put “var my_var1;” at the beginning of the script before assigning any value to it.

Oh I like new browsers (more fault tolerant) however lot of folks use IE7 at this time.