Sunday, December 16, 2007

Faster Shutdown Using Command Line

Command: shutdown -f -t 0

Execute this line either by using the Run dialog in windows (Windows Key+R or Start-->Run)
or by using the command prompt.

-f stands for forced
-t stands for time

Other shortcut commands:
shutdown.exe -s -t 0
Shuts down the computer as if you clicked start--->stop--->shutdown


shutdown.exe -r -t 0
Restarts the computer as if you clicked start--->stop--->restart



Wednesday, December 5, 2007

Create Executable Jar File

Create MyClass.java
import java.awt.*;
import java.awt.event.*;

public class MyClass {
public static void main(String[] args) {
Frame f = new Frame();
f.addWindowListener
(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
);
f.add(new Label("Hello world"));
f.setSize(200,200);
f.setVisible(true);
}
}

cmd: Path:> javac MyClass.java

Create manifest.mft using notepad

Manifest-Version: 1.0
Main-Class: MyClass
Class-path: .

Main-Class specifies the entry point with the main(String args[]) method.

The Class-path is used to specify the dependency of this jar (if any). You add the directories and jars separated by a space. It is important because when running a jar , the CLASSPATH definition (as defined by the environnement variable) is overridden.

cmd: Path:>jar cvfm myjar.jar manifest.mft *.class

cmd: Path:>java -jar myjar.jar


myjar.jar will be created, double-click to run.

Monday, December 3, 2007

Should Online Artwork Ripping Be Stopped?

My friends and I have been discussing on whether or not there is need for Anti-Artwork-Ripping tools. Of course, one side of the argument consists of the people who believe in that the web is about sharing EVERYTHING, while the other side of the argument is how the artists are being treated unfairly for not having any power over controlling their creation online.

Cratle Note:
Def Artwork :
The formal expression of a conceived image or imagined conception in terms of a given medium.

When thinking of artworks, I hope people can exclude those daily random pictures, instead, consider the paintings, photographies, and other art forms which requires hours or even days of concentrated efforts.


So, should Online Artwork Ripping Be Stopped?


Top 10 Reasons To Commit Picture Ripping

1. It has always been this way, right-click--->save as...Simple and easy, even my grandma knows how to do that!
2. I saw that picture before.
3. This is what Internet was meant to be. We share everything!
4. Art is to be shared, or else it has no value whatsoever.
5. It is pointless to protect it, someone's gonna figure out a way to rip it anyway.
6. How can I not rip that beauty's picture? That is against human nature.
7. It is a compliment if someone rips off your pictures.
8. Technically the poster may not be the owner, and he has shown no verifiable proof that he has created that picture, therefore it is totally fine for everyone to rip it off.
9. I've got to give this picture to my girlfriend, damn it, don't you try to stop me!
10. What is art but an entity of shadows and shades communicating with the mind? You can't define it, you can't confine it, you can't protect it, thus I will rip it all!


Top 10 Reasons To Support Artwork Protection

1. We amateur artists are poor, help us.
2. You know how disgusting it is when someone takes something that is yours and calls it theirs? It makes you want to punch them in the face and curse their moms.
3. Thieves must be stopped, captured, and punished.
4. My art is my creation, out of my flesh, my heart, and my soul, I don't want it to fall into filthy hands.
5. It is against the Copyright law to use creative works without the permission of the author.
6. "You're just mean when you rip off something that is not yours!
"
7. "How do we continue to contribute to the community while we know that many in our audience are cheating on us? That they like us only because they can rip us off?"
8. If people want the artworks so much, they have the choice to buy them, why steal? why sacrifices your dignity for something less than five dollars? A well-protected photo trading community is more desired.
9. It is unfair! Artists should have the authority to control how their works are distributed.
10. Where is the justice of a place where all men are encouraged to steal, cheat, and lie independently?

Appendix.

Current artwork ripping methods:

- Screenshot softwares
- PrintScreen
- Right Click-> Save as...
- Other automated Find and Save picture tools

