There is no useradd command in OpenWRT. Instead, shadow user package is available but I found it overkill. Anyway, if you are interested in using it – check out this tutorial,
Follow these steps to create a user without using useradd command in OpenWRT. Continue reading
Author Archives: stz184
Generate huge JSON files with custom PHP >5.3 class
Lately, I’ve been working on transitioning XML feeds to JSON format on big video site. We generate these feeds in order to feed external search service with results. It’s similar to sitemap, but it provides more detailed information about the pages.
This task is challenging because of the following problems that need to be resolved:
- The feed need to represent over 500 000 database entries i.e. videos. It’s just not possible to generate huge PHP multidimensional array with more than 500 000 elements and pass it to json_encode(). Obviously, you need to generate small JSON objects (chunks) concatenated with hand-coded strings and so build the full feed.
- The development and production servers we use are equipped with outdated PHP version 5.3.27. That means:
– No meaningful error messages because json_last_error_msg() function it’s not available prior PHP 5.5
– No JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, and JSON_UNESCAPED_UNICODE - The code should be easy to test and maintain, so it should provide meaningful debug information and error handling.
Format microtime() to provide better feedback on the time elapsed
As a PHP developer you know that it’s common task to check how long a particular class, function or procedure performs. Usually this involves measuring of the time particular code snippet takes to execute. There are lots of PHP code benchmark scripts out there, but the simplest method remains to check the difference between the start and end time. Continue reading
Browser detection
I just have released Browser – PHP port of the popular jQuery browser plugin. It can detect browser name, version and platform. Additionally, mobile and desktop browsers are recognized. It is pretty simple and lightweight to use.
I would be glad to receive any feedback from you!
VLC does not support the audio or video format “hevc”. Unfortunately there is no way for you to fix this.
Just you have chosen a good mоvie to watch, you are seated comfortably in an armchair with pack of popcorn, clicked on your favorite media player VideoLAN and… bang! Error!
VLC does not support the audio or video format “hevc”. Unfortunately there is no way for you to fix this.
The error message above is not really correct. There is a way to fix it!
How To Configure a Mail Server Using Postfix and Dovecot on Ubuntu 14.04 LTS
This tutorial explains how to setup mail server on Ubuntu 14.04 using Postfix and Dovecot. It’s based on few other tutorials and does not pretend to show you all the best practices. I am writing this tutorial because it’s 99.9% sure that I will forget how I configured my own mail server very very soon and I have to write down all the info while it’s still fresh in my head.
Ok, let’s start to work!
How To Get The Log Instead of Just Revision Numbers by svn merge info
svn merge command is really great – it can be used to determine which revisions are already merged and which are eligible to merge from particular branch. But has one big drawback – it can output just the revision numbers, but not the corresponding log messages. So, it’s really hard to determine what has been commited actually with these revisions. Of course, you can run svn log command for the revisions in question, but what if there are, lets say, 50 commits?
You could build a list of commit messages by piping mergeinfo into the svn log command using xargs. It looks like this:
svn mergeinfo --show-revs=eligible ^/branches/version | tr "\\n" "," | xargs -i svn log -c {} ^/branches/version
To make the command little bit easier and shorter, you may consider to add an alias in your ~/.bash_aliases file as follow:
alias svnlog='tr "\\n" "," | xargs -i svn log -c {}'
Now, you can shorten the command like that:
svn mergeinfo --show-revs=eligible ^/branches/version | svnlog ^/branches/version
Enabling SSH Upgrade Access on WordPress on Ubuntu Server
As you may be already know, WordPress allows you to install and update plugins, widgets, themes etc, as well as whole system trough the admin panel. It’s very convenient time-saving feature but it requires you to provide FTP or FTPS credentials every time when its used. It could be really frustrating!
SFTP (SSH over FTP) should not be confused with FTPS (File Transfer Protocol Over SSL). FTP is vulnerable to attacks and should be avoided because the server can only handle usernames and passwords in plain text. So, as many people, I don’t have it installed on my virtual private server. If you feel that you need to install and enable a FTP server, just for WordPress, think twice – you can use SSH instead and I’ll show you how! Continue reading
How to Undo Changes in “nano” Text Editor in Ubuntu
Nano has experimental undo/redo feature. As you’ll see from the nano manual (type “man nano” in a Terminal to read that), you’ll need to start nano with the -u option
$ nano -u somefile.txt
… and then you can use Alt-U to undo and Alt-E to redo.
It’s little bit frustrating that you have to type the “-u” option every time when you want to edit a file, but hopefully there is a solution and its name is “alias”.
Aliases are a way for you to customize the commands by giving them aliases (nicknames). You can use them to remember commands with a lot of options or make their names shorter and easier to type. To setup aliases, all you need is to open the ~/.bash_aliases file and type in:
alias nano='nano -u'
If you want to add more aliases, enter each of them on separate line.
Now, typing “nano” is equal as typing “nano -u”. Tricky, yeah?
How to setup the perfect LAMP stack on Ubuntu 14.04 LTS
Ok, ladies and gentlemen!
I needed local development server closer as possible to the production one. I downloaded and Installed Ubuntu, but didn’t know how to get Apache, MySQL and PHP installed. After a few hours of reading random blogs found on Google and head banging I succeed.
My requirements was:
- Set up multiple subdomains automatically (i.e. Virtual Document Root)
- Password protect all my subdomains when they are accessed outside my home network but access them directly, without need to provide password, when I am connected to my local network and develop.
- To separate the error logs by virtual host (subdomain).
Below is a laundry list of commands to help you configure your own perfect Ubuntu server, too.