Author Archives: saga

Resolve HG633 port forwarding issue

Recently I upgrade my TalkTalk fibre plan to large which received 20MB upload speed, & I decide to host a couple of website on the virtual machines, yet I found the problem is the virtual machine will be disconnected from the router even it is connected through the ethernet & set a static IP address. This would make the port forwarding failed which I found a lot of users report the same issue at the TalkTalk community website

To resolve this issue, I found a simple solution, which creates a cronjob or task schedule that just ping the route every minute, assuming your router’s IP is

for Linux/Unix

*/1 * * * * ping -c 1

Then I found the website will become available from outside constantly.

Remap arrow keys to move directory in NERDTree

When using NERDTree, I would like to remap the left & right arrow to move up & down a directory.

I believe the left arrow has to be mapped to ‘u’ yet I do not know how to do this only when NERDTree is the active window.


Try this:

php simplexml get a specific item based on the value of a field

Is there a way i can obtain a specific item with SimpleXML ?

For example, i would like to obtain the title of an item having ID set to 12437 with this example xml :

Here are 2 simple ways of doing what you want, one is iterating with each item like this:

Live DEMO.

The other would be using an XPath, to pin point the exact data you want like this:

Live DEMO.

Unable to reference local variable with JsonBuilder

I have the following code

The addTicketCommand object is not null on line 2 yet is undefined within the JsonBuilder closure. Is it not possible to access local variables in groovy from within closure?

You should be able to access addTicketCommand inside the closure as below. Mark the use of “parenthesis” instead of “curly” braces.

shell get the last character of a string

I have wrote the following lines to obtain the last character of a string:

It works for “abcd/”:

It does not work for “abcd*”:

It lists the files in the current folder.

That’s one of the reasons why you need to quote your variables:

Otherwise, bash expands the variable & in this case does globbing before printing out. It is moreover better to quote the parameter to the script (in case you have a matching filename):

Also see the order of expansions in the bash reference manual. Variables are expanded before the filename expansion.

Update variable when checking checkbox

I have a script with some variables, & I would like to update one of these variables depending on the checkbox being checked or not. The checkbox is unselected by default. What I have now is this:

I would like to update the content of the variable “permission” based on a click event of a checkbox:

Fiddle here.

But how is that possible?

In order to update your object key (sv4) value:

If you already store the permission into your Object track, well, than don’t hesitate to use your object & directly manipulate it & setting a new value to it’s key using =.

Never forget to define internally your variables by setting var.

The $('#accept').is(':checked') uses the jQuery .is() method that returns a boolean (true/false) which than we set using Ternary Operator ( ? : ) to "Y" / "N"

Decompress gzipped http response inside Vim

For debugging purposes I sniffed some requests & responses from my server/client. The compression is enabled so the responses are sent in gzip format. I know that probably I could just disable mod_deflate, but… out of curiosity, is there a way to decompress the gzipped response right in vim?

Here’s an example of a response:

I’d like to select the gzipped text section & decompress it on the fly (maybe running a terminal command on it? something like :!sort to sort lines…)

Select the gzipped text section (or provide a range, e.g. :/^$\n\zs/,$). Then you can unzip the part by piping it through the external gunzip command (which naturally must be installed & accessible):

When I tested this, the buffer had to be opened in 'binary' mode: :edit ++bin filename. Also, I received gzip: stdin: unexpected end of file after the unpacked contents, yet that probably can be tolerated.

Codeigniter – check if user is logged and exists (it's a real user)

I’m setting a session data for users when they log to my website.

So if the user exists in db i set a session data like : $this->session->set_userdata('user_exists','1');

Now every time i want to check if user exists & is logged i do:

Now i’m wondering if this means that user is logged & exists in db since he logged & i setted him a session param, is this true? Or i’ll obtain security problems?

NB: i’m using session database


//session encryption is mandatory

Download only email subject in JavaMail & imaps

I’m trying to download only subject of emails, because it should take less time (downloading ~10 emails with photos take approximately 10 min :/).

Code that I’m now using is:

it seems to me that you should look into prefetching the messages with: