July 25, 2009 by maohao
Here.
find . -type d -exec chmod 755 {} \;
This will recursively search your directory tree (starting at dir ‘dot’) and chmod 755 all directories only.
Similarly, the following will chmod all files only (and ignore the directories):
find . -type f -exec chmod 644 {} \;
Posted in Linux | Leave a Comment »
July 21, 2009 by maohao
$ export http_proxy=http://myuname:mypass@myproxy:myport
$ sudo apt-get update
Posted in Linux, ubuntu | Leave a Comment »
July 17, 2009 by maohao
Here. By Mayank Sarup.
What do “read”/”write”/”execute” mean?
r – Read permission. Whether the file may be read. In the case of a
directory, this would mean the ability to list the contents of the
directory.
w – Write permission. Whether the file may be written to or modified. For
a directory, this defines whether you can make any changes to the contents
of the directory. If write permission is not set then you will not be able
to delete, rename or create a file.
x – Execute permission. Whether the file may be executed. In the case of a
directory, this attribute decides whether you have permission to enter,
run a search through that directory or execute some program from that
directory.
Examples of and related commands
chmod u-x,g+w,o+rw somefile
chmod xyz filename
(r = 4; w = 2; x = 1)
chown new-owner somefile
chgrp new-grp somefile
Posted in Linux | Leave a Comment »
July 6, 2009 by maohao
This applies to both AIR and Flex project, in Flex SDK 3.3:
// Application.application refers to the top level application.
// But be aware that it's typed to Object as opposed to Application.
// According to Flex team, it's for the purpose of fast compilation and
// being able to access properties/methods in the <Script> of their
// <Application> without having to cast it to their application's real type.
// So this means you can get:
// var stuff:SomeStuff = Application.application.getStuff();
// but you would have to access the real application each time by saying
// Application.application. Or you can do it this way:
var app:MySubclassedApplication = mx.core.Application.application as
MySubclassedApplication;
// UI components with id names are automatically declared as public
var contactList: ContactList = app.contactList;
// as long as you've declared them as public in your <Script>.:)
var dou:Dug = app.dug;
var stuff:SomeStuff = app.getStuff();
Documentation. Note when you are using SWFLoader to load a module into the main application, you can reference your main application as parentApplication.
Posted in ActionScript, ActionScript 3, Flex | Leave a Comment »
June 24, 2009 by maohao
1. Download JFv1.51_CRB43-US.zip (file size 36,614 kb).
2. Rename it to Update.zip and copy to the root of your SD card.
3. Shut down G1.
4. Reboot G1 by holding down Power+Home buttons at the same time, which should bring up the bootloader.
5. Bring out the key board, first Alt+L to display log, then Alt+S to apply patch; this should apply the update.
6. Once done, G1 prompts you to reboot.
7. Per my personal experience, I got stuck on the Android logo (the 3D chrome logo), which froze at the animation loop. What I did was a) Took out the battery and reboot, which doesn’t seem to fix the problem; b) Reboot the second time by going to 3, 4 again. On the bootloader screen, Alt+W to wipe data and reset to factory default.
8. Power up G1 once done. That’s it.
At least it worked for me:)
Posted in Android | Leave a Comment »
June 19, 2009 by maohao
Running the examples that come with the SDK in Eclipse
Eclipse->Package Explorer->Right click->New ->Android Project->Contents->Create project from existing source->Location>Navigate to
<directory_of_your_android_SDK>/platforms/android-1.5/samples/ApiDemos>OK
Eclipse will populate other setting values such as “Project name” and “Build Target” for you.:)
Local resource page (index.html)
<directory_of_your_android_SDK>/docs/index.html
just in case you don’t have/just lost/are having creeping internet but are desperate to look up the documentation to get something done ASAP so that you can go home;)
Posted in Android, Java, eclipse | Leave a Comment »
June 19, 2009 by maohao
Go to Package Explorer -> Right click your Android project ->Run As->Run Configurations.
Under Android Application on the left column, select your project -> on the right column, where you see Android | Target | Common tabs ->
Select Target -> on the bottom “Additional Emulator Command Line Options”->
-http-proxy http://wwwgateProxy.com:1080 -debug-proxy http://wwwgateProxy.com:1080
->Run/Close.
Posted in Android, Java, eclipse | Leave a Comment »
June 8, 2009 by maohao
In a recent prototyping project, I attempted to simulate “shake” gestures in a desktop AIR application, i.e., using mouse cursor to simulate a hand grabbing some object on the screen…
Anyhow. I found out that Flash Player can send out the mouseMove event must faster than it can update the screen. In the case you want to keep track of the simulated gestural motion, you would want to track the mouse cursor position on the stage, instead of the display object the mouse cursor is dragging. This is because when you drag the object to the point Flash Player cannot keep up with, the redaw will then not necessarily reflect the real positional changes of it in between the frames.
Take a look here. Right click to for the code. Also note that when directly register Application.application as the currentTarget we seem to get smoother tracking than if we registered the display object, like so:
mButton.addEventListener(MouseEvent.MOUSE_MOVE, mButton_handleMouseMove);/** you got more stripped out points than if you do this:
addEventListener(MouseEvent.MOUSE_MOVE, mButton_handleMouseMove);// this is btter.*/
Posted in ActionScript, ActionScript 3, Adobe AIR, Flash, Flex, flare | Leave a Comment »
June 7, 2009 by maohao
I find that MVC is much easier to understand both at the conceptual level and at the implementation level if you think about it from the perspective of how you communicate with the Model.
- Control is the input to Model. Basically, the Control is responsible to take input from the user or the system and stransfer it to the changes in the Model; The View is merely there to render the changes from the Model; so it can be considered as the output from the Model. You should keep the business logic as much as possible inside the Model and leave Control/View simple and dandy.For Flex 3 (Halo) components, the way of input is realized by implimenting the “change” listener of the controls, like this:
<mx:TextInput id="mTxt" change="mVO.txtValue = mTxt.htmlText;"/>
In Flex 3, when you bind a model to a control, it is one-way communication, meaning the control will reflect the change whenever there is one in the model; but the control would not be able to change the model. That’s why we need to wire through the change listener to make this happen.
The output is hooked up by setter methods in the Model. Whenever you detect some changes that are historical, you would notify your listeners.
[Bindable]
public function set myValue(v:int):void
{
_myValue = v;
notifyListeners();
}
In ActionScript 3, we normally implement “notifyListeners” by way of dispatchEvent. Your client listens to the event and updates the View by querying the changes from the Model. You may want to have different types of events so that your listeners can respond differently. For example, you normally would invalidate properties of your component and regenerate all the renderers when the data provider has changed, besides doing other updates; and you don’t want to do this kind of heavy-lifting each time when changes occur on the “less important” members of the Model.
- Asynchronous data. Sometimes you may compose something like an HTTPService component into your Model so that it can request external data.The data that are requested by the Control at a lot of times are not immediately available, and normally you would not notify your listeners until they are ready (For example, parsed into an XMLList object that can be consumed by component’s dataProvider).
- Static members are available before non-static members of the objects. You can use static members to set some initial values of your member variables.
- When you smell spaghetti code in your Model, try to partition/refactor your Model into smaller Value Objects. Value objects are a good way to structure your data/make flat Model hierarchical.
- For larger projects, you may want to duplicate Model (or value objects) so that multiple client can access the same data. For example, in your main window of your AIR application, you initialize your model like so:
public var chatModel:ChatModel = new ChatModel();
In another console window, you want to access the same model, like so:
private var chatModel:ChatModel = Application.application.chatModel;
Tags: Model View Controller
Posted in ActionScript, ActionScript 3, Adobe AIR, Design patterns, Flash, Flex, JavaScript;Ajax, XML, user interface | Leave a Comment »