Posts

Showing posts from December, 2014

Only Music can explain

Another great tool to convert mp4 to mp3

It is ffmpeg. In Ubuntu 14.04, you can install ffmpeg as following: $ sudo apt-get install ffmpeg libavcodec-extra-53 Then, you can convert your mp4 videos to mp3: $ ffmpeg -i source.mp4 -b:a 320K -vn dest.mp3 For more information about ffmpeg, please follow its repository:  https://github.com/FFmpeg/FFmpeg

XtraBackup error "InnoDB: Operating system error number 24 in a file operation."

This morning, I tried to backup the MariaDB database using xtrabackup: $ xtrabackup --backup --datadir=/var/lib/mysql/ --target-dir=/data/backups/mysql/ and ran into this error: ... InnoDB: Operating system error number 24 in a file operation. InnoDB: Error number 24 means 'Too many open files'. InnoDB: Some operating system error numbers are described at InnoDB: http://dev.mysql.com/doc/refman/5.1/en/operating-system-error-codes.html InnoDB: Error: could not open single-table tablespace file InnoDB: ./roei_cc/transport.ibd! InnoDB: We do not continue the crash recovery, because the table may become InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it. InnoDB: To fix the problem and start mysqld: InnoDB: 1) If there is a permission problem in the file and mysqld cannot InnoDB: open the file, you should modify the permissions. InnoDB: 2) If the table is not needed, or you can restore it from a backup, InnoDB: then you can remove the .ibd

A pretty neat tool to convert mp4 to mp3

So you download some youtube video to your computer but only want to have the sound. Here you go, pacpl is the one. $ sudo apt-get install pacpl (I only tested this tool on Ubuntu 14.04) start to convert $ pacpl --to mp3 -v -r- -bitrate 320 myvideo.mp4 Awesome!

Deploy Redmine 2.6 with Unicorn, Supervisor, and NginX

This blog post is about how to deploy Redmine 2.6, the opensourced project management software in a Ubuntu server with unicorn, supervisor and nginx. A. Install Redmine: 1. Create a mariadb database for redmine: * database name: redmine * user: redmineuser * password: redminepasswd 2. Clone the redmine's git repo: $ git clone https://github.com/redmine/redmine.git $ cd redmine $ git checkout -b 2.6-stable 3. Configure database connection: Copy config/database.yml.example to config/database.yml and edit this file in order to configure your database settings for "production" environment. production:   adapter: mysql2   database: redmine   host: localhost   username: redmineuser   password: redminepasswd (for ruby 1.9) 4. Install dependencies: $ gem install bundler $ bundle install --without development test 5. Session store secret generation: $ rake generate_secret_token 6. Database schema objects creation: $ RAILS_ENV=production rak

PowerSchool - How to display student photos on the Parent's Portal

Image
To display student's photo on the PowerSchool Parent's Portal: 1. In PS Administrator, create a custom page under the guardian folder, student_photo.html , with the following content: The   ~[studenttitlephoto] will output the student photo's thumbnail which is too small. For example: https://mypowerschool.com/guardian/stpthumb/5712ph_thumb.jpeg?version=1417586219587 I figured out where the source of the real photo is. All I have to do to get the bigger image source is to remove all the ' thumb ' part in the source link of the image: https://mypowerschool/guardian/stp/5712ph.jpeg?version=1417586219587 var src = photo.attr( ' src ' ); src = src. replace ( ' thumb ' , ' ' ); // replace the src link with the bigger photo's src = src. replace ( ' _thumb ' , ' ' ); // replace the src link with the bigger photo's photo.attr( ' src ' , src); Plus, I also have to re

Manage all your WordPress sites in a single dashboard with InfiniteWP

