TinyMCE integration with phpBB3

Modification Name: TinyMCE integration
Author: Garak
Modification Description:: Integrate TinyMCE WYSIWYG editor in the posting textarea.
Modification Version:: 0.4.3
Requirements: TinyMCE 3.2.0.2 or above
Screenshots: example screenshot (sorry it’s in italian)
New!: since 0.2 version, font size is working properly

Instructions

1 - download TinyMCE (Note: this MOD was tested with version 3.2.0.2, any later 3.2.X versionshould work). Optional: download language pack for a localized version (in this case, please notice comments inside config file at step 5)

2 - unzip tiny_mce directory (Note: it’s NOT the main directory) under styles/prosilver/template/
So, you should have a directory named styles/prosilver/template/tiny_mce (Note: this modcould work with other themes also, but it’s untested)

3 - open file styles/prosilver/template/tiny_mce/plugins/bbcode/editor_plugin.js and replace its content with the following
Read the rest of this entry »

Double-Array Trie

Definition. For a transition from state s to t which takes character c as the input, the condition maintained in the double-array trie is:

  • check[base[s] + c] = s
  • base[s] + c = t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Procedure Relocate(s : state; b : base_index) 
//Move base for state s to a new place beginning at b  
begin 
	foreach input character c for the state s 
	//i.e. foreach c such that check[base[s] + c]] = s 
	begin 
		check[b + c] := s; //mark owner 
		base[b + c] := base[base[s] + c]; //copy data 
 
		//the node base[s] + c is to be moved to b + c; 
		//Hence, for any i for which check[i] = base[s] + c, 
		//update check[i] to b + c 
		foreach input character d for the node base[s] + c 
		begin 
			check[base[base[s] + c] + d] := b + c 
		end; 
		check[base[s] + c] := none //free the cell
	end; 
	base[s] := b 
end

Find The Shortest Path: Dijkstra

Dijkstra is one of the most classic algorithm, which is used to find the shortest path from one vertex to other vertexes in graph. The algorithm use greedy algorithm to find the next shortest path gradually, until all the paths are found.

The complex of the algorithm is O^2, the following is the sample code of Dijkstra: Read the rest of this entry »

tomcat+hibernate: could not find datasource error!

tomcat+hibernate: could not find datasource” is a very common error when you config hibernate using tomcat datasource. After survey a lot of material, here I give a right configuration method. I hope it can help you!

First, config tomcat data source. Find the file Tomcat 5.5\conf\Context.xml and add the following lines to it:

<Resource
name=”jdbc/DB
type=”javax.sql.DataSource”
maxActive=”4″
maxIdle=”2″
username=”root”
maxWait=”5000″
driverClassName=”com.mysql.jdbc.Driver”
password=”pass”
url=”jdbc:mysql://127.0.0.1:3306/dbname”/>
Then, config hibernate. Write the hibernate config file like this:
<!– datasource connection properties –>
<property name=”connection.datasource”>java:comp/env/jdbc/DB</property>
<!– dialect for MySQL –>
<property name=”dialect”>
org.hibernate.dialect.MySQLDialect
</property>
Attention: Please take care of the red part of the code!

Attribute Description of Action in Struts

attribute

The attribute specifies the name of the ActionForm that is mapped to a given scope. If you do not specify an attribute, the name attribute becomes the value of the attribute. Thus, if the attribute is not specified, the attribute defaults to the name of the ActionForm.

className

The className attribute is used to specify custom config object. We will cover these in Chapter 10 in more detail. For now, you can replace any config object with a custom config object. The custom config object can have additional properties.

include

You can use the include attribute to specify a JSP that will handle this request. The JSP is the only handler of this request. Using this should be the exception, not the norm. This attribute is mutually exclusive with the forward attribute and the type attribute, meaning that only one of the attributes can be set.

input

The input attribute is used to specify the input View for an action. The input attribute usually specifies a JSP page that has an HTML form that submits to this action. If there are any problems with form validation, then control of the application will forward back to this input View. This attribute is optional, but if it’s not included, an error occurs when Struts attempts to display validation errors. Read the rest of this entry »

Transform Examples in CSS3

CSS3 makes it possible to do things like rotate, scale, and skew the objects in your pages without resorting to images, Flash, or JavaScript. All of these effects are called “transforms.” They’re supported in Firefox, Safari, Chrome, and Opera 10.5.

You apply a transform using the transform property, naturally (though for now you’ll need to use the browser-specific equivalents: -moz-transform, -webkit-transform, and -o-transform). You can also use the transform-origin property to specify the point of origin from which the transform takes place, such as the center or top right corner of the object.

In the transform property, you specify the type of transform (called “transform functions”), and then in parentheses write the measurements needed for that particular transform. For instance, a value of translate(10px, 20px) would move the element 10 pixels to the right and 20 pixels down from its original location in the flow. Other supported transform functions are scale, rotate, and skew.

Read the rest of this entry »

@, # in PHP

  1. @ is used before the function, so that does not display error messages.
  2. function foo($n)
    {
    $result = 1/$n;
    return $result;
    }
    echo @foo(0); // Errors produced in foo() will be ignored.
    echo “end”; // output end

  3. # is the comment symbol. With the same as / /, # is one-line comment symbol (multi-line comment symbol is / * * /).

Points about Programing

  1. The only “best practice” you should be using all the time is “Use Your Brain”.
  2. Programmers who don’t code in their spare time for fun will never become as good as those that do.
  3. Most comments in code are in fact a pernicious form of code duplication.
  4. XML is highly overrated
  5. Not all programmers are created equal
  6. ”Googling it” is okay!
  7. If you only know one language, no matter how well you know it, you’re not a great programmer.
  8. Your job is to put yourself out of work.
  9. Design patterns are hurting good design more than they’re helping it.
  10. Unit Testing won’t help you write good code
Page 1 of 6123456