Signing a Windows Programs
I wrote a program, but lots of virus program giving alerts and i learn i have to sign my programs with "code signing". There is lots alternative for code signing, i choice Verisign. There is some steps for signing.
Getting Signature
- Buy a code signin certificate. Whole list > (You can also create test certificates using makecert.exe.)
- User Certificate Manager (certmgr.exe) The Certificate Manager is also used to import and export certificates.
- You get some files from CA (Verisign etc.) Save as abc.cer and abc.spc, after we will conver that files to .pfx
- command prompt ;
cert2spc xyz.cer xyz.spc
pvk2pfx -pvk abc.pvk -pi pvkpassword -spc abc.spc -pfx pfxfilename -po pfxpassword -f - Finally, import your file to certificate store.
- After we can sign our programs.
Signing program
- You can use wizard but it doesnt work in Win8
Command prompt: signtool signwizard - Another option;
signtool sign /yourfile.exe - Dont forget to add timestamp for sign
signtool timestamp -t timestamp.verisign.com/scripts/
timstamp.dll yourfile. exe
Here is more details;
- www.kinook.com/blog/?p=10
- www.digicert.com/code-signing/signcode-signtool-command-line.htm
- www.sslshopper.com/what-is-code-signing.html
- blog.didierstevens.com/2008/12/31/howto-add-a-digital-signature-to-executables/
Sort VARCHAR as INT in MySQL
Sometimes we can user VARCHAR for integer values. But when we need sort them, we have got big problem. Because VARCHAR's are string and it is sorting like a string.
Example:
1a 2a 3a 10b 20b 30b 15c 25c 35c (VARCHAR)
1a 10b 15c 2a 20b 25c 3a 30b 35c (Sorted)
We need
1a 2a 3a 10b 15c 20b 25c 30b 35c (Sorted integer)
We can do it with mysql CAST
SELECT vNumber FROM table ORDER BY CAST(`vNumber` AS SIGNED)
Reverse order
SELECT vNumber FROM table ORDER BY CAST(`vNumber` AS SIGNED) DESC
Other possible conversion types you may need are:
- BINARY[(N)]
- CHAR[(N)]
- DATE
- DATETIME
- DECIMAL[(M[,D])]
- SIGNED [INTEGER]
- TIME
- UNSIGNED [INTEGER]
You can find more about CAST -> MySQL docs here.
Recursive Category Listing
Webmasters allways use category trees, i wrote a function about creating category trees with using recursive function.
<?php header('Content-Type: text/html; charset=UTF-8'); include($_SERVER['DOCUMENT_ROOT']."/mysql.inc.php"); function categories($firstCategory,$node) { $kQ = mysql_query("SELECT * FROM categories WHERE category= ".$firstCategory); if(mysql_num_rows($kQ) > 0) { echo(str_repeat("\t",$node+1)."<ul>\n"); $node++; while($k = mysql_fetch_array($kQ)) { //str_repeat is for "view source" format, we set TAB character for readable HTML echo(str_repeat("\t",$node)."<li>".($node+1)." ".$k["name"]."</li>\n"); // Recursive, call function it self categories($k["id"], $node); } echo(str_repeat("\t",$node)."</ul>\n"); } } categories(0,-1); ?>
Output :
- Food
- Fruits
- Apple
- Banana
- Vegetables
- Tomatoes
- Aborgin
- Fruits
- Drinks
- Soft
- Fruit Juice
- Apple Juice
- Strawberry Juice
- Milk
- Fruit Juice
- Soft
Tracking Advertisement Campaigns
We can track easily with using google analytics for all advertising campaings. We use utm_source, utm_medium, utm_campaing, utm_content and utm_term for tracking..
utm_medium is using for particular marketing; email, affiliate, paid search etc.
utm_source is our basic source which is we used to advertising; google adwords, facebook ads etc.
utm_campaing is your advertising campaing name, you will see this name in google analytics; %20 discount, Free shipping etc.
And URL example for following
- utm_medium=banner-adv
- utm_source=adwords
- utm_campaign=free-membership
- utm_content=300-250-fire
www.webmastersucks.com/?utm_medium=banner-adv&utm_source=adwords&utm_campaign=free-membership&utm_content=300-250-fire
From now on we can track our campaing in Google Analytics easily..
Optimize PHP Codes Tricks
- Use echo, not print,
- Unset your variable when your job is over that variable, especially for large arrays,
- Don't use require_once,
- Use full paths for includes,
- str_replace is faster than ereg_replace but strtr is fastest.. If you can, use strtr,
- Close your database connections when you are finish your process,
- Using $table['id'] is faster than $table[id],
- Use caching systems (memcache etc.)
For more about php optimizing >
Break Categories to Columns in WordPress
Normally the category list is single column. But you can use this trick to split two columns.
Firstly, find
<?php wp_list_categories(); ?>
Then replace this code like here :
<?php $cats = explode("<br />",wp_list_categories('title_li=&echo=0&depth=1&style=none')); $cat_n = count($cats) - 1; for ($i=0;$i<$cat_n;$i++): if ($i<$cat_n/2): $cat_left = $cat_left.'<li>'.$cats[$i].'</li>'; elseif ($i>=$cat_n/2): $cat_right = $cat_right.'<li>'.$cats[$i].'</li>'; endif; endfor; ?> <ul class="left"> <?php echo $cat_left;?> </ul> <ul class="right"> <?php echo $cat_right;?> </ul>
After changing this you can stylize your columns with css file (style.css)
.right {float:left; px;} .left {float:left; px;}
Twitter Advertisements
There is some web tools for twitter advertisements.
Here is the list of Twitter Ads :
Resizing All Images in Directory
I need a script for resize all images in one directory. I have create thumbnails for a site. I have not so much time write these code. I found two different code and mixed them. I love PHP, it is very easy to solve problem with little scripts. If you resize in same directory it will be resize resized images. If you need in same directory, just resized for temp directory and move it to your real one.
- Resizing image with Php by Simon Jarvis
- Directory Listing by Spoono
<? /* * Class: SimpleImage, Author: Simon Jarvis, Copyright: 2006 Simon Jarvis, Date: 08/11/06 * Link: www.white-hat-web-design.co.uk/articles/php-image-resizing.php * See the GNU General Public License for more details: www.gnu.org/licenses/gpl.html */ class SimpleImage { var $image; var $image_type; function load($filename) { $image_info = getimagesize($filename); $this->image_type = $image_info[2]; if( $this->image_type == IMAGETYPE_JPEG ) { $this->image = imagecreatefromjpeg($filename); } elseif( $this->image_type == IMAGETYPE_GIF ) { $this->image = imagecreatefromgif($filename); } elseif( $this->image_type == IMAGETYPE_PNG ) { $this->image = imagecreatefrompng($filename); } } function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) { if( $image_type == IMAGETYPE_JPEG ) { imagejpeg($this->image,$filename,$compression); } elseif( $image_type == IMAGETYPE_GIF ) { imagegif($this->image,$filename); } elseif( $image_type == IMAGETYPE_PNG ) { imagepng($this->image,$filename); } if( $permissions != null) { chmod($filename,$permissions); } } function output($image_type=IMAGETYPE_JPEG) { if( $image_type == IMAGETYPE_JPEG ) { imagejpeg($this->image); } elseif( $image_type == IMAGETYPE_GIF ) { imagegif($this->image); } elseif( $image_type == IMAGETYPE_PNG ) { imagepng($this->image); } } function getWidth() { return imagesx($this->image); } function getHeight() { return imagesy($this->image); } function resizeToHeight($height) { $ratio = $height / $this->getHeight(); $width = $this->getWidth() * $ratio; $this->resize($width,$height); } function resizeToWidth($width) { $ratio = $width / $this->getWidth(); $height = $this->getheight() * $ratio; $this->resize($width,$height); } function scale($scale) { $width = $this->getWidth() * $scale/100; $height = $this->getheight() * $scale/100; $this->resize($width,$height); } function resize($width,$height) { $new_image = imagecreatetruecolor($width, $height); imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight()); $this->image = $new_image; } } // End of SimpleImage class /* Directory Listing Source : www.spoono.com/php/tutorials/tutorial.php?id=10 */ // Define the path as relative $path = "/home/site/public_html/images/"; // Using the opendir function $dir_handle = @opendir($path) or die("ERROR: Cannot open <b>$path</b>"); echo("Directory Listing of $path<br/>"); //running the while loop while ($file = readdir($dir_handle)) { if($file != "." && $file != "..") { $image = new SimpleImage(); $image->load("images/".$file); $image->resize(80,60); $image->save("images2/mini_".$file); echo("&bull; $file <br>"); } } //closing the directory closedir($dir_handle); ?>
Google Announce Chromium OS Project
Today Google released Chromium OS, the open source project behind Google Chrome OS. Google Chrome OS is an operating system that is intended for people who spend most of their time on the web. It aims to provide a computing experience that is fast, simple and secure. The Chromium OS project as you'll see it today is comprised of the code that has been developed thus far, our early experiments with the user interface, and detailed design docs for many parts that are under active development.
Fore more information and announcement:
chrome.blogspot.com/2009/11/announcing-chromium-os-open-source.html
googletesting.blogspot.com/2009/11/testing-chrome-os.html