Enable TSQL xp_cmdshell command

SQL Server blocked access to procedure ‘sys.xp_cmdshell’ of component ‘xp_cmdshell’ because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of ‘xp_cmdshell’ by using sp_configure

A simple script to enable xp_cmdshell in SQL Server

sp_configure 'show advanced options',1
GO
RECONFIGURE
GO
sp_configure xp_cmdshell,1
GO
RECONFIGURE

Remove Maintance WP State

Description of error

If you’ve been keeping on top of your WordPress updates using the automatic upgrade feature, you may have run into a problem immediately after upgrading. A message that prevents access to any page on your blog, “Briefly unavailable for scheduled maintenance. Check back in a minute”.

Cause of this message

During an automatic upgrade, WordPress places a file in the blog root directory called “.maintenance” to prevent visitors from being confronted with ugly, broken pages during the upgrade process. That’s a great little built-in feature, but if the upgrade gets interrupted or fails for any reason, that file doesn’t get deleted and nobody, including you, can access your blog. No worries, this is (most likely) the simplest fix ever.

Official Solution

All you have to do is delete the .maintenance file from the blog root directory. Simple as it gets. After you’ve deleted the files you should be able to access the site just fine, but you may have to run the automatic upgrade again. How do you know if you should run it again? You’ll see a notification on the dashboard page that a new version of WordPress is available…same as you always see when a new upgrade is available. If you don’t see that message, you’re good to go.

In case problem persists

In my case the “. maintenance” file was not there at all. Started exploring the blog files and there it was.
In wp-content/upgrade/<pluggin_name>.temp
The pluggin name was the latest pluggin i tried to update. So i deleted this folder and everything came back to normal state.

I hope this helps.

Getting NSDate from NSString

Very useful, yet short and simple, code snippet on how to rip the NSDate from NSString using NSDateFormatter:

NSString *dateString = @"2010-01-19";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
// this is imporant - we set our input date format to match our input string
// if format doesn't match you'll get nil from your string, so be careful
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
NSDate *dateFromString = [[NSDate alloc] init];
// ta-daaa!
dateFromString = [dateFormatter dateFromString:dateString];

If you need more info about different date formats see Unicode Date Format Patterns. Of course if you usually work with standard dates you can use setDateStyle instead of setDateFormat.

Rebuild Icon Cache in Windows (Vista and 7)

Rebuilding the Icon Cache Database

  • Close all folder windows that are currently open.
  • Launch Task Manager using the CTRL+SHIFT+ESC key sequence, or by running taskmgr.exe.
  • In the Process tab, right-click on the Explorer.exe process and select End Process.
  • Click the End process button when asked for confirmation.
  • From the File menu of Task Manager, select New Task (Run…)
  • Type CMD.EXE, and click OK
  • In the Command Prompt window, type the commands one by one and press ENTER after each command:
    CD /d %userprofile%\AppData\Local
    DEL IconCache.db /a
    EXIT
    
  • In Task Manager, click File, select New Task (Run…)
  • Type EXPLORER.EXE, and click OK.

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";
        }
    }
}
?>

iPhone Touch Icon – Create your own Icon Set

Since the introduction to the iPhone 4, we now have some additional icons we need to create to support the Hi-Res graphics of the iPhones Retinal Display. Altogether we now have a total of 6 app icons, each with a different pixel size in order to support all devices they are as follows:

  • iPhone 4 Hi-Res App Icon ( 114 x 114 )
  • iPhone App Icon ( 57 x 57 )
  • iPad App Icon ( 72 x 72 )
  • iphone 4 Hi-Res Spotlight Icon ( 58 x 58 )
  • iPhone Spotlight Icon ( 29 x 29 )
  • iPad Spotlight Icon ( 50 x 50 )

After recently developing a few iPhone apps, I found it to be a redundant task to create 6 icons every time I make a new app. To make this process faster, I’ve created a PHP script that takes the highest resolution icon and converts it down to the 6 icons required.
You can find this script at my company website at http://empoc.com/ios-icons/
It only takes a few seconds to create all of the icons and when the script has finished running you will be able to download them all in a nicely zipped up file. I’ve also got instructions there that will show you what to do with the icons once you’ve downloaded them.
Please have a look and let me know what you think…

Alternatively you can visit make app icon to create the whole set of icons http://makeappicon.com/

Why Google Chrome?

There are some features that most ppl hasnt noticed in google Chrome. For my opinion Google Chrome will be the no1 choise of all net freaks.

Incognito mode (private browsing)

For times when you want to browse in stealth mode, for example, to plan surprises like gifts or birthdays, Google Chrome offers the incognito browsing mode. Here’s how the incognito mode works:

Webpages that you open and files downloaded while you are incognito aren’t recorded in your browsing and download histories.
All new cookies are deleted after you close all incognito windows that you’ve opened.
Changes made to your Google Chrome bookmarks and general settings while in incognito mode are always saved.
Keyboard shortcut: Ctrl+Shift+N

Advanced Search in Address Bar

Chrome uses a search engine as your type a url. So the address bar can be used for search and for inserting a url. Autocomplete is very helpful even in very specific searches.

Also Check out this screen. In options

There are default Search options but also Other search engines from Sites you use mostly (this is done for you automatically)

Quick Search

Type your search. As you type you can see the number of occurrences (current occurrences is highlighted in orange).
Check out that the search string is highlighted in the scrollbar also.

Keyboard shortcut: CTRL + F

Speed

see some past test i did with tracemonkey here

Wiscp on iPhone

First make sure you have ssh and bsd subsystem installed from installer. If you cant find the source reboot or turn off wifi and back on.

Next get WinSCP and find your iPhone’s ip by going to (on your iphone) settings > Wi-Fi > “Your selected WiFi” > Look under IP Address- Connect to your iPhone using WinSCP (user: root password: alpine) Change File Protocol to SCP.

Once OpenSSH is installed your phone will be vunerable to all users in a specific wifi subnet. Make sure to Use the WinSCP terminal window an use this command to change password:

passwd root
type in password, press return
type it in again, press return

To avoid frequent logouts remember to change the Setting -> General -> Auto-Lock (5 minutes or Never)

IT collaboration, Tutorials, Tips