Monday, June 22, 2015

Xiaomi Yi Action Camera: Non-Technical Review, Sample Video

Xiaomi Yi Action Camera: Non-Technical Review, Sample Video and Why I Bought Xiaomi and not GoPro.

A quick word about this post - this is a super non-technical review of the Xiaomi camera filled with personal feedback from a very casual consumer. There are several really technical articles available via a quick Google search detailing all of the differences and specifications of Xiaomi Yi Action Camera and competitors; this is not one of those. Additionally, I don't intend to bash on GoPro or Xiaomi Yi in any way – while I think the 2 cameras are marketed in the same “action cam” category, they are worlds apart in quality, purpose, functionality and their features and are in fact completely different products that should not even be compared side by side (although I am doing just that...) The Xiaomi Yi action camera (for me) is like a Honda Civic and a GoPro being a high-end Mercedes. They both get you from point A to point B to good video very well, but one is going to have way more technology and features that you are paying for.

Tuesday, October 21, 2014

How to use RSYNC to compare 2 directories / folders and then create a 3rd directory with only the files that are new / different?

It took me a long while to finally create an rsync command to do what I needed correctly. This can be used to manage server backup folders or just synchronizing folders.

In my case, I have 2 very similar folders. FolderA is my "live" real site. "FolderB" is my backup copy of FolderA.

In order to keep my FolderB backup copy synchronized with the real FolderA website, I need to use rsync, but only find files that are different in any way, new or modified. For example, if I updated a PHP file in real site, I want it copied to the backup site and if someone uploaded a picture on the real site - I want that new file copied to the backup folder as well.

Please note that command below uses "--dry-run" parameter, keep it - it means nothing will actually be done or changed / written until you delete the --dry-run parameter from the command. It just means its in "test mode" and won't destroy anything until removed.

Because I don't want the files automatically written into my backup folder, I am creating a 3rd folder called "difference" and that's where ALL updated files from FolderA (real site) will be created. This means that I need to copy the "difference" folder into my backup folderB (overwrite any existing files in folderB with the ones from difference folder).

Confused yet? I think I am. Summary is: compare real site folderA to backup folderB and create the updated files inside a brand new /difference/ folder.

The command: 

rsync -rv --checksum --exclude '.htaccess' --exclude 'wp-config.php' --progress --stats --dry-run --compare-dest=/var/www/html/folderB/ /var/www/html/folderA/ /var/www/html/difference

  • note that I am excluding 2 files from being synchronized, modify or delete the exclude parameters as you see fit for your needs
  • folderA = your real site / your source of all up to date changes
  • folderB = this is your backup folder
  • difference = this is the brand new folder where updated files from folderA will be written that do not exist or are not up-to-date in folderB
Don't forget to remove --dry-run parameter to actually write the files for real in the /difference/ directory! 

Monday, March 24, 2014

Converting old MySQL passwords to MySQL 5.6 (16 characters to 41 characters)

  • Remove or comment old_passwords = 1 in my.cnf
Restart MySQL. If you don’t, MySQL will keep using the old password format, which will mean that you cannot upgrade the passwords using the builtin PASSWORD() hashing function.
The old password hashes are 16 characters, the new ones are 41 characters.
  • Connect to the database, and run the following query:
    SELECT user, Length(Password) FROM mysql.user;
This will show you which passwords are in the old format, ex:
| user     | Length(`Password`) |
| root     |                 41 |
| root     |                 16 |
| user2    |                 16 |
| user2    |                 16 |
Notice here that each user can have multiple rows (one for each different host specification).
To update the password for each user, run the following:
UPDATE mysql.user SET Password = PASSWORD('password') WHERE user = 'username';
Finally, flush privileges:

Wednesday, March 19, 2014

How to upgrade Plesk MySQL to Percona MySQL 5.6 (latest)

