768x90 Getting Online Shouldn't be Tough- $7.49 .com Domains at Go Daddy

List and read files and directories in a zip file

First of all you should download library here

And then short play with script below
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">


<mx:Script>
<![CDATA[
import mx.controls.Alert;
import nochump.util.zip.ZipEntry;
import mx.events.ListEvent;
import nochump.util.zip.ZipFile;
[Bindable]private var _zipFile:ZipFile;
[Bindable]private var _file:File;

private function browseFile():void{
var _file:File = new File();
_file.browseForOpen("Open.", getTypes());
_file.addEventListener(Event.SELECT, fileSelected);
}

private function getTypes():Array {
var allTypes:Array = new Array(getImageTypeFilter());
return allTypes;
}

private function getImageTypeFilter():FileFilter {
return new FileFilter("ZIP File", "*.zip");
}

private function setFileInfo(name:String, size:uint):void {
zipFileLabel.text = "Archive: " + name + " (" + sizeFormatter.format(size) + " bytes)";
}

private function fileSelected(event:Event):void {
_file = event.currentTarget as File;
var urlStream:URLStream = new URLStream();
urlStream.addEventListener(Event.COMPLETE, completeHandler);
urlStream.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
urlStream.addEventListener(SecurityErrorEvent.SECURITY_ERROR, errorHandler);
urlStream.load(new URLRequest(_file.nativePath));
}

private function completeHandler(event:Event):void {
var data:URLStream = URLStream(event.target);
setFileInfo(_file.name, data.bytesAvailable);
_zipFile = new ZipFile(data);
}

private function errorHandler(event:ErrorEvent):void {
Alert.show(event.text);
}

private function itemClickEvent(event:ListEvent):void {
var entry:ZipEntry = event.currentTarget.selectedItem as ZipEntry;
if(entry) taEntryData.text = String(_zipFile.getInput(entry));
}

private function labelSize(item:Object, column:DataGridColumn):String {
return sizeFormatter.format(item[column.dataField]);
}

private function labelModified(item:Object, column:DataGridColumn):String {
return dateFormatter.format(new Date(item.time));
}

private function labelCrc(item:Object, column:DataGridColumn):String {
return item.crc.toString(16).toUpperCase();
}

]]>
</mx:Script>

<mx:NumberFormatter id="sizeFormatter" useThousandsSeparator="true" />
<mx:DateFormatter id="dateFormatter" formatString="MM/DD/YYYY L:NN A" />

<mx:Panel title="Zip Demo" height="100%" width="100%">
<mx:Label id="zipFileLabel" />
<mx:VDividedBox width="100%" height="100%">
<mx:DataGrid id="dgEntries" width="100%" height="100%" dataProvider="{_zipFile.entries}" itemClick="itemClickEvent(event);">
<mx:columns>
<mx:DataGridColumn headerText="Name" dataField="name" width="300" />
<mx:DataGridColumn headerText="Size" dataField="size" labelFunction="labelSize" />
<mx:DataGridColumn headerText="Packed" dataField="compressedSize" labelFunction="labelSize" />
<mx:DataGridColumn headerText="Modified" labelFunction="labelModified" width="150" />
<mx:DataGridColumn headerText="CRC32" labelFunction="labelCrc" />
</mx:columns>
</mx:DataGrid>
<mx:TextArea id="taEntryData" width="100%" height="100%">
</mx:TextArea>
</mx:VDividedBox>
<mx:ControlBar>
<mx:Spacer width="100%"/>
<mx:HBox>
<mx:Form>
<mx:FormItem label="Open Zip File:" width="100%" styleName="lblForm" required="true">
<mx:Button id="btnBrowse" label="Browse" click="{browseFile()}"/>
</mx:FormItem>
</mx:Form>
</mx:HBox>
</mx:ControlBar>
</mx:Panel>



</mx:WindowedApplication>

Anti Distorted resolution picture when resizing

If you resize picture by defining new width or height from normal size, you will get the picture resolution's distorted or broken quality. There's a method how to make the picture keeps soft and smooth.

Create a utility class


package com.jackBite.utils
{
import mx.controls.Image;
import flash.display.Bitmap;

public class CleanImage extends Image
{
/*public function CleanImage()
{
}*/

override protected function updateDisplayList(unscaledWidth:Number,unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
if(content is Bitmap)
{
var bmp:Bitmap = Bitmap(content);
if(bmp && bmp.smoothing == false)
bmp.smoothing = true;
}
}

}
}



In MXML Component, You Put this

<utils:CleanImage id="feedLogo" height="30" source="{_imageRss}"/>

How To add image into any Textinput

You maybe want to add image or icon like magnifiying icon in textInput of your flex, Here i have some method how you can do that :

Create AS Component



package nebula.utils
{
import mx.controls.Image;
import mx.controls.TextInput;

public class SearchTextInput extends TextInput
{
public function SearchTextInput()
{
}

override protected function createChildren():void
{
super.createChildren();
var searchImg:Image = new Image();
searchImg.source = Images.search_icon;
searchImg.width=12;
searchImg.height=12;
searchImg.x = 2;
searchImg.y = 3;
setStyle("paddingLeft",searchImg.width+2);
addChild(searchImg);
}

}
}



in mxml component you put this:


<utils:SearchTextInput text="enter professional name ..." id="searchPro" click="{searchPro.text = ''}" width="200"/>




Another Alternative (sometime not work)


<mx:HBox>
<mx:TextInput id="myTextInput" />
<mx:Images source="{your_image_url}" paddingLeft="6" />
</mx:HBox>

Hacking Zindus (ThunderBird Add-On)

