Articles Tagged 'trick'


Very short trick: stop NSTimer

The use of timers ( NSTimer ) to develop applications for Apple iPhone is very frequent, not only in making games. One of the problems with which one can collide is the asynchronicity of the timer, which can lead, during the arrest of one or more timers, the crash of our application. , si invoca la invalidate che, appunto, arresta il timer. When you want to stop one or more timers, where repeats is set to YES , it invokes the invalidate who, precisely, the timer stops.

Continued ...

Very short snippet: PHP slug

Who develops to WordPress definitely knows the word slug , usually used to indicate the text strings that do not contain spaces or other "strange" characters. In practice a friendly URL string, which can be used within a URL.

Continued ...

Very short trick: Conditional CSS and optimization

The use of conditions within the browser is often used to decide which style sheet to load depending on the type of browser. For example we can use this code to load a particular style sheet when the browser is Internet Explorer 6:

Continued ...

Very short trick: pages and pages parents daughters to WordPress

Alternately to the post in WordPress pages that are available, although similar, have some important differences with the "Post" (articles) real. In praticolare a page can have sub pages ("children"), similar to what happens with the categories. Here are some useful scripts to extricate their management and handling:

Continued ...

Very short trick: adjust the dates by MySQL

. Sometimes you find it impossible to change the time setting up a Web Server or MySQL to work on a table where a field TIMESTAMP is set to ON UPDATE CURRENT_TIMESTAMP . So it becomes necessary, in the face of a select, adjust the time retrieved with the correct time zone. For example, if our server is located in Los Angeles, with a time zone 9 hours back, simply use:

1
2
campo_timestamp , INTERVAL 9 HOUR ) AS `local_timestamp` SELECT DATE_ADD (campo_timestamp, INTERVAL HOUR 9) `AS` local_timestamp
FROM mytable

è la stessa data 9 ore avanti. The field campo_timestamp contains the actual date of the server and the alias local_timestamp is the same on 9 hours ahead.

Continued ...

Very short trick: disable the resizing of a textarea on Safari

In any browser developed starting from the rendering engine WebKit (by appointment as Safari or Google Chrome ), the fields textarea show, bottom right, the characteristic feature of resizing. If this peculiarity may prove very useful in some cases, in others it becomes a nuisance element.

Continued ...

Very short trick: take random elements from an array in PHP

The function shuffle() PHP "mixes" literally the elements of an array:

1
2
3
4
array ( "ele1" , "ele2" , "ele3" , "ele4" ) ; $ A = array ("ele1", "ele2", "ele3", "ele4");
$a ) ; print_r ($ a);
$a ) ; shuffle ($ a);
$a ) ; print_r ($ a);

Continued ...

Very short trick: ADDED_TO_STAGE

per capire quando il nostro MovieClip è disegnato effettivamente sulla stage: As we have seen several times in the constructor of a class that extends MovieClip may be necessary to add the event ADDED_TO_STAGE to understand when our MovieClip is actually drawn on the Stage:

Continued ...

Very short trick: duplicate or clone one or more rows in MySQL

To duplicate the contents of a table full of itself, just use:

1
* FROM MYTABLE INSERT INTO SELECT * FROM MyTable MYTABLE

You can also use the Claus WHERE if necessary:

1
* FROM MYTABLE WHERE a = b INSERT INTO SELECT * FROM MyTable WHERE MYTABLE a = b

If the table has any index or unique key, which would cause an error, you can filter the fields to be duplicated:

1
field1 , field2 , ... ) SELECT field1 , field2 , ... FROM MYTABLE INSERT INTO MYTABLE (field1, field2, ...) SELECT field1, field2, ... FROM MyTable

Even you can duplicate a record and change a value, such as dual field and add 1:

1
field1 , field2 , ... ) SELECT ( field1 + 1 ) , field2 , ... FROM MYTABLE INSERT INTO MYTABLE (field1, field2, ...) SELECT (field1 + 1), field2, ... FROM MyTable

Continued ...

Very short trick: addEventListener () AS3, a handler more events

In Actionscript 3.0 you must use addEventListener() to intercept any event:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/ **
* Given a MovieClip mc, you set events and handlers
* /
( MouseEvent . CLICK , on_click ) ; mc. addEventListener ( MouseEvent . CLICK, on_click);
( MouseEvent . ROLL_OVER , on_roll_over ) ; mc. addEventListener ( MouseEvent . ROLL_OVER, on_roll_over);
( MouseEvent . ROLL_OUT , on_roll_out ) ; mc. addEventListener ( MouseEvent . ROLL_OUT, on_roll_out);
/ **
* Functions hander for the above events
* /
e : MouseEvent ) : void { on_click function (e: MouseEvent ): void {
/ / Click
}
e : MouseEvent ) : void { on_roll_over function (e: MouseEvent ): void {
/ / Roll over
}
e : MouseEvent ) : void { on_roll_out function (e: MouseEvent ): void {
/ / Roll-out
}

Continued ...



Stop SOPA