Chrome is not showing frame border

 

I have frameset with

   1: frameborder="yes"

attribute.  It works well in IE and FF (showing borders between frames) but not in Chrome.

 

Workaround very simple  — just delete attribute completely. Now it working in all browsers.

onfocus not working in Chrome

That is. I am just trying to adjust some old project, working fine only in IE8, to Firefox and Chrome.

 

Workaround very simple  –  change onfocus to onclick.

click() not working in Chrome

 

I have code like

   1: var link = document.getElementById("myLink");

   2: link.click();

and it is working in all browsers (really tested in IE8 and FF9) but not in Chrome.

 

Stackoverflow has three questions about this issue without workaround.

http://stackoverflow.com/questions/5015893/onclick-parent-getelementbyid-click-not-working-in-chrome

http://stackoverflow.com/questions/1938356/chrome-browser-action-click-not-working

http://stackoverflow.com/questions/7857289/click-not-working-in-chrome

People speak about some security limits.

And voila – solution:

   1: var link = document.getElementById("myLink"); //existing code

   2: $(link).click();

or pure jQuery style:

   1: $("#myLink").click();

jQuery rules!!

How to close parent window in Firefox and Chrome

.. and possible also in Opera, Safari etc.

The problem:

   1: parent.window.close();

that working well in IE8 but not working in Firefox and Chrome. Some state that for security reasons.

Solution (lol):

   1: top.window.close();

 

A little more details:

I have a page that opens popup using showModalDialog(….) function.

Inside popup i have a frameset(old project) with two frames. One of them have button which onclick="parent.window.close()" not working in FF but onclick="top.window.close()" successfully closes popup.

 

If You american citizen do something with SOPA because it can be "ZHOPA".

Good Luck!

GetResource().getPath() FileNotFoundException while running from jar

I have some code that works correct when run from Eclipse, but throws FileNotFoundException when run from jar.

Even more this code properly worked before but stopped after… I don’t know. May be after some Windows update?

Here is the code

 

   1: String path = Thread.currentThread().getContextClassLoader().getResource("stopwords.txt").getPath();

   2: System.out.println(path);

   3: BufferedReader input = new BufferedReader(new FileReader(new File(filePath)));

Output: file:/F:/PROMOTION/executor.jar!/stopwords.txt  — correct path to file, so file is found by getResource(…) method.

Exception thrown from code line 3:

java.io.FileNotFoundException: file:\F:\PROMOTION\executor.jar!\stopwords.txt (The filename, directory name, or volume label syntax is incorrect)

What cause for this strange behavior  I don’t know. Stackoverflow has about 4 questions about same issue, but not explain cause as well.

But workaround (at least in my case) the next: to use getResourceAsStream() instead of getResource().getPath() and Scanner instead of BufferedReader.

Full working code is looks like:

   1: InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("stopwords.txt");

   2: List<String> lines = new ArrayList<String>();

   3:          Scanner scanner = new Scanner(stream);

   4:             try {

   5:               while (scanner.hasNextLine()){

   6:                 lines.add(scanner.nextLine());

   7:               }

   8:             }

   9:             finally{

  10:               scanner.close();

  11:             }

The most [java] advanced country

Today i downloaded from sourceforge some java library and occasionally looked on statistics.

The first place with 20% from all downloads  takes … China.

USA on the second place. India – 3. Spain – 4. And so on.

Component doesn’t fill container on resize

 

I have [custom] component that change its width  but not height  on resize. Cause is probably a bug in SWT Designer.  This code was auto generated and produce a problem

GroupLayout gl_shell = new GroupLayout(shell);

        gl_shell.setHorizontalGroup(

            gl_shell.createParallelGroup(GroupLayout.LEADING)

                .add(composite, GroupLayout.DEFAULT_SIZE, 800, Short.MAX_VALUE)

        );

        gl_shell.setVerticalGroup(

            gl_shell.createParallelGroup(GroupLayout.LEADING)

                .add(composite)//problem here

        );