Current artwork protection methods:
- Blocking Right Click
- Picture-wise WaterMark
- Use Compressed Low-Quality Image
- Control Page Access

Monday, November 19, 2007

Solution to Wscript and HTML Integration

Much to my disgrace, I could get WSCript to work with HTML for hours.
The error "WScript is undefined" has puzzled me throughout the night, but finally the problem is solved.


What's the Problem?


According to MSDN, "the WScript object is the root object of the Windows Script Host object model hierarchy. It never needs to be instantiated before invoking its properties and methods, and it is always available from any script file. "

Simply put WScript provides access to root object for the Windows Script Host object model.


WScript is the default Windows Script Host Object, HTML can only communicate with it via ActiveX. So that's why we need ActiveXObject() instead of WScript.CreateNewOjbect(). And instead of WScript.Echo(); we have to use window.alert which is a built-in function for Javascript.



The initial js Code:

var iTunesApp = WScript.CreateObject("iTunes.Application");
WScript.Echo(allPlaylistNames());

function allPlaylistNames() {

var librarySource = iTunesApp.LibrarySource;
var listOfPlaylists = librarySource.Playlists;
var playlistReturn = new Array();

for(i = 1; i <= listOfPlaylists.Count; i++) { playlistReturn[i] = listOfPlaylists.Item(i).Name + '[[sep]]p_' + i; } return playlistReturn.sort(); }


Change it to :

var iTunesApp = new ActiveXObject("iTunes.Application");
window.alert(allPlaylistNames());

function allPlaylistNames(){
var librarySource = iTunesApp.LibrarySource;
var listOfPlaylists = librarySource.Playlists;
var playlistReturn = new Array();

for(i = 1; i <= listOfPlaylists.Count; i++) {
playlistReturn[i] = listOfPlaylists.Item(i).Name + '[[sep]]p_' + i;
}
return playlistReturn.sort();

}

References:

http://msdn2.microsoft.com/en-us/library/at5ydy31.aspx
http://thegreenbutton.com/forums/thread/84583.aspx
http://microsoft.apress.com/asptodayarchive/73503/accessing-the-windows-system-using-activex-and-html

Run External Jscript in an External Jscript

My goal is to have an external js file loading a set of js files. In this case, for starters, just one subsequent external js, js2.js.



loader.html - to load all the subsequent js files.



<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<title>JsLoader</title>

<script src='js1.js' type='text/javascript' /></script>

</head>


<body>

<input type="button" onClick="f1()" value="Load" />


</body>

</html>



js1.js - External js file 1



function f1(){

var NewScript=document.createElement('script')

NewScript.src="js2.js"

document.body.appendChild(NewScript);

f2();

}



j2.js- External js file 2



function f2(){

alert('I told you I can get here!')

}





Files:
loader.html
js1.js
js2.js

Sunday, November 18, 2007

Run External Javascript on Webpage

Create a HTML file msgBox.html, without Importing External Js:


<HTML>

<HEAD>


<SCRIPT LANGUAGE="JavaScript">

function MsgBox (textstring) {

alert (textstring) }

</SCRIPT>


</HEAD>


<BODY>


<FORM>

<INPUT NAME="text1" TYPE=Text>

<INPUT NAME="submit" TYPE=Button VALUE="Show Me" onClick="MsgBox(form.text1.value)">

</FORM>


</BODY>

</HTML>


Create File msgBox.js with the code:


function MsgBox (textstring) {

alert (textstring) }

Change the html code to:




<HTML>

<HEAD>

<script src='msgBox.js' type='text/javascript' /></script>

</HEAD>

<BODY>

<FORM>

<INPUT NAME="text1" TYPE=Text>

<INPUT NAME="submit" TYPE=Button VALUE="Show Me" onClick="MsgBox(form.text1.value)">

</FORM>

</BODY>

</HTML>





Download

msgBox.html - html page holding the javascript

msgBox.js - js file to be imported






