|
Stanford University is one of the world’s leading research and teaching institutions.
Actually they are erogating free online courses for several disciplines.
The following list report courses that are most interesting for me.
If you’re interested in other courses, follow the link of one course, then look at other available courses.
Cryptography, Dan Boneh
http://www.crypto-class.org/
Class starts February, 2012

Human-Computer Interaction Scott Klemmer
http://www.hci-class.org
Class starts January 30, 2012

Design and Analysis of Algorithms I, Tim Roughgarden
http://www.algo-class.org
Class starts February 2012

Technology Entrepreneurship, Chuck Eesley
http://www.venture-class.org
Class starts February 2012

References
This article introduces mybatis java (iBatis 3 for java) and summarizes its configurationand usage. The article also give suggestions and conclusions on mybatis usage.

Introduction
The iBATIS Data Mapper (born in 2002) is a framework that introduces SQL Mapping approach to persistence layer development. The iBATIS name and code was donated to the Apache Software Foundation, that hosts project development for many years.
In 2010 the core development team of iBATIS has decided to continue development under new home: Google Code; and with a new name: mybatis .
Actually both the Java and .NET project teams have forked the software to Google Code ( mybatis Java and mybatis .NET ). The new version of the project added support to metadata annotations.
Configuration
building SqlSessionFactory from XML is quite simple:
String resource = "org/mybatis/example/Configuration.xml";
Reader reader = Resources.getResourceAsReader(resource);
sqlMapper = new SqlSessionFactoryBuilder().build(reader);
The configuration file contains settings for the core of the MyBatis system
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC" />
<dataSource type="POOLED">
<property name="driver" value="${driver}" />
<property name="url" value="${url}" />
<property name="username" value="${username}" />
<property name="password" value="${password}" />
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="org/mybatis/example/BlogMapper.xml" />
</mappers>
</configuration>
note:
- ${parameterName} : indicate a parameter, usually taken via propery file ..
- mapper: imply the existence of the BlogMapper.xml file
This snippet of code shows how to do an XSL transform with Java
private static final String ERR_XSL_CONFIGURATION = "Error during XSL Transform configuration.";
private static final String ERR_XSL_TRANSFORM = "Error during XSL Transform execution.";
/** XSL Transform with input, output and parameters. */
@SuppressWarnings("unchecked")
public static void transform(Source xml, Source xsl, Result out, HashMap< String, ? > params){
// factory init
TransformerFactory factory = TransformerFactory.newInstance();
// Transformer object init
Transformer t;
try {
t = factory.newTransformer(xsl);
} catch (TransformerConfigurationException e) {
// if any XSL error
throw new RuntimeException( ERR_XSL_CONFIGURATION, e );
}
// insert parameters (if any)
if( params != null && params.size() > 0 ){
Iterator< ? > i = params.entrySet().iterator();
Entry< String, ? > me ;
while(i.hasNext()){
me = (Entry< String, ? >) i.next();
t.setParameter(me.getKey(), me.getValue());
}
}
// Transformation execution
try {
t.transform(xml, out);
} catch (TransformerException e) {
// if any Transformation error
throw new RuntimeException( ERR_XSL_TRANSFORM, e );
}
}
The JSP Standard Taglibrary (JSTL) encapsulates as simple tags, several core functionalities common to many JSP applications. For example it contains tags for store / display variables, make iterations, XML manipulation, Input / Output, and so on.
This post explain how to setup a page with JSTL and make some examples for common tags.
Install JSTL
To use a tag library you need to import jar libraries containing the implementation and define tags that invoke functions inside the library.

You can find jstl-1.2.jar on the web or from this local archive.
Test JSTL
Since the jat we’ve copied contains both libraries and TLD definitions, we can start to use JSTL tags. To use them, first we need reference JSTL with a declaration at top of JSP. In the shippet below we reference the jstl/core library, whose tags are available under the prefix “c:” .
<!-- declare usage of common -->
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
Then we could put some JSTL tags inside the page.
<h1>Test JSTL</h1>
<!-- import an xml file in a variable, then prints out to page -->
<c:import url="test.xml" var="xml"/>
1. <c:out value="${xml}"/><br/>
2. <c:out value="${xml}" escapeXml="false"/><br/>
In the snippet above we used
- c:import to read a file on the server, and store content inside a varuable
- c:out to output the content of a variable to the page (you could escape xml)
See the screenshoot

To make some further test with the jstl/core we insert another two snippet, for loops. The first show a simple loop that build a table
<table border="1">
<tr>
<th>i:</th>
<c:forEach var="i" begin="1" end="10" step="1">
<td><c:out value="${i}"/></td>
</c:forEach>
</tr>
</table>
The second list page parameters. Take care that param is an implicit Map object.
<ul>
<c:forEach var="pageParameters" items="${param}">
<li><c:out value="${pageParameters.key}"/> =
<c:out value="${pageParameters.value}"/></li>
</c:forEach>
</ul>
The result, obvious, are a table and a list. But instead to watch the picture, you can build yourself.

