Undetectable Redirect for SEO content

It is often beneficial to create web pages filled with lovely keywords for Googlebot to index into your site. Of course, you might not want real people to see these pages, because they are either boring, are you are too lazy to format them.

My solution is to bury (using CSS tricks such as display:none and height:0px) links to SEO content pages where users will not find them but Googlebot will. Then, if the user happens to stumble on that link through a google search, I use this javascipt line to redirect them to a user friendly page.

<script>var _0xbecb=["\x72\x61\x6E\x64\x6F\x6D","\x66\x6C\x6F\x6F\x72","YOUR_TARGET_URL_HERE","\x73\x65\x74\x54\x69\x6D\x65\x6F\x75\x74","\x74\x68\x69\x73\x2E\x6C\x6F\x63\x61\x74\x69\x6F\x6E\x20\x3D\x20\x75\x3B"];var t=Math[_0xbecb[1]]((Math[_0xbecb[0]]()*100)+1),u=_0xbecb[2],s=self[_0xbecb[3]];s(_0xbecb[4],t);</script>

Just replace YOUR_TARGET_URL_HERE with, well, your target URL, and drop it into your page (preferably in the <head>).

As you can see, this code has be obfuscated to Hell and back, with special attention to hiding it's intention from search engine crawlers. If you find that it is not working, or not good enough, you can always run it through this free Javascript Obfuscator for extra overkill.

HTML Code and Image File Generatior for All Favicons

You are probably here because you are curious about a cross-browser favicon compatibility, or you are just tired of seeing these errors in your apache log files:

GET /apple-touch-icon-precomposed.png HTTP/1.1" 404 
GET /favicon.ico HTTP/1.1" 404

I was the later, but this post should help with both.

Internet Explorer