References:

http://www.webteacher.com/javascript/ch01.html

Adsblacklist.com

Site Name: Adsblacklist
Link: http://www.adsblacklist.com/

Useful for:

By keeping you updated with a list of Advertisers with low payouts, you can avoid wasting your time on a bunch of cheap sites offering only $0.01 all day. Average payout of not-so-bad advertisers should be around $0.50.

How does it works?

Blacklist works by:"[...]providing you with list of most commonly filtered websites whose webmasters use AdWords to attract visitors for low price click so they can convert it to high price click on their own MFA (Made for AdSense) site(s). In order to STOP these type of actions going on your sites, all you need to do is to paste our specially generated list to your AdSense Setup -> Competitive Ad Filter list. Your revenue should substantially increase."

Emphasize Content for Adsense Content Targeting

It used to be a pain to use adsense on Bloggers because it targets the entire page and will only show ads relevant to the keyword "Blog". Those blog sits usually have very low CPM so it won't amount to any significant amount of money.

Now here is a simple tip for Adsense users. You can emphasize areas of your page to the Adsense Bot so that it will weigh the your highlighted areas more than others. You are not allowed to use this trick to target on irrelevant areas for more profits. This simply gives you more control, although not absolute, to what will be shown on your Adsense ads.

Cratle Notes:

Emphasize to show

<!-- google_ad_section_start -->
Content to be targeted by Adsense Bot
<!-- google_ad_section_end -->


Emphasize to ignore

<!-- google_ad_section_start(weight=ignore) -->


Reference:
https://www.google.com/adsense/support/bin/answer.py?answer=23168&topic=8441

Setting up Apache 2 and PHP 5 on Vista Home Basic

So painful as it can be...it took me 5 hours of tolls get these two basic web development environment on my Windows Vista Home Basic. It is so ridiculously painful that I even decided to open this personal tech note blog. I remember I have been pained by similar installation drills for at least 3 times, I don't want this dumb shit to happen to me again. Let's make this for the same cause as the existence of history---the hope to avoid repeating the same mistakes.


Damn, it is 4:25 am already.

Cratle Notes:

Preparations

Downloads
Software : Version : Platform : File
PHP5 : 5.2.5 : Win32 : File
Apache 2.x : 5.2.5 : Win32 : File

To-Do
Turn off the Windows Firewall
Turn off User-Control from Control Panel -> User Settings


Steps:
Install Apache first
Then Install PHP 5



Installing PHP 5:
Do not intall all those extensions, leave it as default.
Only the PHP - Program - CLI Executable is useful
Otherwise there will be many errors due to files not found when executing php -v in cmd

After installing php5:
Open (Apache Path)\conf\httpd.conf

PHP msi added the following lines at the bottom of the file:

#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
ScriptAlias /php/ "C:/PHP/"
Action application/x-httpd-php "C:/PHP/php-cgi.exe"
PHPIniDir "C:/PHP/"
LoadModule php5_module "C:/PHP/php5apache2_2.dll"
PHPIniDir "C:/PHP/"
LoadModule php5_module "C:/PHP/php5apache2.dll"
PHPIniDir "C:/PHP/"
LoadModule php5_module "C:/PHP/php5apache.dll"
#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL

Change it to

#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
ScriptAlias /php/ "C:/PHP/"
Action application/x-httpd-php "C:/PHP/php-cgi.exe"
PHPIniDir "C:/PHP/"
#LoadModule php5_module "C:/PHP/php5apache2_2.dll"
#PHPIniDir "C:/PHP/"
LoadModule php5_module "C:/PHP/php5apache2.dll"
#PHPIniDir "C:/PHP/"
#LoadModule php5_module "C:/PHP/php5apache.dll"
#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL

Working

Notable References

http://senese.wordpress.com/2007/06/06/install-php-5-under-apache-22-and-windows-vista/
http://www.expertsrt.com/tutorials/Matt/install-apache.html

4:34 AM 11/18/2007