Category Archives: Experience

Bugs and Tips found recently

1: Teensy as a keyboard does not work properly in GRUB.

Solution: break your long input into parts (<=3 chars) and add delays (50ms is enough) between them.

 

2: In Debian and Ubuntu, your may install some PHP PECL modules just by using

sudo apt-get install php5-pecl-http php5-propro php5-raphf

(PHP run as an apache mod)

Restart Apache, php -m does not show any new module installed.

Try add ini files(propro.ini File Content: extension=propro.so) to /etc/php5/mod-available and make link (15-propro.ini for example) at /etc/php5/apache/conf.d pointing to /etc/php5/mod-available/propro.ini

restart Apache again, php module still not loading.

The solution:

use php5enmod propro instead :)
3: Dell PowerEdge RAID Controller (PERC) H730 and SSD.
Unable to build raid for Samsung 850 EVO SSD in the Lifecycle Manager.

Solution: goto BIOS and find device management- raid controller then build your RAID there.

How to get a certification to sign PDFs

I’m trying to get a certification to sign my PDF files these days.

My Goal:

  1. It is a certification signed by a trusted CA in Adobe Acrobat (of course it can’t be self-signed)
  2. It is cheap

What I did:

Check the current list of Adobe Approved  Trusted CA (http://helpx.adobe.com/acrobat/kb/approved-trust-list1.html)

Check those CA’s website.

Many of those CA are used inside their company/organization only, Some “Widely known CA” like DigiCert, GlobalSign, Entrust cost a lot(200-800 USD/year) for the certification, and you maybe asked for purchasing a USB device for the cert, PLUS, some of them limit the number of files you signed.

Finally I found “CERTUM (Unizeto Technologies)” in Porland, they supply a certification for a low cost(~10USD/year)  https://en.sklep.unizeto.pl/data-safety/id-certificates/certyfikat-professional-id.html

Continue reading How to get a certification to sign PDFs

[Apache] Rewrite subdomain as subfolder

What You Want:

/path/to/www/root/
—————–/123/index.php ===> http://123.yourwebsite.com/
—————–/www/index.php ===> http://www.yourwebsite.com/
—————–/blog/index.php ===> http://blog.yourwebsite.com/
—————–/email/main/index.php ===> http://email.yourwebsite.com/main/

Set dns:

A (may be AAAA) * to your server’s IP address.

This is the rewrite code you should use:

RewriteEngine On
RewriteMap lowercase int:tolower
RewriteCond %{HTTP_HOST} ^(.*)\.yourwebsite\.com$
RewriteRule ^(.*)$     /path/to/www/root/${lowercase:%1}/$1 [L]

PS:

Options -Indexes

Will not working in this case. Since Apache can not find the subfolder if you hide them. All subdomains will return a 404 error.

isset() vs empty() vs is_null()

PHP has different functions which can be used to test the value of a variable. Three useful functions for this are isset()empty() and is_null(). All these function return a boolean value. If these functions are not used in correct way they can cause unexpected results.

isset() and empty() are often viewed as functions that are opposite, however this is not always true. In this post I will explain the differences between these functions.

 

isset()

From PHP manual – isset():

isset — Determine if a variable is set and is not NULL

In other words, it returns true only when the variable is not null.

empty()
From PHP Manual – empty():

empty — Determine whether a variable is empty

In other words, it will return true if the variable is an empty string, false, array(), NULL, “0?, 0, and an unset variable.

is_null()
From PHP Manual – is_null():

is_null — Finds whether a variable is NULL

In other words, it returns true only when the variable is null. is_null() is opposite of isset(), except for one difference that isset() can be applied to unknown variables, but is_null() only to declared variables.

The table below is an easy reference for what these functions will return for different values. The blank spaces means the function returns bool(false).
Value of variable ($var) isset($var) empty($var) is_null($var)
“” (an empty string) bool(true) bool(true)
” ” (space) bool(true)
FALSE bool(true) bool(true)
TRUE bool(true)
array() (an empty array) bool(true) bool(true)
NULL bool(true) bool(true)
“0″ (0 as a string) bool(true) bool(true)
0 (0 as an integer) bool(true) bool(true)
0.0 (0 as a float) bool(true) bool(true)
var $var; (a variable declared, but without a value) bool(true) bool(true)
NULL byte (“\ 0″) bool(true)
=======================================
Copy From http://techtalk.virendrachandak.com/php-isset-vs-empty-vs-is_null/  By Virendra on January 21, 2012