Configuring NAT, DMZ or Virtual Servers on ASMAX AR1004g

This is a very short brief on how to properly setup NAT functions on ASMAX AR1004g router, i.e. how to route all (or part of) incoming traffic to a specific machine in your local network. In this text, I assume that your router is available under 192.168.1.1 static IP address in your local network and you want to route all traffic using FTP protocol to your video-player, available under 192.168.1.3 and all traffic using HTTP to another computer, that is accessible under 192.168.1.4 static IP address in your local network. Adjust this assumption to your actual situation. Read More “Configuring NAT, DMZ or Virtual Servers on ASMAX AR1004g”

Five major software development rules

To all those, who just don’t get it!

  1. DRY = Don’t Repeat Yourself!
  2. KiSS = Keep it Simple, Stupid!
  3. You ain’t gonna need this!
  4. Premature optimization is the beginning of all hell!
  5. Copy-paste is time waste!

Never, ever forget about these five, if you’re developing anything.

Simple script for showing contents of a folder

Long long time ago in a galaxy far far away I wrote a very simple PHP script, that I usually put into index.php of a directory, which contents I’d like to print out to the browser. I’m using this solutions on all servers and hostings which has Apache-based directory listings disabled and thus are showing empty page or error screen, if folder does not contain index.php.

Here’s the code:

[code language=”php”]
$dir = getcwd();

if (is_dir($dir))
{
if ($dh = opendir($dir))
{
echo(‘Files in this folder:<ul>’);

while (($file = readdir($dh)) !== false)
{
if ($file != ‘.’ && $file != ‘..’ && $file != ‘index.php’)
{
echo(‘<li><a href="’.$file.’">’.$file.'</a></li>’);
}
}
closedir($dh);

echo(”);
}
}
[/code]

That’s pretty much everything, folks!

Is it possible to convert working pure PHP appication to Yii

I was once asked, if it would be possible to do step-by-step conversion of a large project written in pure PHP into Yii. In my opinion, it is possible, but absolutely not worth it.

Most professional frameworks are complete opposite to “pure PHP” code in actually all areas. Code is separated most times (i.e. into model, view and controller in MVC design pattern) and uses mostly framework classes or code. I would even say, that writing an application in some framework means using only 10-20% of pure PHP code and doing rest purely on framework classes, extensions, controllers etc.

In other words: porting a “pure PHP” application into framework code would mean writing that application from scratch. I’m not sure, if you would be able to reuse more than 5% of your original source code?

Installing SVN on QNAP using IPKG (Optware)

This article is based on information provided by QPKG package created for SVN by noski and on QNAP Wiki article about SVN and of course a piece of my experience. But since SVN is relatively easily to install by-hand (so you don’t actually need QPKG package) and since Wiki article about SVN is outdated / contains some garbage (directory /share does note belong to /dev/ram!), I decided to write my own guide.

Read More “Installing SVN on QNAP using IPKG (Optware)”

Sending *.exe files through GMail and other mail servers

As for right know (when anything goes web and desktop applications are nearly dead) there aren’t many situations, when you would like to send an *.exe file as an attachment. But, suppose you want. Then you, the good question, is how to do this? Well… in general, you can’t do that. Gmail itself will block you from sending an EXE file directly or ZIP archive containing it. Saying that it did so, for the security reasons. And, even if you pass it over (see below), most mail servers will block you from delivering such contents to mailboxes operated on this or that server.

Read More “Sending *.exe files through GMail and other mail servers”

Installing Optware (IPKG) on QNAP TS-210

Outdated article! Read the updated version instead.

This article deals with installing Optware (IPKG) on QNAP TS-210 NAS machine. Optware is a must-have, if you want to do anything with your NAS that goes beyond using as simple network storage. I.e., if you want to access it via SSH and play a little around Linux on-board. In other words, in installs many core utils, that are simply gone from default distribution of Linux on-board QNAP.

Read More “Installing Optware (IPKG) on QNAP TS-210”

Fix for problem with mixing USB shares on QNAP

Most QNAPs randomly mounts USB disk shares. I.e. you can have disk attached to left USB port as USBDisk1, second as USBDisk2 and after reset — changed together. This causes many problems, where being unable to write some script accessing particular disks could be named at first. There isn’t an easy way to work around it. The only solution I found out was to write an script that resides in flash memory (therefore is called upon each restart of QNAP) and that mounts disks under shares similar to their disk labels.

Read More “Fix for problem with mixing USB shares on QNAP”

Remove non-empty directory on QNAP or Linux

You may try to use rm -rf [directory] to delete given directory along with all its content (including all subdirectiories and all files). Use this with caution, to not end up deleting all files on your root! :>

Note, that on QNAP (but not on regular Linux) you have to start your session as admin user, as you cannot use su command to become root. If you try this, you’ll end up with error su: user root does not exist.

Tables with multilevel lists inside in Microsoft Word

Tables with multilevel lists inside are rather uncommon element of Microsoft Word documents, but sometimes this is the best solution, you can have. For example, when you need tree-like structure (multilevel list) on the left with additional columns to the right. But, in general, it is harder piece of cake to build and manage them.

Read More “Tables with multilevel lists inside in Microsoft Word”

Introduction to bash scripts

While playing with some extra features on my newly purchased QNAP TS-210 at some point I was forced to finally write some bash script to be able to control things, that are uncontrollable via administration panel. For this reason I had to learn myself at least basics of bash, that is installed on my QNAP. I used floppix page and linuxconfig.org Wiki as a base for my learning process (and source for this article), however I had to write down my own memo-list to be able to quickly find, what I’m looking for.

Read More “Introduction to bash scripts”

No Samba access after password change

Let us understand it. Windows is stupid and idiotic system. Suppose, you store (remember) your NAS’s Samba username and password, so you don’t have to provide it, each time you access your local network share. If you thenchange your user password, Windows either won’t detect the fact that password has changed or, even if it detect it, it won’t show you login/password dialog box to provide new one. Instead, it continue to provide NAS with wrong (outdated) password.

Read More “No Samba access after password change”