Dec 232011
 

Reading from stdin is not something familiar to many php coders, so here are a few ways to read in the puzzle you are given from stdin using the PHP CLI.

$s=fgets(STDIN);

Reads in a complete line of input as a string, complete with end of line character.

$c=fgetc(STDIN);

Reads in a single character.

Also worth looking at are fscanf(), fgetcsv(), fread()

To test your scripts you can use this command from a linux shell (other operating systems may differ)

php your_script.php < test.txt

Where test.txt is a plain text file containing your sample input.

If you want to join codegolf.com's challenages via PHP language, you need to know how to read from stdin via PHP CLI.

codegolf.com forum

Dec 232011
 

What is it?

IE-CSS3 is a script to provide Internet Explorer support for some new styles available in the upcoming CSS3 standard.
How it works

If you’re viewing this page in Internet Explorer, some of the elements have been rebuilt by the script in Vector Markup Language (VML), an IE-specific vector drawing language. VML supports things that are missing from IE’s CSS implementation like rounded corners and blur effects.
How to use it

Just add CSS styles as you normally would, but include one new line:

.box {
-moz-border-radius: 15px; /* Firefox */
-webkit-border-radius: 15px; /* Safari and Chrome */
border-radius: 15px; /* Opera 10.5+, future browsers, and now also Internet Explorer 6+ using IE-CSS3 */

-moz-box-shadow: 10px 10px 20px #000; /* Firefox */
-webkit-box-shadow: 10px 10px 20px #000; /* Safari and Chrome */
box-shadow: 10px 10px 20px #000; /* Opera 10.5+, future browsers and IE6+ using IE-CSS3 */

behavior: url(ie-css3.htc); /* This lets IE know to call the script on all elements which get the ‘box’ class */
}

Issues and Workarounds

You would expect URLs in behavior: url(…) to be relative to the current directory as they are in a background-image: url(…) style for example, but instead Microsoft decided to ignore standards here and make them relative to the docroot instead. So behavior: url(ie-css3.htc) should work if ie-css3.htc is in the root directory of the site.

You will probably run into issues with z-index, especially if embedding one IE-CSS3 enabled element inside of another. There are two simple workarounds:

Set the z-index of the IE-CSS3 element to a number larger than its surrounding elements.
Make sure the IE-CSS3 element is positioned, such as with position: relative or position: absolute

Sometimes an IE-CSS3 element will show up at a slightly different position than the original, untouched element. There could be a few reasons for this:

You have broken tags somewhere in your markup, probably above the IE-CSS3 element.
You are experiencing misc IE6 and IE7 bugs. Try adding the styles zoom: 1 and/or position: relative to the IE-CSS3 element and its immediate parent. You could also try removing any margins on the IE-CSS3 element and/or its parent, use padding instead.

Styles and their status
Style What works What doesn’t work
border-radius

Setting a radius for all four corners
Element borders

Setting a radius for individual corners separately

box-shadow

Blur size
Offset

Any color other than #000

text-shadow

Blur size
Offset
Color

The shadow looks a little bit different than it does in FF/Safari/Chrome, I’m not sure why

Catch here.

Dec 142011
 
$sudo zypper install fcitx fcitx-qt4 fcitx-devel fcitx-config-kde4
$sudo vim /etc/sysconfig/language

change :
INPUT_METHOD="fcitx"

Then,

export XMODIFIERS="@im=fcitx"
export GTK_IM_MODULE=fcitx
#export QT_IM_SWITCHER=imsw-multi #I do not know more about this line
export QT_IM_MODULE=fcitx

Reboot.

Dec 132011
 

I can not believe that mod_rewrite is not enabled by default on OpenSuse 12.1

First,

$sudo vim /etc/sysconfig/apache2

find the following line, it must look like:

APACHE_MODULES="suexec access actions alias auth auth_dbm autoindex cgi dir env expires 
include log_config mime negotiation setenvif userdir ssl php5"

Add “rewrite” between “”.

Then,

$sudo /etc/init.d/apache2 restart

Now it works.