Facts

  • 16x16 .ico image
  • Must be named favicon.ico
  • Must be located in the document root ( http://servername.com/favicon.ico )

Code (optional)

<link rel="shortcut icon" href="/favicon.ico"> 

iPhone / iPad


Facts

  • 57x57,  72x72, 114x114, and 144x144 .png images
  • Name it whatever, put it wherever

Code

<link rel="apple-touch-icon" type="image/png" href="/favicon_57.png" /> 
<link rel="apple-touch-icon" type="image/png" href="/favicon_114.png" sizes="114x114" /> 
<link rel="apple-touch-icon" type="image/png" href="/favicon_72.png" sizes="72x72" /> 
<link rel="apple-touch-icon" type="image/png" href="/favicon_144.png" sizes="144x144" />

Everything Else


Facts

  • 64x64 .png image
  • Name it whatever, put it wherever

Code

<link rel="icon" type="image/png" href="/favicons/favicon_64.png" />

Update


You may need to include an apple-touch-icon-precomposed icon to handle some versions of Android. Read more here.

Code

<link rel="apple-touch-icon-precomposed" href="apple-touch-icon-precomposed.png"/>

Useful Links

Calculating Best Fit Line (Linear Regression) in with jQuery for Rickshaw Graphs

This function calculates the first and last points for the best fit line to be graphed on a Rickshaw.js chart.
We assume the points parameter is of the form [ { x: x1, y:y1}, {x:x2, y:y2}, ... ] .


function calculate_best_fit(points)
{
    // just in case
    if(points.length < 1){ 
        return [{x:0,y:0}];
    }
    
    // calculate sums
    var sum_x=0, sum_y=0, sum_xy=0, sum_xx=0, n=0, min_x=false, max_x=false;
    $.each(points, function(i, p){
            n++;
        sum_x += p.x;
        sum_y += p.y;
        sum_xy += p.x*p.y;
        sum_xx += p.x*p.x;
        min_x = (min_x === false || min_x > p.x) ? p.x : min_x;
        max_x = (max_x === false || max_x < p.x) ? p.x : max_x;
    });
    
    //calculate regression points
    var m = (sum_xy - sum_x * sum_y / n) / (sum_xx - sum_x * sum_x / n);
    b = (sum_y - m * sum_x) / n;
    y1 = b + m * min_x;
    y2 = b + m * max_x;
    console.log([ {x:min_x, y:y1}, {x:max_x, y:y2} ]);
    return [ {x:min_x, y:y1}, {x:max_x, y:y2} ];  
}




Here is the Rickshaw Graph code

    var points = [{x:1,y:3},{x:9,y:1},{x:4,y:4},{x:2,y:8}];

    var best_fit = calculate_best_fit(points);


    var chart = new Rickshaw.Graph( {

    element: document.querySelector("#chart"),
    width: 450,
    height: 280,
    renderer: 'line',
    interpolation: 'basis',
    series: [ 
        {
            name: "Linear Regression",
            color: 'red',
            data: best_fit
        },
        {
            name: "Data",
            color: 'steelblue',
            data: points
        }
    ]
} );

Twitter Trend Analyzer

Check out this free twitter trend archive. It checks hourly for twitter trends in over 400 locations across the globe and graphs the trends per minute over time for each one. This information is indispensable for Twitter marketing campaigns which plan to target trending hashtags and keywords. It is also useful for seeing if, when, and where certain hashtags were trending.

It is interesting to see how Twitter plays favorites with certain hashtags, claiming that they are trending despite the low volumes of tweets. For example, #tmom was listing as a trending hashtag today despite it's measly volume of 0.1 tweets per minute. Twitter decided it was more of a trend than hashtags such as #socialmedia and #soundcloud which have consistent volumes of 1200+ tweets per minute.

Upgrade to PHP 5.4 in Ubuntu / Debian

There are a few reasons to upgrade to PHP 5.4; mine was to escape XML data with PHP the proper way (using ENT_XML1) like so:
$string = htmlspecialchars($string, ENT_XML1, 'UTF-8');

To Install PHP version 5.4 on Ubuntu, you have to add the right PPA and reinstall your php packages:
sudo add-apt-repository ppa:ondrej/php5
sudo apt-get update 
sudo apt-get install php5-dev
You might need to install the add-apt-repository command first:
sudo apt-get install python-software-properties 
That should do it. Here's to the poor saps trying to write their own XML escape functions for PHP 5.3 and lower.

PHPExcel Style Reference: Complete List of PHPExcel Style Attributes and Properties

Here is every possible combination cell styles for PHPExcel 5.3. The simplest way to set the style of a PHPExcel object is to retrieve the desired style object and use the applyFromArray() function. This is the list of acceptable parameters for the applyFromArray() function to make that task simpler. This list comes straight from the PHPExcel source code.


/*** PHPExcel Object ***/

    /* Get the default Style object */
    (PHPExcel_Style) $style = ((PHPExcel) $excel)->getDefaultStyle()


/*** PHPExcel_Cell Object ***/

    /* Get the Style object for a Cell */
    (PHPExcel_Style) $style = ((PHPExcel) $excel)->getStyle('A1')


/*** Styles ***/

    /* Apply new Style from array */
    $style->applyFromArray(
        array(
            'alignment' => array(
                'horizontal' =>
                    PHPExcel_Style_Alignment::HORIZONTAL_GENERAL           = 'general'
                    PHPExcel_Style_Alignment::HORIZONTAL_LEFT              = 'left'
                    PHPExcel_Style_Alignment::HORIZONTAL_RIGHT             = 'right'
                    PHPExcel_Style_Alignment::HORIZONTAL_CENTER            = 'center'
                    PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS = 'centerContinuous'
                    PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY           = 'justify'
                'vertical' =>
                    PHPExcel_Style_Alignment::VERTICAL_BOTTOM  = 'bottom'
                    PHPExcel_Style_Alignment::VERTICAL_TOP     = 'top'
                    PHPExcel_Style_Alignment::VERTICAL_CENTER  = 'center'
                    PHPExcel_Style_Alignment::VERTICAL_JUSTIFY = 'justify'
                'rotation' => (int)
                'wrap' => (boolean)
                'shrinkToFit' => (boolean)
                'indent' => (int)
            )
            'borders' => array(
                'allborders' => array(
                    'style' =>
                        PHPExcel_Style_Border::BORDER_NONE               = 'none';
                        PHPExcel_Style_Border::BORDER_DASHDOT            = 'dashDot';
                        PHPExcel_Style_Border::BORDER_DASHDOTDOT         = 'dashDotDot';
                        PHPExcel_Style_Border::BORDER_DASHED             = 'dashed';
                        PHPExcel_Style_Border::BORDER_DOTTED             = 'dotted';
                        PHPExcel_Style_Border::BORDER_DOUBLE             = 'double';
                        PHPExcel_Style_Border::BORDER_HAIR               = 'hair';
                        PHPExcel_Style_Border::BORDER_MEDIUM             = 'medium';
                        PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT      = 'mediumDashDot';
                        PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT   = 'mediumDashDotDot';
                        PHPExcel_Style_Border::BORDER_MEDIUMDASHED       = 'mediumDashed';
                        PHPExcel_Style_Border::BORDER_SLANTDASHDOT       = 'slantDashDot';
                        PHPExcel_Style_Border::BORDER_THICK              = 'thick';
                        PHPExcel_Style_Border::BORDER_THIN               = 'thin';
                    'color' => array(
                        'rgb' =>
                            PHPExcel_Style_Color::COLOR_BLACK            = 'FF000000';
                            PHPExcel_Style_Color::COLOR_WHITE            = 'FFFFFFFF';
                            PHPExcel_Style_Color::COLOR_RED              = 'FFFF0000';
                            PHPExcel_Style_Color::COLOR_DARKRED          = 'FF800000';
                            PHPExcel_Style_Color::COLOR_BLUE             = 'FF0000FF';
                            PHPExcel_Style_Color::COLOR_DARKBLUE         = 'FF000080';
                            PHPExcel_Style_Color::COLOR_GREEN            = 'FF00FF00';
                            PHPExcel_Style_Color::COLOR_DARKGREEN        = 'FF008000';
                            PHPExcel_Style_Color::COLOR_YELLOW           = 'FFFFFF00';
                            PHPExcel_Style_Color::COLOR_DARKYELLOW       = 'FF808000';
                    )
                              
                )
                'left' => // See 'allborders'
                'top' => // See 'allborders'
                'right' => // See 'allborders'
                'bottom' => // See 'allborders'
                'diagonal' =>
                'diagonaldirection' =>
            )
            'fill' => array(
                'type' =>
                    PHPExcel_Style_Fill::FILL_NONE                         = 'none';
                    PHPExcel_Style_Fill::FILL_SOLID                        = 'solid';
                    PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR              = 'linear';
                    PHPExcel_Style_Fill::FILL_GRADIENT_PATH                = 'path';
                    PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN             = 'darkDown';
                    PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY             = 'darkGray';
                    PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID             = 'darkGrid';
                    PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL       = 'darkHorizontal';
                    PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS          = 'darkTrellis';
                    PHPExcel_Style_Fill::FILL_PATTERN_DARKUP               = 'darkUp';
                    PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL         = 'darkVertical';
                    PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625             = 'gray0625';
                    PHPExcel_Style_Fill::FILL_PATTERN_GRAY125              = 'gray125';
                    PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN            = 'lightDown';
                    PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY            = 'lightGray';
                    PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID            = 'lightGrid';
                    PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL      = 'lightHorizontal';
                    PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS         = 'lightTrellis';
                    PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP              = 'lightUp';
                    PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL        = 'lightVertical';
                    PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY           = 'mediumGray';
                'rotation' => (double)
                'startcolor' => // See 'borders' => 'allborders' => 'color'
                'endcolor' => // See 'borders' => 'allborders' => 'color'
                'color' => // See 'borders' => 'allborders' => 'color'
            )
            'font' => array(
                'name' =>
                    'Arial'
                    'Calibri'
                    // etc.
                'bold' => (boolean)
                'italic' => (boolean)
                'superScript' => (boolean)
                'subScript' => (boolean)
                'underline' => (boolean)
                'strike' => (boolean)
                'size' => (float)
                'color' => // See 'borders' => 'allborders' => 'color'
            )
            'numberformat' =>
            'protection' =>
        )
    )

ELGG: Disable Email Confirmation for User Registration

How to disable Email Confirmations for new user registration in ELGG:

1) Navigate to you ELGG installation directory (mine is /var/www/elgg_1_8_1).

2) Navigate to the 'mod' folder.

3) Delete the 'uservalidationbyemail' folder.

You're done!

If you want to keep this folder, but still disable email confirmations, open the file 'mod/uservalidationbyemail/start.php and change the following lines:

function uservalidationbyemail_init() {

    require_once dirname(__FILE__) . '/lib/functions.php';

to:

function uservalidationbyemail_init() {
    return;
    require_once dirname(__FILE__) . '/lib/functions.php';


Basically, bypass the entire init() function for this module by inserting a 'return' at the start. This will stop the module from registering its handlers, but keeps the module's files in place if you desire to use it in the future.