that looks like:

Untitled

changing code to :

 

gl_shell.setHorizontalGroup(

            gl_shell.createParallelGroup(GroupLayout.LEADING)

                .add(composite, GroupLayout.DEFAULT_SIZE, 800, Short.MAX_VALUE)

        );

        

        gl_shell.setVerticalGroup(

                gl_shell.createParallelGroup(GroupLayout.LEADING)

                    .add(composite, GroupLayout.DEFAULT_SIZE, 542, Short.MAX_VALUE)

            );

solve the problem.

How to program bots in Java?

 

So, what about writing bots in Java? Question only looks hard but have very simple answer:

Use:

  1. HtmlUnit;
  2. Selenium;

Using HtmlUnit to writing bots pretty good described.

 

What is Selenium?

Selenium is testing framework that consist of Firefox plugin that can record user’s actions in browser and Java (several another languages as well) API allowed to “play” this record from Java application.

While HtmlUnit has some limitations, Selenium (or bot written using Selenium) can do all what user can do in Firefox.

Bots programmed with HtmlUnit can be multithreaded (very fast) but some times have problem with Javascript rich sites.

By the way Selenium can use HtmlUnit as “player” as well as Firefox and Chrome. Interesting question If HtmlUnit limitations applied to Selenium tests run on HtmlUnit.  

 

Below is a code snippet from my program that submits link to one of the famous social bookmarking sites. Snippet shows what is the “user’s actions record” that selenium provides.

 

selenium.open("/");

selenium.type("password", password);

selenium.click("rememberme");

selenium.click("login-submit");

selenium.waitForPageToLoad("30000");

selenium.click("link=Favorites");

selenium.waitForPageToLoad("30000");

selenium.click("link=Add a site");

selenium.type("url", url);

selenium.type("review", review);

selenium.click("link=Add a site >");

selenium.type("topic", topic);

selenium.click("sfw");

selenium.click("//input[@value='Submit >']");

selenium.waitForPageToLoad("30000");

ShareEveryWhere

I am just registering application on Twitter, so this page is answer for Twitters request about application homepage.

Google ranking factors

Google always make choice between relevance and authority.

Relevance factors  always on-page factors, but authority factors always off-page factors.

Read the rest of this entry »

Simple blogging with AdSense using Easy-Peasy AdSense Plugin and AdCode Widget Plugin

 

  1. Inserting AdSense code to main column using Easy-Peasy AdSense Plugin.
  2. Inserting AdSense code to sidebar using AdCode Widget Plugin.

Read the rest of this entry »

XAMPP vs WAMP on Windows 7

Great day. I successfully installed  XAMPP on Windows 7.

The only reason why I use Windows 7 that it was preinstalled on the laptop I bought.

I wanted to install WordPress locally so i needed environment: apache, php, mysql. There are three options available:

  • WAMP;
  • XAMPP;
  • separate installation for all needed.

I started from WAMP and not succeed. I read many forums and discover that many people have the same or similar problem.

Useful tips that i found there was:

  1. disable UAC;
  2. check hosts file (must contains only one uncommented row:      127.0.0.1           localhost).

But also after doing this i cannot make it works.

So, I moved to second option XAMPP. And succeed with no problem.

Viva XAMPP!

How to join multiple css

I host my sites on bluehost and have client with hosting on hostmonster, and on both this hostings i experienced very slow page loading. About 20 sec. WordPress simple theme, no images. The main cause as i see in firebug is a multiple css files.  Server response to first request for css immediately, but for second and/or third and further waiting time grow up to 10 sec per request.

Explicitly required to join multiple css files (main theme css and those that come from plugins) to one.

Possible solutions:

  1. manually remove from all plugins code that register plugin’s css file and manually copy-paste all css content to main style.css file.
  2. use some plugin, that make all above work.

 

First solution i declined instantly. I am lazy. So, i went to google.com and query  “join multiple css wordpress plugin”.