Enjoy.
References
Some PL/SQL snippets of code
Backup and recovery of a table
First create a backup copy of your table
backup
create table MY_TABLE_BACK
AS
select * from MY_TABLE
After your stuff, recovery the original table
insert into MY_TABLE
select * from MY_TABLE_BACK
delete all rows
delete from MY_TABLE_BACK
select *
from orders
where id = &ID
before executing the query will appear a Dialog asking for variable

Find keys referencing your table
-- find foreign keys
select table_name from user_constraints
where r_constraint_name in
(select constraint_name
from user_constraints
where constraint_type in ('P','U')
and table_name = upper('&tableOfInterest')
)
Group and count
Group by and count limit to ten rows
select *
from (select count(*), t.id_order
from order_cart t
group by m.id_order
order by count(*) desc)
where rownum < 10
Rename Columns
alter table MY_TABLE_NAME
rename column OLD_NAME to NEW_NAME
List column names
SELECT column_name
FROM user_tab_cols
WHERE table_name = 'MY_TABLE_NAME'
List available tables in a schema
The following script list data for available tables in specified schema, and order rows by table name.
SELECT *
FROM all_tables
WHERE owner = upper('&SCHEMA_NAME')
ORDER BY table_name
Since there is the parameter &SCHEMA_NAME, before executing the query will appear a dialog in which you can insert the name of schema.

References:
http://stackoverflow.com/questions/926437/is-there-a-way-to-view-relationships-in-oracle-sql-developer
http://viralpatel.net/blogs/2009/08/fast-data-copy-with-create-table-select-from-in-plsql.html
This article explain how to use XSL Transformation to build an XHTML document.
XSL Transform for build XHTML
Assume we want transform following XML document
<?xml version="1.0" encoding="UTF-8"?>
<books>
<book isbn="9781849511742" title="WordPress 3.0 jQuery" pdate="24/09/2010"/>
<book isbn="9781849511407" title="WordPress Top Plugins" pdate="21/09/2010"/>
<book isbn="9781847196569" title="WordPress 2.7 Complete" pdate="02/06/2009"/>
<book isbn="9781849510080" title="WordPress 2.8 Theme Design" pdate="30/11/2009"/>
<book isbn="9781847197382" title="WordPress 2.7 Cookbook" pdate="15/07/2009"/>
<book isbn="9781847193599" title="WordPress Plugin Development: Beginner's Guide" pdate="16/02/2009"/>
<book isbn="9781847198822" title="WordPress and Flash 10x Cookbook" pdate="19/04/2010"/>
<book isbn="9781849512367" title="Joomla! 1.5 Cookbook" pdate="26/10/2010"/>
<book isbn="9781849511803" title="Joomla! 1.5 Top Extensions Cookbook" pdate="18/10/2010"/>
<book isbn="9781849512220" title="Building job sites with Joomla!" pdate="21/09/2010"/>
<book isbn="9781849511704" title="Joomla! 1.5 Site Blueprints" pdate="26/05/2010"/>
<book isbn="9781847199904" title="Joomla! 1.5: Beginner's Guide" pdate="05/03/2010"/>
<book isbn="9781847195166" title="Joomla! 1.5x Customization: Make Your Site Adapt to Your Needs" pdate="24/08/2009"/>
</books>
An XSL Transform take on XML input and will produce output in several formats. To produce XHTML output we must define the correct output format at the top of the document.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8"
doctype-public="-//W3C//DTD XHTML 1.1//EN"
doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
indent="yes"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Books</title>
</head>
<body>
<h1>Books</h1>
<table>
<tr>
<th>isbn</th>
<th>title</th>
<th>publish date</th>
</tr>
<xsl:for-each select="books/book">
<tr>
<td><xsl:value-of select="@isbn"/></td>
<td><xsl:value-of select="@title"/></td>
<td><xsl:value-of select="@pdate"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The transform is quite simple, and here, there is an image showing the output result.

