Category Archives: Uncategorized

How to remove extra Keyboard from Windows 10 – Language list

To fix this issue, delete the Preload registry folder and restart (or sign out) the computer:

HKEY_USERS.DEFAULT\Keyboard Layout\Preload

This folder seems to be some legacy remnant that contains non-user-specified keyboard layouts to be added to the list of languages when the user signs in. While the fix itself works through restarts, there’s a few things that seem to bring back this folder

To automate the procedure create a txt file and paste the contents below.

Windows Registry Editor Version 5.00

[-HKEY_USERS\.DEFAULT\Keyboard Layout\Preload]

You can then save the file with .reg extension and run it if registry folder comes back.  You need to logout or restart for changes to take effect.

Tip: From notepad use quotes like to “RemoveLang.reg” to save with new file extension.

Single page application SEO Optimizations

Client side rendered sites as is are not fully compatible with SEO standards before JS framework burst of technologies came out.  In 2009 there was a AJAX crawling scheme that google provided to developers. As cited here there no support and is currently deprecated.

Here is the deal. Modern JS Frameworks such as React, Angular, Ember, Vue, Aurelia have mixed support on crawling techniques. Some very promising frameworks are losing ground in popularity caused on lack of support on all aspects of web content delivery. Promising web developing heaven is not as easy as it looks in single hello world demonstration. Markets depended in web marketing are bound to server side scripting languages.

There are some solutions for web crawlers to be able to render and get information from you single applications but most of them require extra work.

A valuable  link on crawling settings “Robots meta tag and X-Robots-Tag HTTP header specifications

1 solution

Use a pre-render and serve html content of your pages with your own service. Note that not all js frameworks provide this functionality. Angular and Angular2 are the only fully supported pre-rendering engines.
You could actually use a robust caching service by rendering all your pages with a server-side js framework like PhantomJS and storing the html output to serve when requested to bots. The actual caveats here are that the output is not guaranteed to be same as the browser results. Also you add an overhead of refreshing the static content to the deployment procedure.

2nd Solution

Use Prerender.io, BromBone, Snapsearch hosted services and then you can easily redirect your pages accordingly to the service url when spotting that there is a crawler that is indexing your page.

3rd solution

Do nothing. It’s kinda vague to say that google now crawls SPA websites.  There was a special tag providing the context that this page uses # url redirection.

Previously adding
<meta name=”fragment” content=”!”/>
This meta tag actually transformed your url as follows
https://yoursite.com/#/contact to
https://yoursite.com/?_escaped_fragment_/contact.html

Assuming that google crawls content after # now you can cross your fingers that crawlers (not just google) will get more mature in the future. Try explaining that to marketing department.

4th solution

Use the href attribute value to go to the static page (or pre-rendering service) and use the onclick for actual users. Quickly provided as bellow
<a href=”/contact.html” onclick=”window.location=/#/contact; return false;” />
Provided that you have a prerenderer or a prerender service setup.

SEO and Javascript: New Challenges
SEO for AngularJS and other Javascript Frameworks

MySQL Change Collation Script

<?php
// Original script (v1.0) by/from: http://www.phpwact.org/php/i18n/utf-8/mysql
// Improved/modified (v1.05) by Bogdan http://bogdan.org.ua/
// Last updated: 2010-06-28
 
// this script will output all queries needed to change all fields/tables to a different collation
// it is HIGHLY suggested you make a MySQL backup prior to running any of the generated queries
 
// this code is provided AS IS and without any warranty
 
// add text/plain header when used not as a CLI script; PHP CLI SAPI shouldn't output headers
header("Content-Type: text/plain");
 
// precaution
die("Make a backup of your MySQL database, then remove this line from the code!");
 
set_time_limit(0);
 
// collation you want to change to:
$convert_to   = 'utf8_general_ci';
 
// character set of new collation:
$character_set= 'utf8';
 
// DB login information - *modify before use*
$username = 'user';
$password = 'pass';
$database = 'database_name';
$host     = 'localhost';
 
//-- usually, there is nothing to modify below this line --//
 
// show TABLE alteration queries?
$show_alter_table = true;
// show FIELD alteration queries?
$show_alter_field = true;
 
mysql_connect($host, $username, $password);
mysql_select_db($database);
 
$rs_tables = mysql_query(" SHOW TABLES ") or die(mysql_error());
 
