Webmaster Sucks Here I share stuff I used to suck at as a novice webmaster..

24Oct/13Off

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

  1. Buy a code signin certificate. Whole list > (You can also create test certificates using makecert.exe.)
  2. User Certificate Manager (certmgr.exe) The Certificate Manager is also used to import and export certificates.
  3. You get some files from CA (Verisign etc.) Save as abc.cer and abc.spc, after we will conver that files to .pfx
  4. command prompt ;
    cert2spc xyz.cer xyz.spc
    pvk2pfx -pvk abc.pvk -pi pvkpassword -spc abc.spc -pfx pfxfilename -po pfxpassword -f
  5. Finally, import your file to certificate store.
  6. After we can sign our programs.

Signing program

  1. You can use wizard but it doesnt work in Win8
    Command prompt: signtool signwizard
  2. Another option;
    signtool sign /yourfile.exe
  3. 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/
Tagged as: certmgr, code signing, exe signing, program signing, signtool, timestamp, verisign, verisign timestamp No Comments
13Jun/11Off

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.
Tagged as: mysql cast, sort integer, sort mysql, sort varchar, sort varchar integer 3 Comments
7Jan/11Off

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
  • Drinks
    • Soft
      • Fruit Juice
        • Apple Juice
        • Strawberry Juice
      • Milk
Tagged as: categories php, category list, recursive function, recursive functions php, recursive php, str_repeat, str_repeate php, WordPress 2 Comments
6Jan/11Off

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..

Tagged as: campaign tagging, campaign tracking, campaing track, google analytics, google analytics track, marketing campaign tracking, msn, paid-search, track url, tracking campaign, utm_campaign, utm_content, utm_medium, utm_source, utm_term, yahoo No Comments
6Dec/10Off

Optimize PHP Codes Tricks

spacer
  1. Use echo, not print,
  2. Unset your variable when your job is over that variable, especially for large arrays,
  3. Don't use require_once,
  4. Use full paths for includes,
  5. str_replace is faster than ereg_replace but strtr is fastest.. If you can, use strtr,
  6. Close your database connections when you are finish your process,
  7. Using $table['id'] is faster than $table[id],
  8. Use caching systems (memcache etc.)

For more about php optimizing >

Tagged as: code optimize, optimize php code, optimize tricks, optimizing php, php code optimize, php optimize, php optimizing, php tricks 2 Comments
3Dec/10Off

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;}
Tagged as: breaking categories in wordpress, categories wordpress, wordpress categori split, wordpress categories, wordpress category No Comments
11Oct/10Off

Twitter Advertisements

There is some web tools for twitter advertisements.

Here is the list of Twitter Ads :

  • Twittertise - Advertise on Twitter
  • Twitterad - Monetize your twitter profile
  • TwitterCard - Place a 125x125 TwitterCard on your Blog or as an Advertisement
  • Twitterribbons - Twitter Ribbon Ad generator
  • TwitterKnowHow - Twitter ribbon ad generator
  • BeaMagpie - Be a Magpie is an ad network for Twitter
  • TweetTornado - Fully automated advertising software
  • FeaturedUsers - FeaturedUsers is a Twitter application ad network
  • Tagged as: beamagpie, featuredusers, tweettornado, twitter, twitter ads, twitter advertisement, twitterad, twittercard, twitterknowhow, twitterribbons, twittertise No Comments
    11May/10Off

    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.

    1. Resizing image with Php by Simon Jarvis
    2. 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("• $file <br>");
       }
    }
    
    //closing the directory
    closedir($dir_handle);
    ?>
    
    
    Tagged as: directory list, directory list php, resize image, resize image directory, resize image php, resizing image 9 Comments
    20Nov/09Off

    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

    Tagged as: chrome os, chrome os project, chromium, chromium os, chromium os project, Google, google chrome, google chrome os, google operating system, google os No Comments
    17Nov/09Off

    Google Create New Programming Language : GO

    Google Engineers create new programming language "Go". In first look it is look like C++ or Java. We will see, how it will be.

    More details :
    www.golang.me/google-launches-its-own-programming-language-go/

    Tagged as: go lang, golang, golang.me, google programming, the go programming language 1 Comment
       Older Entries »

    Webmaster Sucks

    Social

    spacer

    spacer
    spacer

    Categories

    Recent comments

    Tags

    blogger chura clean br virus date calculation download download avast download avast free download avast free edition Google google analytics
    Related searches:
    google function twitter directory signing
    gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.