Zindus is a thunderbird add-on to import your google contact to thunderbird. The problem of zindus is not shown the first_name and last_name, address and organization if you use google data V.3

Let's see how it works:

1. Download Zindus from your ThunderBird.


2. Open the xpi file using winRar/7zip and extract the file.

3. Go to folder 'chrome' and then extract zindus.jar using WinRar/7zip

4. After you extract the JAR, go to folder content/zindus/

5. Open const.js and find 'const GD_API_VERSION ' and then change the value tobe "3"

6. Open contactgoogle.js and after that replace all with my script from this url: http://pastie.org/879955

7. archive the changes file to zindus.jar and archive back zindus.jar to xpi using 7zip or WinRar(drag and drop the xpi root folder to opened xpi in winRar)

8. Install it into your thunderbird and start import the google document

9. Binggo ^o^ address now display well and also organization and your first & last name.

Import contact information in Google Spreadsheet To Google Contact Using Rake

This March, I had a sexy task to import all employees and departments contacts information which were stored in Google Spreadsheet into Google contact.

A dummy people will think to pay data entry for entering them through google contact form. Whoa.. if i were a data entry, i would have had broken fingers after entering all data. Any way, I found a shortcut to import all data in only seconds or minutes, that is; make a robot to enter all data when we have a lunch.

Now, let's prepare the tools :

1. Installed Ruby on Rails Application
2. gem install gdata
3. gem install google-spreadsheet-ruby
4. open any text editor

Create Basic Rake Frame


namespace :db do

desc "GS2C: Google spreadsheet to Google contact"
task :gs2c => :environment do
require 'gdata'
require 'google_spreadsheet'

#Here will be some sexy scripts

end

end



Here it is, The Robot

namespace :db do

desc "GS2C: Google spreadsheet to Google contact"
task :gs2c => :environment do
require 'fastercsv'
require 'gdata'
require 'google_spreadsheet'

#sample spreadsheet URL
#https://spreadsheets.google.com/a/kiranatama.com/ccc?key=0AlQZq7IIjE6UdF92SkhRazlYaVFUWFNYZGxxLWpoT0E&hl=en

#settings
@spreadsheet_key = "0AlQZq7IIjE6UdF92SkhRazlYaVFUWFNYZGxxLWpoT0E"
login_config = YAML.load_file("#{RAILS_ROOT}/config/google_login.yml")[RAILS_ENV]
login_config["google"].each { |key, value| instance_variable_set("@#{key}", value) }

def create_spreadsheet_connector
@google_spreadsheet = GoogleSpreadsheet.login(@email_contact, @password_contact)
create_contact_connector
end

def create_contact_connector
@google_contact = GData::Client::Contacts.new({
:authsub_scope => 'http://www.google.com/m8/feeds/',
:source => 'google-DocListManager-v1.1',
:version => '3.0'})
@google_contact.clientlogin(@email_contact, @password_contact)
create_contact_entry
end

def create_contact_entry
@contact_entry = <<-EOF
<atom:entry xmlns:atom='http://www.w3.org/2005/Atom'
xmlns:gd='http://schemas.google.com/g/2005'>
<atom:category scheme='http://schemas.google.com/g/2005#kind'
term='http://schemas.google.com/contact/2008#contact' />
EOF
start_load_csv
end

def start_load_csv
@spreadsheet = @google_spreadsheet.spreadsheet_by_key(@spreadsheet_key)
#Sample Row Header / First Row
#First Name | Last Name | Email | Work Phone | Home Phone | Address | City | State | Country | ZIP
#You have to skip first row and blank row
i = 0
@spreadsheet.worksheets do |row|
if i < 1
i++
return
end
@google_contact.post( 'http://www.google.com/m8/feeds/' + 'contacts/default/base?v=3', create_google_contact(row,i))
i++
end
end

def create_address(address,city,state,country,zip)
address = <<-EOF
<gd:postalAddress rel='http://schemas.google.com/g/2005#home' primary='true'>
#{address}
#{city}
#{state}, #{zip}
#{country}
</gd:postalAddress>
EOF
return address
end

def create_google_contact(row,i)
first_name = row[i, 1].blank? ? "---" : row[i, 1]
last_name = row[i, 1].blank? ? "---" : row[i, 2]
email = row[i, 3].blank? ? "---" : row[i, 3]
work_phone = row[i, 4].blank? ? "---" : row[i, 4]
home_phone = row[i, 5].blank? ? "---" : row[i, 5]
address = row[i, 6].blank? ? "---" : row[i, 6]
city = row[i, 7].blank? ? "---" : row[i, 7]
state = row[i, 8].blank? ? "---" : row[i, 8]
country = row[i, 9].blank? ? "---" : row[i, 9]
zip = row[i, 10].blank? ? "---" : row[i, 10]
full_name = first_name + last_name

data = <<-EOF
#{@contact_entry}
<title>#{full_name}</title>
<atom:content type='text'>#{contact.note}</atom:content>
<gd:name>
<gd:fullName>#{full_name}</gd:fullName>
<gd:givenName>#{first_name}</gd:givenName>
<gd:familyName>#{last_name}</gd:familyName>
</gd:name>

<gd:email primary='true' rel='http://schemas.google.com/g/2005#home' address='#{email}'/>
<gd:phoneNumber rel='http://schemas.google.com/g/2005#home'>#{home_phone}</gd:phoneNumber>
<gd:phoneNumber rel='http://schemas.google.com/g/2005#work'>#{work_phone}</gd:phoneNumber>

#{create_address(address,city,state,country,zip)}

</atom:entry>
EOF
return data
end

create_spreadsheet_connector

end

end


Command Line : rake db:gs2c or rake -T

 
powered by Blogger