Archive for January, 2009

web2.0: Youtube RSS API

Friday, January 30th, 2009

Getting the User RSS:

  1. http://www.youtube.com/rss/user/[username]/videos.rss
  2. http://gdata.youtube.com/feeds/base/users/[username]/uploads?alt=rss&v=2&client=ytapi-youtube-profile

#2 seems to be the official google GDATA way, but it does not get the same list that you can see in the user’s profile. #1 gives the expected result. I cannot find a way to get the “videos” view with the #2 (GDATA) format (note: changing “uploads” to “views” does not work). I will look more into it and update this post.

See Also:

Java: ActiveMQ in-VM Configuration, Initialization, and Usage

Saturday, January 24th, 2009

Creating a Connection Factory (Programmatic):

import org.apache.activemq.ActiveMQConnectionFactory;
import javax.jms.Connection;
import javax.jms.Session;
...
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
...
Connection connection = factory.createConnection();
...
connection.start();
...
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

Java: Open Source JMS

Saturday, January 24th, 2009

I am looking at an in-VM (or in-Application) JMS implementations. ActiveMQ seems to have good support for in-vm JMS.

ActiveMQ

ActiveMQ: is an open source, Apache 2.0 licensed Message Broker and JMS 1.1 implementation which integrates seamlessly into Geronimo, light weight containers and any Java application. JMS 1.1 / J2EE 1.4 compliant, full support for JCA resource adaptors, upport for transient, persistent, transactional and XA messaging, supports in-VM, TCP, SSL, NIO, UDP, multicast, JGroups and JXTA transports, REST API, Streamlets to support web streaming support, in memory JMS provider, ideal for unit testing, JSR 77 / 88 support for easy deployment & management & hot deployment, rules based message routing via Drools.

In-VM URI example:

vm://broker1?marshal=false&broker.persistent=false&async=false

See Also:

Other JMS Implementations

  • mom4J: is a 100% pure Java® implementation of the Java Message Service (JMS)® specification, published by Sun Microsystems®. LGPL
  • OpenJMS – Supports both Point-to-Point and publish-subscribe messaging models, Guaranteed delivery of messages, synchronous and asynchronous message delivery, persistence using JDBC, Local transactions, message filtering using SQL92-like selectors, Applet support, integrates with Servlet containers, and support for RMI, TCP, HTTP and SSL protocol stacks.

See also:

jDom: Converting from JDOM to DOM

Saturday, January 24th, 2009
public org.w3c.dom.Document convertToDOM(org.jdom.Document jdomDoc)
     throws JDOMException {

     DOMOutputter outputter = new DOMOutputter();
     return outputter.output(jdomDoc);
}

public org.w3c.dom.Element convertToDOM(org.jdom.Element jdomElement)
     throws JDOMException {
     DOMOutputter outputter = new DOMOutputter();
     return outputter.output(jdomElement);
}

public org.w3c.dom.Attr convertToDOM(org.jdom.Document jdomAttribute)
     throws JDOMException {
     DOMOutputter outputter = new DOMOutputter();
     return outputter.output(jdomAttribute);
}

Source: Tip: Converting from JDOM

jQuery: UI Sortable Syntax

Friday, January 23rd, 2009
<script type="text/javascript">
    $(document).ready(function() {
       $(".myList").sortable({
           revert: true
       });
    });
</script>
<ul id="myList">
	    <li>Item 1</li>
	    <li>Item 2</li>
	    <li>Item 3</li>
	    <li>Item 4</li>
</ul>

jQuery UI Sortable API

MySql: Import dump file in MySql

Friday, January 16th, 2009
mysql -u dbuser -p database < file-dump.sql

WordPress: Stop Replacing Double Dash with Em-dash

Friday, January 16th, 2009

WordPress automatically replace ‘--‘ by ‘–‘.

2 Options:

    1) use <code>

    <code>--</code>

    2) Edit SITE_ROOT/wp-includes/formatting.php

    and change the $static_characters and $dynamic_replacements
    This is quite risky and not really good for maintenance.

Tech: Derby vs Oracle Berkely DB JE

Friday, January 16th, 2009

Great Discussion on Derby vs Oracle BDB JE

MySql: backup, mysqldump nodata, no structure, no create table

Wednesday, January 14th, 2009

MySql Dump

# mysqldump -u dbuser -p[pwd] --opt database > database_backup.sql

MySql Dump without data (only structure)

# mysqldump -u dbuser -p[pwd] --no-data database > database_backup.sql

MySql Dump without structure (no drop/create table)

# mysqldump -u dbuser -p[pwd] --no-create-db --no-create-info database > database_backup.sql

Import SQL file

mysql -u user_name -p  database_name < /path/to/file.sql

MySql: Show, Desc, Info on Database and Table

Wednesday, January 14th, 2009

Show Database

mysql> show databases

Show Tables

mysql> use my_database
mysql> show tables

or Show Table Status for more information

mysql> show table status

Describe Table

mysql> desc my_table

MySql Cheat Sheet