First found was Speedy plugin that seems unsupported from 2008. Google’s algorithm though efficient some times returns such things.

But second was http://omninoggin.com/wordpress-plugins/wp-minify-wordpress-plugin/ by MadeinThayaLand. I try it and i am very satisfied.  Now my client’s site loading time go down to 6 sec. Only!.

 

And more, this programmer-girl looked like girl and really programmer: she has many useful plugins already downloaded almost 1,000,000 times.

And even more she has name like my first dream country (I am currently live in Thailand) and lives in Costa-Rica my second dream country.

That’s all.

Posting to Blogger using API

As I wrote in previous post Blogger API has pretty low rate limit – 50. So if your case is thousands of posts use WordPress with XML-RPC, but if 50 is just suitable then code below can help.  Don’t forget to download API and dependencies

 

public class BloggerAutoPost {

 

     static final String EMAILACCOUNT = "googleaccount_email";

     static final String PASSWORD = "password";

     GoogleService service;

     String  blogId;

     Collection<Post> posts;

 

 

    public static void main(String[] args) throws Exception {

       BloggerAutoPost bloggerAutoPost = new BloggerAutoPost();

       bloggerAutoPost.load();

       bloggerAutoPost.login();

       bloggerAutoPost.getBlog();

       bloggerAutoPost.metaPost();

   }

 

    void load(){

      //initialize collection of posts  

 

    }

 

    void metaPost(){

        for (Post post : posts){

            post(post);

        }

    }

 

    private void login() throws AuthenticationException {

        service = new GoogleService("blogger", "test");

        service.setUserCredentials(EMAILACCOUNT, PASSWORD);

 

    }

 

    private void post(Post post) throws Exception {

        Entry myEntry = new Entry();

        myEntry.setTitle(new PlainTextConstruct(post.title));

        myEntry.setContent(new PlainTextConstruct(post.body));

        Set categories = myEntry.getCategories();

        Category category = new Category();

        category.setTerm(post.category);

        category.setLabel(null);

        category.setScheme("http://www.blogger.com/atom/ns#");

        category.setLabelLang(null);

        categories.add(category);

 

        // Ask the service to insert the new entry

        URL postUrl = new URL("http://www.blogger.com/feeds/" + blogId + "/posts/default");

        service.insert(postUrl, myEntry);

 

    }

 

    private void getBlog() throws MalformedURLException, IOException, ServiceException {

        // Request the feed

        final URL feedUrl = new URL("http://www.blogger.com/feeds/default/blogs");

        Feed resultFeed = service.getFeed(feedUrl, Feed.class);

 

        // Print the results

        System.out.println(resultFeed.getTitle().getPlainText());

        for (int i = 0; i < resultFeed.getEntries().size(); i++) {

            Entry entry = resultFeed.getEntries().get(i);

            blogId = entry.getId().substring(entry.getId().indexOf("-", 30) + 1);

            System.out.println("\t" + entry.getTitle().getPlainText());

            System.out.println(blogId);

        }

 

    }

 

}

 

class Post {

 

    String title;

    String body;

    String category;

 

    public Post(String title, String body, String category) {

        this.title = title;

        this.body = body;

        this.category = category;

    }

}

Blogger API post limits

 

I tried to post to Blogger  through API. In the next post I will provide code details. But when i finally polished my client and run it to post several thousands of posts,  I discovered that Blogger API have pretty low post limit. Only 50 posts can be post, after this number I got:

 

com.google.gdata.util.InvalidEntryException: Bad Request
Blog has exceeded rate limit or otherwise requires word verification for new posts

Workaround can be: wait 1 hour, then relogin and continue, but I simply bored from Blogger already. I come back to WordPress :) . WordPress XML-RPC client not more complex then Blogger and I already successfully posted almost 5000 posts per night.:)

Traffic data available at Google Ad Planner only for high popular sites

Above statement pretty trivial.

But interesting that Google seems to use Alexa rank and produce Ad Planner data only for sites with Alexa Rank less than 100,000.