Plesk admin panel usually ships with MySQL 5.1 and if you are looking to upgrade it to 5.6 the process (at least for me) was not quite clear, with lots of little issues along the way. I learned a couple of things that are not immediately obvious and hope to capture them along the way in this quick guide. Here is my version of the steps necessary to upgrade MySQL 5.1 to Percona MySQL Server (and client). (Big shout-out to this blogger as well for clearing things up very nicely:

Quick Note on "Why upgrade to Percona MySQL 5.6"
  • In short, Percona MySQL server is a modified MySQL 5.6 distribution that is optimized for maximum performance and will improve the overall performance of your database services (in theory, in most cases).

Starting Configuration
  • CentOS 64 Bit
  • Plesk 11.5+ with standard default packages installed
  • MySQL 5.1

Friday, December 14, 2012

Really useful, Essential CentOS / UNIX Commands

I'll begin by saying that I am absolutely no UNIX expert. Having worked with Unix (specifically CentOS) systems for a few years - I've been Googling and learning lots of really essential and overall very useful commands. I've kept a spreadsheet for myself - but figured it may prove to be helpful and time-saving for someone else.

Finding a specific filename on the Unix filesystem in all Sub-Directories

  • Let's say you are currently inside /var/www/yoursite directory
  • You want to find a file called "barney.jpg" inside "yoursite" directory and all of its sub-directories
  • find . -name barney.jpg -type f

Executing a command on several Unix servers at the same time

  • In this example, imagine you have a cluster of 7 web-servers named webserver1 through 7
  • You want to execute the same command on all 7 machines without having to ssh individually to each machine and executing the same command line.
  • The command below will massh into 7 webservers, check the apc.ini file and output a grep search result of "apc.shm_size=256". The commands after -c can be anything, for example "w".
  • massh -r webserver[1-7] -c "cat /etc/php.d/apc.ini |grep apc.shm_size=256" -o

How to check the actual/real directory location inside Sym-linked Directory

  • Let's say that your /var/www/yoursite directory is a symbolic link to a release branch
  • Example: /var/www/yoursite/ => /var/www/releases/2012_release1/
  • To view the physical location inside the symbolic link directory you have to modify the "pwd" command slightly:
  • pwd -P

How to grep everything inside a directory including all of its sub-directories?

  • In this example you are inside a document root, such as /var/www/yoursite/
  • There are hundreds of .php files located in different directories
  • You want to find the exact file that references a specific keyword inside it
  • For example "whSysopRangeBans"
  • grep -r -i 'wgSysopRangeBans' ./

How to remove lines inside a file using VI (VIM Editor) that begin with a specific character

  • In this example you are editing a sample file called example.php
  • Imagine that every line in example.php starts with "X" without quotes
  • XBuffer do xyz
  • XRender zyg
  • For some reason you want to find and remove the lines that begin with the X character
  • The VIM command for this regular expression delete is:
  • :g/^x.*$/d
How to output top 10 requests in your Apache ERROR or ACCESS log

  • In this example you are checking your apache request log(s)
  • Want to find out what the top 10 requesting IP's are?
  • cat /var/log/httpd/ | awk '{print $1}'| sort -n | uniq -c | sort -rn | head -n10 
  • Very helpful in quickly identifying malicious scrapers and other issues

How to migrate / move an entire site server to server or sync full sites / directories

  • In this example we have two different servers
  • You want to sync or move the files from one server to another; from source to destination
  • This command will rsync files that are updated or do not exist on the destination directory
  • So, if you want to synchronize both directories on two different servers, this command will help.
  • Below command assumes you are logged into the source server and you will be connecting/sending files to destination server; you will be syncing "uploads" directories:
  • rsync -auv -e ssh --progress /var/www/html/ username@destinationserverip:/var/www/html/destination/upload/

How to Tar Gzip an Entire Directory (create a tarball for entire directory and all sub-dirs)

  • In this example you are creating a backup.tgz file inside migration directory using all of the files and sub-directories from /
  • tar -czvf /var/www/html/migration/backup.tgz /var/www/html/

You have a large GZIP tar ball, how to download/move a large tar file server to server:

  • In this example you created a huge backup.tgz file on a server called serversource1
  • Now you want to move it to another server, serverdestination1
  • While logged in on serverdestination1 (new server), issue this command:
  • scp someusername@serversource1:/var/www/html/migration/backup.tgz  /var/www/html/destinationdirectory/

OK, How to "unzip" / un-tar my tar-gzip archive file?

  • You've successfully zipped and moved your large gzip file
  • The command below will unzip and re-create all of the files and sub-directories from the archive file
  • tar -xzf backup.tgz -C /var/www/html/destinationdirectory/

How to dump / create backup for your MySQL Database using mysqldump
  • For example, you would like to create a complete database backup file of your vBulletin forum or your Wordpress blog
  • mysqldump -h'yourmysqlserverhostname' -u'mysqlusername' -p'mysqlpassword' sourcedbname > backup.sql
  • Please note that -h parameter may be optional for some machines and you can remove -h'hostname' entirely from the above command

How to restore MySQL database from dump file

  • Earlier, you've created a backup.sql mysql dump file
  • Now you want to "restore" this backup file to a new clean database
  • Important note: You can't really restore a mysql dump file on top of existing database if the tables already exist, you will have to create a new clean database or "drop" the database entirely. Dropping the database will completely delete all of the tables and content!
  • mysql -h'mysqlhostname' -u'mysqlusername' -p'mysqlpassword' destination_databasename < backup.sql

How to merge / synchronize two file folders

  • Imagine that you have two slightly different images directories, images_new and images_old
  • You want to create just one directory that has all of the up-to-date files
  • You want to copy all of the content from images_old into images_new without overwriting anything that has not been updated or modified in any way according to timestamp, not filename.
  • rsync -va /var/www/html/images_old/ /var/www/html/images_new

How to find and delete a specific

  • In this example you are going to find a filename match for "" and then delete it
  • $find . -type f -name "" -exec rm -f {} \;

How to copy "cp" files from one directory to another, but only new files that do not exist already
  • In this example you are trying to copy files from images_old to images_new directories, but do not overwrite any files that exist already.
  • In essence you are merging two directories together without overwriting old files
  • sudo yes n | cp -i -R /mnt/images_old/* /var/www/sites/images_new/

How to create a symlink, How to create a fake directory alias for easy access
  • In this example you are creating a symbolic link between directories
  • Really usefull for SVN control also
  • In this example your "new_build" directory will replace the "live" directory
  • ln -s  /home/content//public_html/new_build /home/content/public_html/live