You can download source code
References
This article introduce wordpress for business users, focusing on those themes:
Web-log-ging
Blogging began very much as an exercise in personal publishing. The majority of blogs take the form of a personal journal, which no implicit business agenda. However many ‘personal’ bloggers have found ways to monetize their activity; there is now a growing breed of ‘professional bloggers’, who derive much, in not at all of their income from blogging.
With politicians and influential journalists playing an active role in the blogosphere, it wasn’t long until the business community recognize the potential benefits of blogging. Today business blogging is commonplace with more and more web users expecting to see a ‘Blog’ on company home pages.
we can see three types of Blog: Personal Weblog, Political Weblog and Business Weblog.
Business Weblog
Key of success for a blog is having a clear vision of what you want it to do for you. This is calledblogging strategy. Once it’s clear in your mind, you can start to set concrete tactical goals for your blog.
weblogs can be a very inexpensive form of marketing – you can get a lot of value for a relatively small investment.
Some common strategic goals of business blogging: increase sales; add value to product and services; open dialog with your customers; raise awareness of your company, product and services; demonstrate your knowledge and expertise; to provide customer service and support; to improve public relations (media, reputation, crisis, and so on); to drive traffic to your other websites; to give some personality to your corporate image.,
You can have several of these strategic goals in mind for your blog. Your blog can achieve one or a combination of these.
Categorization of Business Weblogs
By understanting what your tactical goals are, you can probably detrmine what type of blog you should have.
- Product weblogs - strategic goals: increase sales and add value
- Corporate or Company weblogs – strategic goals: several strategic goals
- News weblogs – strategic goals: showing expertise and adding personality (increasing sales)
- Expert weblogs – strategic goals: raising awareness of the expert’s business activities; demonstrating knowledge and expertise and driving traffic to the expert’s other websites.
useful tools:
- contact form 7: have a simple CAPTCHA contact form on your WordPress blog
- google XML sitemaps: help search engine to better index your blog
- SEO Super Super Comments: create a new dynamic page for each comment
- gain competitive edge with a well polished weblog
for who start a business blog using WordPress.
References
This document contains some hints on how to use for object oriented programming.
jQuery snippets
Some snippets of code showing how to use jQuery
// return true if the element is an input
$('#elementId').is('input');
// get the name of the tag
$('#elementId').get(0).tagName
Plain Object Definition
simple example: define an object in javascript [link_01]
This sample show how to define and use an object in javascript.
First the object is created, like a function; then we add a constructor and a method using the prototype property.
// define Object as a function
function StringBuffer(){
this.buffer = [];
}
// add a constructor with one string parameter
StringBuffer.prototype.append = function append(string){
this.buffer.push(string);
return this;
}
// add one method to the object
StringBuffer.prototype.toString = function toString(){
return this.buffer.join('');
}
Now we can instantiate the object and use its data and methods.
// new instance
var buf = new StringBuffer();
// use the instance
buf.append('hello');
buf.append('world');
alert(buf.toString());
References
Gimp is a free application for drawing and image editing.
GIMP is like a professional tool with many features and in no way inferior to professional applications like Photoshop, CorelDraw, etc.
See the official site, e la official documentazione.
On Internet there are many tutorial that explain how to use GIMP. There is a list of those of my interest:
Tutorial
Logo 2.0 con GIMP (IT), HTML.it
Web 2.0 Text logo (EN)
Gimp Tutorial: Logo-Design ( DE ), YouTube video
Creare un bigliettino da visita con GIMP (IT), YouTube video
Create a grunge business card using GIMP (EN)
Design a business card with the GIMP (EN)
40 + Excellent GIMP Tutorial for designers (EN)
This article contains some code snippets that I commonly use for Java I/O.
Create temp file
Create a temp file inside a specified folder
/** max index reached with temp files */
public static int MAX_INDEX = 100;
/**
* Create a temporary file in specified folder. To create the file
* use prefix and postfix passed as parameters. Temporary files
* are numbered according to an internal index.
*
* @param baseDir path of base directory that will contain file
* @param prefix file prefix
* @param postfix file postfix
* @return temporary File or null
*/
public static File createTempFile(String baseDir, String prefix,
String postfix) throws Exception {
File parentDir = new File(baseDir);
File tempFile = null;
if (parentDir != null) {
for (int index = 0; index < MAX_INDEX; index++) {
tempFile = new File(parentDir, prefix + "_" + index + postfix);
if (!tempFile.exists()) {
if (tempFile.createNewFile())
return tempFile;
}
}
}
return null;
}
Write String to File
Write String content inside a specified file.
public static void writeToFile(String content, File outFile) {
try {
// Create file
FileWriter fstream = new FileWriter( outFile );
BufferedWriter out = new BufferedWriter(fstream);
out.write( content );
// Close the output stream
out.close();
} catch (Exception e) {
// Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
Read String from File, by Filesystem
Read Textual content of a file starting from file path, given on filesystem. The method raises exceptions
public static String tryReadFromFile(String filepath) throws Exception {
// leggo risorsa da stream
InputStream inStream = new FileInputStream(filepath);
byte[] content = new byte[inStream.available()];
inStream.read(content);
inStream.close();
// l'array di byte diventa stringa
return new String(content);
}
Lettura String da File, tramite Classpath
Read textual content of a file starting from file path, given on classpath. The method raises exceptions
public static String tryReadFromResource(String classpath)
throws Exception {
// leggo risorsa da stream
InputStream inStream = CLASSLOADER.getResourceAsStream(classpath);
byte[] content = new byte[inStream.available()];
inStream.read(content);
inStream.close();
// l'array di byte diventa stringa
return new String(content);
}
Lettura String da File, tramite URL
Read textual content from a resource referenced by an URL, given as parameter. The methos raises exceptions
public static String tryReadFromURL(String urlString) throws Exception {
// lettura risorsa
URL url = new URL(urlString);
InputStream inStream = url.openStream();
byte[] content = new byte[inStream.available()];
inStream.read(content);
inStream.close();
// l'array di byte diventa stringa
return new String(content);
}
.
.
|
|