For example site http://www.familiararticles.com ranked 99651 on Alexa included in Ad Planner database, but site http://www.womenhealthexercise.com/ ranked 100,238 did not.

Possible to conclude that Google consider sites with Alexa Rank less than 100,000 not important at all? And use it in particular for backlink building planning?

Great spam comments examples

This girlforlegos (nofollow link) just posted on one of my blogs the comments that can be read below. Firstly i just wanted to mark them as spam, but i go and look at site: poor but not dangerous adsense blog and comments really great :D . So, I finally approved them all:

  1. I dont know what to say. This blog is fantastic. Thats not really a really huge statement, but its all I could come up with after reading this. You know so much about this subject. So much so that you made me want to learn more about it. Your blog is my stepping stone, my friend. Thanks for the heads up on this subject.
  2. Im not going to say what everyone else has already said, but I do want to comment on your knowledge of the topic. Youre truly well-informed. I cant believe how much of this I just wasnt aware of. Thank you for bringing more information to this topic for me. Im truly grateful and really impressed.
  3. After reading this I thought it was very informative. I appreciate you taking the time and effort to put this post together. Once again I find myself spending way to much time both reading and commenting. But so what, it was still worth it!
  4. You certainly understand what youre referring to. Man, this website is simply excellent! I cant wait to browse more of what youve got to share. Im actually delighted that I discovered this when I did since I had been truly starting to become tired with the total writing world. Youve turned me around, dude!
  5. I thought it was going to be some boring old post, but it really compensated for my time. I will post a link to this page on my blog. I am sure my visitors will find that very useful.

The biggest(30!) list of project hosting sites

I looked for some project hosting site to store my projects. So, I made small research and find several sources already containing such collections. Besides of this I googled for “project hosting” and founded sites also added to result list:

Assembla

Asynchrony
BerliOS
bitbacket.org

Bounty Source
code.google.com
codeplex.com/
CodeSpaces
freepository
GBorg
GForge 2
github.com
gna.org/
icculus.org
java.net/
kenai.com
OpenSVN
projectlocker.com
origo.ethz.ch/
Savannah
SEUL
sourceforge.net
SunSITE.dk
tigris.org/
Unfuddle
XP-Dev

Free Windows Blogging Software Review

Finally, I decided to be professional blogger :) and to start to use some desktop blogging software.

Important features used as criteria:

– free;

– must support all major blog engines (firstly Wodpress, Blogger and LiveJournal);

– firefox like misspelling highlighting;

– optionally can simultaneously post to multiple blogs.

So, i found this wordpress codex page with list of wordpress blog clients, browsed and choose some of them to download and test:

– BlogDesk;

– QTM;

– Qumana;

– Zaundry;

– Zaundry Raven;

– Windows Live Writer;

I checked them very quickly and possible dismissed something. I was unable to connect to my blog with QTM and Zaundry Raven threw some error message so  I deleted them from list. So, next list is windows blogging software that was connected and properly worked from 1st attempt.

– BlogDesk;

– Qumana;

– Zaundry;

– Windows Live Writer;

BlogDesk the only free windows blogging software that can simultaneously  publish to multiple blogs. Sometimes it can be useful. But list of supported blog engines is very short. Blogger and LiveJournal are not supported. So, can be used only if mass posting to WordPress blogs needed.

Qumana places some annoying “powered by” message in new post. Deleted.

Zaundry is very good: big list of supported engines, nice interface, but spelling must be run by user and not comfortable at all for me.

Windows Live Writer the best. Finally some Microsoft software that i like more than opensource analogs. Over all above has amazing preview feature making possible to see how post will be looks like after posting to web.

Test Post From BlogDesk to multiple blogs

I am currently testing blog writing desktop clients. And BlogDesk seems to be owner of very interesting feature: simultaneous posting to multiple blogs.

So, I post……………………………

………. OK. Posted successfuly to 2 different blogs.


wp