Image
If you have so many WordPress sites to manage like me, you will find yourself getting into trouble when you have to look after every site's updates. plugins, themes... It would be great if we have only one place to manage all the sites. Fortunately, I found a pretty good solution, the InfiniteWP, and it's free. (This's not a rare situation anyway) InfiniteWP's official website: http://infinitewp.com/ Here are the only few things you have to do in order to setup a central place to control all your WordPress sites: 1. In every WordPress site, install the InfiniteWP client plugin: After you install the plugin, activate it to get the client details: 2. Install the InfiniteWP: a. Download the InfiniteWP source, unzip, and copy to /var/www/iwp Download link:  http://infinitewp.com/installing-options/ $ unzip IWPAdminPanel_v2.4.3.zip $ sudo cp -R IWPAdminPanel_v2.4.3 /var/www/iwp $ sudo chown -R www-data:www-data /var/www/iwp b. Create a MariaDB

Trying WPScan, a black box WordPress vulnerability scanner

Image
I just found a great tool to scan my wordpress sites for vulnerability, WPScan . WPScan is a blackbox scanner which means that you can install it on your computer and scan remote wordpress servers. To install WPScan on my Ubuntu 14.04 server, I ran these command lines: $ sudo apt-get install libcurl4-gnutls-dev libxml2 libxml2-dev libxslt1-dev ruby-dev build-essential $ git clone https://github.com/wpscanteam/wpscan.git $ cd wpscan $ sudo gem install bundler && bundle install --without test Then, tried some of these features: 1. Simple check: $ ruby wpscan.rb --url www.mywordpress.com 2.  Do a wordlist password brute force on all the users: $ ruby wpscan.rb --url www.mywordpress.com --wordlist darkc0de.txt Notes: you can download the sample wordlist file here . for more scanning methods, please read the WPScan's official website .

Some notes when working with Google Apps Script

Image
Here are some notes I took when working with Google Apps Script: 1. Global variables: Can't change global variables's values. If you want to change them, use scriptdb (removed on November 20, 2014), google spreadsheets (data < 10000 rows), or Google Cloud SQL (data > 10000 rows) instead. 2. Call external REST API(s) To debug your script when calling an external REST API using UrlFetchApp.fetch, you can use this parameter of the options: 'muteHttpExceptions': true, For example:   var url = 'http://myapi.com';   var options = {     'method': 'POST',     'headers': headers,     'payload': 'This is the payload',     'contentType': 'application/json',     'muteHttpExceptions': true // use for debugging   };   var response = UrlFetchApp.fetch(api_url, options); 3. For loops: For loops in Google Script looks a lot like python except for..., example: for(item in

SMS reminder in Redmine with Google Apps Script

Image
Do you remember how we use Google Apps Script to get SMS notification every time we receive an email? If not, please read this article . It's even cooler if you can take advantage of that script to remind you about Redmine 's issues due date. Even though Redmine already has the email reminder feature which is quite convenient but if you want more, like SMS, here is the hack: 1. Turn on the email reminder feature of Redmine by adding a crontab to run this rake task: # crontab -e 00 08 * * * /usr/bin/rake redmine:send_reminders days=7 users="12" RAILS_ENV="production" Everyday at 8AM, it will check Redmine, if there is any issue of mine will due in 7 days (not in closed status), it will email me. To turn the reminder on for all user, just get rid of the " users " parameter. More details at here . 2. In Gmail, create a filter for all email messages has the following word: Has the following words: " issue(s) due in the next &qu

To use https (only) for Moodle with nginx

Image
To make your moodle instance work on https only is pretty simple with nginx: 1. Create a folder to contain the ssl certificate and key at /etc/nginx/ssl 2. Configure your nginx server block as following: 3. Create a simlink to the server block and restart nginx: $ sudo ln -s /etc/nginx/sites-available/mymoodlessl /etc/nginx/sites-enabled/mymoodlessl $ sudo service nginx restart 4. Add/modify these two lines to your moodle's config.php: $CFG->wwwroot   = 'https://mymoodle.com'; $CFG->sslproxy=true; 4. Do not enable " Use https for logins " in Site administration / ► Security / ► HTTP security 5. Done