Wednesday, October 13, 2010

Executing vim commands from command line

Source

I executed the following when I wanted to replace
all "include" statements in my php files to "include_once"

vim.exe -c "argdo %s/include /include_once /ge | update" *.php

Friday, October 8, 2010

bookmarklet for changing a page's max size

 javascript:(function(){var%20newSS,%20styles='body%20{max-width:%20800px;}';%20if(document.createStyleSheet)%20{document.createStyleSheet(%22javascript:'%22+styles+%22'%22);}%20else%20{newSS=document.createElement('link');%20newSS.rel='stylesheet';%20newSS.href='data:text/css,'+escape(styles);%20document.documentElement.childNodes[0].appendChild(newSS);}})();

Flex 4 difference between property and class

Source
Now, how do you know, regardless of the defnition style, which is a property
and which is a class?




   1:  <s:Group>
   2:    <s:layout>
   3:     <s:VerticalLayout/>
   4:    </s:layout>
   5:    <s:Button label="1"/>
   6:    <s:Button label="2"/>
   7:    <s:Button>
   8:     <s:label>3</s:label>
   9:    </s:Button>
  10:  </s:Group>

The G in the <s: Group> tag is uppercase, so it refers to an instance of a Flex class named  Group. The l in the <s:layout> tag is lowercase, so it is a property of the Group. The V in the  <s:VerticalLayout> tag is uppercase, so it is referring to a new instance of a Flex class named  VerticalLayout.

Scrolling content in Flex 4



Source
In previous versions of Flex, every container had this functionality by 
default. While extremely convenient for the developer, it also meant that 
every container was burdened with this extra code even though it was 
hidden the vast majority of times. In Flex 4, you need to specifically
indicate when an area is scrollable. Tis is accomplished via a special 
tag named Scroller that wraps your Group tag.

   1:  <s:Scroller height="65">
   2:    <s:Group>
   3:     <s:layout>
   4:      <s:VerticalLayout/>
   5:    </s:layout>
   6:     <s:Button label="1"/>
   7:     <s:Button label="2"/>
   8:     <s:Button label="3"/>
   9:    </s:Group>
  10:  </s:Scroller>

Flex 4 basic layouts


Source
   1:  <s:Group>
   2:    <s:layout>
   3:     <s:HorizontalLayout/>
   4:    </s:layout>
   5:    <s:Button label="1"/>
   6:    <s:Button label="2"/>
   7:    <s:Button label="3"/>
   8:  </s:Group>

HorizontalLayout/VerticalLayout/TileLayout/BasicLayout

AS-3/Flex Dictionary weak keys


A sample source code for using a dictionary in AS-3/Flex with weak keys.
When I say new Dictionary(true), after a while all those objects, whose
only references are as the dictionary keys, will be garbage collected.
So, if run the following in debug mode, after a while, output of trace 
will be 0, from 1 initially. 

   1:  <?xml version="1.0"?>
   2:  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()">
   3:      <mx:Script><![CDATA[
   4:          private var di:Dictionary = new Dictionary(true);
   5:          private function init():void {
   6:             di[new Sprite()] = [1,2,3];
   7:              setTimeout(startTrack,5000);
   8:          }
   9:   
  10:          private function startTrack():void {
  11:             System.gc();
  12:              var count:int = 0;
  13:              for each (var arr:Array in di) {
  14:                  ++count;
  15:              }
  16:              trace("number of elements in dictionary = " +count);
  17:              setTimeout(startTrack,5000);
  18:          }
  19:          ]]></mx:Script>
  20:  </mx:Application>

Sunday, October 3, 2010

Blog Archive