while ($row_tables = mysql_fetch_row($rs_tables)) {
    $table = mysql_real_escape_string($row_tables&#91;0&#93;);
   
    // Alter table collation
    // ALTER TABLE `account` DEFAULT CHARACTER SET utf8
    if ($show_alter_table)
        echo("ALTER TABLE `$table` DEFAULT CHARACTER SET $character_set;\n");
 
    $rs = mysql_query(" SHOW FULL FIELDS FROM `$table` ") or die(mysql_error());
 
    while ( $row = mysql_fetch_assoc($rs) ) {
       
        if ( $row&#91;'Collation'&#93; == '' || $row&#91;'Collation'&#93; == $convert_to )
            continue;
 
        // Is the field allowed to be null?
        if ( $row&#91;'Null'&#93; == 'YES' )
            $nullable = ' NULL ';
        else
            $nullable = ' NOT NULL ';
 
        // Does the field default to null, a string, or nothing?
        if ( $row&#91;'Default'&#93; === NULL && $row&#91;'Null'&#93; == 'YES' )
            $default = " DEFAULT NULL ";
        elseif ( $row&#91;'Default'&#93; != '' )
            $default = " DEFAULT '".mysql_real_escape_string($row&#91;'Default'&#93;)."'";
        else
            $default = '';
 
        // sanity check and fix:
        if ($nullable == ' NOT NULL ' && $default == ' DEFAULT NULL ') {
            $default = '';
            echo "/* Warning: wrong combination of 'default value' and 'NULL-flag' detected - and fixed! */\n";
            echo "/* Diagnostics: row&#91;Null&#93; = '$row&#91;Null&#93;', row&#91;Default&#93; = " . mysql_real_escape_string($row&#91;'Default'&#93;) . ", MySQL version: " . mysql_get_server_info() . " */\n";
        }
 
        // Don't alter INT columns: no collations, and altering them drops autoincrement values
        if (strpos($row&#91;'Type'&#93;, 'int') !== false) {
            $show_alter_field = False;
        }
        else {
            $show_alter_field = True;
        }
 
        // Alter field collation:
        // ALTER TABLE `tab` CHANGE `field` `field` CHAR( 5 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL
        if ($show_alter_field) {
            $field = mysql_real_escape_string($row&#91;'Field'&#93;);
            echo "ALTER TABLE `$table` CHANGE `$field` `$field` $row&#91;Type&#93; CHARACTER SET $character_set COLLATE $convert_to $nullable $default;\n";
        }
    }
}
?>

Capture Save/Load/Remove Image in documents directory

NSFileManager offers a convenient way to write images to and load them from the documents directory.
If you’re frequently doing that in your project, I suggest to wrap up NSFileManager support in three simple methods:

Save/Load/Remove Image Methods

//saving an image

- (void)saveImage:(UIImage*)image:(NSString*)imageName {

NSData *imageData = UIImagePNGRepresentation(image); //convert image into .png format.

NSFileManager *fileManager = [NSFileManager defaultManager];

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png", imageName]];

[fileManager createFileAtPath:fullPath contents:imageData attributes:nil];

NSLog(@"image saved");

}

//removing an image

- (void)removeImage:(NSString*)fileName {

NSFileManager *fileManager = [NSFileManager defaultManager];

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png", fileName]];

[fileManager removeItemAtPath: fullPath error:NULL];

NSLog(@"image removed");

}

//loading an image

- (UIImage*)loadImage:(NSString*)imageName {

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png", imageName]];

return [UIImage imageWithContentsOfFile:fullPath];

}

Now, you can easily save an image like:

[self saveImage: myUIImage: @"myUIImageName"];

or load it like:

myUIImage = [self loadImage: @"myUIImageName"];

or remove it like:

[self removeImage: @"myUIImageName"];

Capture an image

– (UIImage*) getGLScreenshot {
NSInteger myDataLength = 320 * 480 * 4;

// allocate array and read pixels into it.
GLubyte *buffer = (GLubyte *) malloc(myDataLength);
glReadPixels(0, 0, 320, 480, GL_RGBA, GL_UNSIGNED_BYTE, buffer);

// gl renders “upside down” so swap top to bottom into new array.
// there’s gotta be a better way, but this works.
GLubyte *buffer2 = (GLubyte *) malloc(myDataLength);
for(int y = 0; y <480; y++) { for(int x = 0; x <320 * 4; x++) { buffer2[(479 - y) * 320 * 4 + x] = buffer[y * 4 * 320 + x]; } } // make data provider with data. CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, buffer2, myDataLength, NULL); // prep the ingredients int bitsPerComponent = 8; int bitsPerPixel = 32; int bytesPerRow = 4 * 320; CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB(); CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault; CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault; // make the cgimage CGImageRef imageRef = CGImageCreate(320, 480, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent); // then make the uiimage from that UIImage *myImage = [UIImage imageWithCGImage:imageRef]; return myImage; } - (void)saveGLScreenshotToPhotosAlbum { UIImageWriteToSavedPhotosAlbum([self getGLScreenshot], nil, nil, nil); } [/sourcecode]