Posts

Showing posts from August, 2016

Mass resize photos in Linux with ffmpeg

To resize multiple photos at once, you can run this command line: + Resize To 1/10 its original size: $ for filename in /path/to/*.jpg; do ffmpeg -i "$filename" -y -vf scale=iw*.1:ih*.1 "$filename";done with: iw: input width ih: input height + Keep the aspect ratio, we need to specify only one component, either width or height, and set the other component to -1: $ for filename in /path/to/*.jpg; do ffmpeg -i "$filename" -y -vf scale=250:-1 "$filename";done

What to do when your root account in vCenter has been locked out

Image
If the root account is not accessible through the console, the secure shell, and the Virtual Appliance Management Interface (VAMI) (vCenter Server Appliance 5.5 and 6.0 Update 1), the root account has been inactivated due to password expiration or too many fail attempts . To reactivate the root account, the vCenter Server appliance must be rebooted and the kernel option modified in the GRUB bootloader to obtain a root shell. To reactivate the root account: 1. Reboot the vCenter Server appliance using the vSphere Client. 2. When the GRUB bootloader appears, press the spacebar to disable autoboot. 3. Type  p  to access the appliance boot options. 4. Enter the GRUB password. Note : If the vCenter Server appliance was deployed without editing the root password in the Virtual Appliance Management Interface (VAMI), the default GRUB password is  vmware . If the vCenter Server appliance root password ...

Enter bash shell mode of vmware vcenter server console

These are the commands that you need to enter to go the bash shell mode of vCenter server appliance: Command> shell.set --enabled true Command> shell

Disable password expiration policy in Linux

If you don't want your user's password expired after an amount of time, you can run this command: # chage -I -1 -m 0 -M 99999 -E -1 username It will set: Minimum Password Age to 0 Maximum Password Age to 99999 Password Inactive to -1 Account Expiration Date to -1

MySQL query results to a CSV file

You can use this syntax to output your MySQL query results to a CSV file, for example: SELECT blog_id, path, registered, last_updated      INTO OUTFILE '/tmp/test.csv'      FIELDS TERMINATED BY ','      OPTIONALLY ENCLOSED BY '"'      ESCAPED BY '\\'      LINES TERMINATED BY '\n'  FROM wp_blogs  WHERE path IN ('/105102/','/105095/','/103206/'); Note: It's better to output the file to /tmp directory because mysql user has permission to write there.

Use external folder as DocumentRoot in Apache

When adding a new Virtual Host in Apache with DocumentRoot outsite of the default htdocs folder (xamp), you need the red line in your server virtual host configuration: <VirtualHost *:80>     ServerAdmin myemail@mydomain.com     DocumentRoot "C:/xampp/photography"     ServerName mydomain.com     ErrorLog "logs/mydomain.com-error.log"     CustomLog "logs/mydomain.com-access.log" common <Directory "C:/xampp/photography/"> Options Indexes MultiViews Order allow,deny Allow from all Require all granted </Directory> </VirtualHost> If not, you gonna get the Do not have permission error when trying to access your website.

#700 - Apache 2.4 HTTPS on Windows Server stops working after running for several hours

I was trying setup an Apache 2.4 server on Windows Server 2008 R2 to server static files for my web applications over SSL. It ran smoothly for couple hours and than hang forever. I tried to restart server every time it happens but it only last for several hours and then crashed again. It frustrated me and after looking to the configuration of Apache for a while, I finally make it works beautifully. 1. Enable MPM in  httpd.conf with those settings: By default, this MPM uses advanced Windows APIs for accepting new client connections. In some configurations, third-party products may interfere with this implementation, with the following messages written to the web server log: Child: Encountered too many AcceptEx faults accepting client connections. winnt_mpm: falling back to 'AcceptFilter none'. The MPM falls back to a safer implementation, but some client requests were not processed correctly. In order to avoid this error, use AcceptFilter with accept filter none. Ac...

Restore Moodle course in command line with MOOSH

It's the next step of this , restoring your big Moodle course in command line with MOOSH: course-restore Restore course from path/to/backup.mbz to category or existig course. Example 1: Restore backup.mbz into category with id=1 moosh -n course-restore backup.mbz 1 Example 2: Restore backup.mbz into existing course with id=3 moosh -n course-restore -e backup.mbz 3

WordPress Multisite - Create user and blog in command line using php

If you have a WordPress Multisite instance and you have to create blogs for your users, using the web interface of WordPress is not a good idea because you have to do it one by one. Here is a solution: 1. Create a csv file contains all the user information. 2. Using php and WordPress's function to create users and blogs. 3. Enjoy You can start from here. This is a php script I wrote to create a single user, blog, and add that user as an administrator of the blog: Usage: 1. Place that script inside a subfolder of your WordPress installation, for example: /var/www/wordpress/your_custom_scripts/create_user_blog.php 2. Run it: $ php /var/www/wordpress/your_custom_scripts/create_user_blog.php <username> <password> <user's display name> <user's blog path> <site category> Notes: 1. In the script I used my company-assigned id_number as user's blog path. 2. I also add site_category option to the new blog to categorize all my ...

WordPress - Bypass W3 Total Cache when running php script in command line

If your wordpress site's using W3 Total Cache, there is a big chance that your php script will stop working because of the cache, especially db cache. Here is my solution for that: Flush W3 Total Cache cache before running any functions. You simply put this line of code before executing any wordpress's function: if (function_exists('w3tc_dbcache_flush')) { w3tc_dbcache_flush(); } For example: ...                 // Flush W3TC DB cache before creating blog                 if (function_exists('w3tc_dbcache_flush')) { w3tc_dbcache_flush(); }                 $blog_id = wpmu_create_blog('my.multisite.blog', $path, $title, $user_id, $meta); ...

Backup Moodle courses in command line using MOOSH

Sometimes, you cannot backup your Moodle course because it is too big which makes the web server timeout. In that situation, backing up the course using command line is a good way to go. MOOSH will help you perfectly. Github repository: https://github.com/tmuras/moosh Official website and documentations:   http://moosh-online.com/ 1. Install MOOSH in your Ubuntu server:  sudo apt-add-repository ppa:zabuch/ppa  sudo apt-get update  sudo apt-get install moosh 2. Go to moodle installation folder and run this command: $ moosh -n course-backup -f /path/to/where/you/store/backup/mycourse.mbz <course_id>

Subscribe Google Apps users to calendars using GAM and python

If you want to subscribe a Google App user to calendar, you can use GAM and python. This following script my get you started: Note: You have to have GAM up and running before running this script.

Moodle - Get courses by category using php script

So, programmer, I heard that you want to get all the moodle courses of a category programmatically? Here you go: It takes advantages of Moodle's  lib/coursecatlib.php.