Tuesday, November 03, 2009

Linux 2.6.31 kernel


Linux 2.6.31 kernel is pants. I'm back to 2.6.28, and will wait for at least a month for the issues to settle down.

Saturday, August 01, 2009

Farewell, Cory

Cannon shots are being fired every 30 minutes at the military base near our house. It surprises the shit out of me, so I wrote a cronjob to warn me of incoming shots:
0,30  *   *   *   *   echo "Incoming cannon shots in 30 minutes." | say -v Vicki
29,59 * * * * echo "Incoming cannon shots in 1 minute." | say -v Vicki

I didn't know Mac OS X speech synthesis feature was scriptable!

Tuesday, June 30, 2009

Saturday, June 27, 2009

Google Moderator part 2

before sending a new page request, the server checks the differences on what the client already has, and what its going to sent. the difference is then compressed and sent, browser on the client patches it. this should provide amazing improvement.


What kind of files? Generating a diff from file A and B, where A and B are totally unrelated files, results in a file which is more or less the same size as B. Therefore, this won't provide "amazing improvement".

Browsers already support caching and HTTP compression.

My idea is to make a giant web where the internet connection is splitted between the people connected so there is no connection wasted, think for example, when somebody with 10 mb/s turns off the pc nobody can use that speed, maybe you can make it :)


QoS.

Governments should aim to provide affordable broadband access for all citizens, in the same way they provide access to affordable water, electricity or shelter.


Government-run ISP? No thanks.

The government needs to subsidize the various brodband access methods out there. Things like Brodband over Power lines, and low orbit satellites. We've spent 7.4 trillion, one would think there is some money in there to fund this stuff.


Government subsidy? Do you know where that money comes from? From taxes, of course. Are you suggesting that people who don't use the Internet will subsidize people who use 1TB of bandwidth per month? Good thinking!

2 ways to make the web faster, 1st one is stopping illegal contents, spams & peer2peer streams, to access & saturate large % of ISPs bandwidth; the 2nd one is replacing the customer's outdated PSTN cables by optic fiber, but how will pay THE BILL ?

Use bandwidth effectively by removing the limits and allocating it to who use them the most,...instead of giving high bandwidth for a person who uses internet just to check an email, give it to someone who runs a webserver...


You want to censor the Internet? Die, communist, die!





Friday, June 26, 2009

Let's make the web faster: Google moderator

Okay, I'm sufficiently annoyed with the ideas posted in Google moderator. Most of the ideas posted there are not new, and they can be implemented with existing technology. The sad thing is, people vote them up.

most websites are templated on the serverside, and for most websites every page you view means about 20% of data transfer is the template. the template should only load once, and should be done in browsers.


You mean like XSL Transformations, which is already implemented in several Web browsers?

P2P browser: Standard browsing is exclusively client/server. Imagine instead that every browser is a P2P app and reports webpage data it downloads to "tracking servers" so when someone else wants the same page they get it from several peers instead


You mean like The Coral Content Distribution Network?

Extend HTML mark-up with new elements. The code will be more complicated because of more elements, but much shorter. Same with CSS - extend number of properties to resolve different tasks by one style property. Reduce size of properties names for CSS


Extend HTML? Oh, so you mean like XHTML, or the Extensible Hypertext Markup Language?

Apache has modules like mod_perl, mod_php and other that allow you to extend the functionality of the browser. While Firefox 'plugins' do that for the frontend, why not make modules for the 'backend' of the browser that enable you to send PHP or Perl


Send what?

Come up with rules which can't be explained by different ways. Like padding in IE and FF - now to make page with same look in all popular browsers you should add more code and CSS which increase size of page and take more time...


You mean like XHTML Strict?

Developers need to comeup with a way to use the already existing information through browoser. Say if it is the same IP packets receiving from the past try to use it and construct the patterns. Avoid duplicate bits to receive. This helps in bandwidth


You mean like using caching settings in the HTTP header?

Many headers that are being sent as part of every HTTP req. and resp, though all HTTP headers are optional. Web servers have to rethink on file naming and their url references. Smaller data to be transported means faster transport.


What kind of rethinking? What kind of URL references? What kind of naming?

And save what, 8 bytes?

Why don't we have an alternative to HTML? I mean open source, anyone can commit changes to the source, and a group oversees which changes are actually put in place. HTML5 will not be released till 2022, and that's when you realize it's ridiculous.


What's ridiculous is that you think HTML is a program.

w3c should regulate the release of browsers. if a browser doesn't pass all the tests for a standard, it should be allowed to call itself a "browser" . because of browsers not following standards, we forcefully hv to implant hacks, and make web slower


Are you a communist?



Wednesday, June 03, 2009

Moo

simoncpu-dev:~# apt-get moo
(__)
(oo)
/------\/
/ | ||
* /\---/\
~~ ~~
...."Have you mooed today?"...
simoncpu-dev:~# aptitude moo
There are no Easter Eggs in this program.
simoncpu-dev:~# aptitude -v moo
There really are no Easter Eggs in this program.
simoncpu-dev:~# aptitude -vv moo
Didn't I already tell you that there are no Easter Eggs in this program?
simoncpu-dev:~# aptitude -vvv moo
Stop it!
simoncpu-dev:~# aptitude -vvvv moo
Okay, okay, if I give you an Easter Egg, will you go away?
simoncpu-dev:~# aptitude -vvvvv moo
All right, you win.

/----\
-------/ \
/ \
/ |
-----------------/ --------\
----------------------------------------------
simoncpu-dev:~# aptitude -vvvvvv moo
What is it? It's an elephant being eaten by a snake, of course.

Tuesday, June 02, 2009

HOWTO Access a VMWare console from Mac OS X or Linux

Problem

There are no VMWare Server clients for Linux and Mac OS X. VMWare provides a Web UI for its server, but it requires a plug-in that doesn't work* on non-Windows platforms.

Solution
  1. SSH into the VMWare Server.
  2. Navigate to the VM folder, and edit the *.vmx file.
  3. Enable VNC by appending the following settings:
    remotedisplay.vnc.enabled = "TRUE"
    remotedisplay.vnc.port = "5900"
    remotedisplay.vnc.password = "foobar"
  4. Start/restart your VM.
  5. Connect to your VM using a VNC client. I'm currently using Chicken of the VNC. You might want to google for a client that suits you.
If you need to connect to multiple VMs, simply use a different port (5900 for display :0, 5901 for diplay :1, etc).

I haven't tried this with VMWare ESX Server. I'll try this in the office tomorrow.

* It somewhat works in Linux.

Thursday, May 28, 2009

HOWTO Import VMWare Fusion disk images to VirtualBox


Here are the steps on importing VMWare Fusion disk images to VirtualBox.

First, create a hard link from your VMWare package.

simoncpu@soulfury:~/Documents/Virtual Machines$ ln -h "Debian Linux.vmwarevm/Debian Linux.vmdk"
You can move or copy it anywhere you want. What's important is that it's accessible outside the original directory because Mac OS X doesn't treat the package as a navigable directory.

Next, create a new VirtualBox VM. In the "Create New Virtual Machine" wizard, select "Use existing hard disk" and open the Virtual Media Manager. Click "Add", and navigate to the hard link that you've created earlier.

Click "Finish" to create your VM. In theory (i.e., I haven't tested this) the OS will now boot at this point as long as you've used an IDE controller from VMWare. If not, then proceed as follows:

Change your VM's settings and go to the Storage tab. Next, check the "Enable Additional Controller" checkbox and select any SCSI controller from the drop down box. In the Attachments section, change your hard disk's slot from IDE Primary Master to SCSI Port 0.

Click OK, and start your VM.

Thursday, April 30, 2009

Process Management in PHP

My PHP script downloads a series of binary patches and places them into a directory for further processing. It also creates lock files to prevent two or more instances of my script from being run.

The Problem

When the script receives a SIGINT (Ctrl+C) or SIGTERM signal from the OS, my script is prevented from cleaning up the temporary files, which usually occupies hundreds of MB of space. The lock files also become stale, so my script prevents itself from being run until the next reboot, when the /tmp directory is cleaned up.

The Solution

The solution is to catch the signals so that my script is given one last chance to perform cleanup:
function sig_handler($signo)
{
switch ($signo) {
case SIGTERM:
case SIGQUIT:
case SIGABRT:
case SIGINT:
echo "==> Software Update has been aborted.\n";
echo "==> Performing cleanup...\n";
cleanup();
exit();

break;
default:
// Unknown signal. Do something here...
exit();
}

}

pcntl_signal(SIGTERM, "sig_handler");
pcntl_signal(SIGQUIT, "sig_handler");
pcntl_signal(SIGABRT, "sig_handler");
pcntl_signal(SIGINT, "sig_handler");

Wednesday, April 29, 2009

tail -F in PHP

I'm currently writing a PHP script that pushes live log data to the front-end UI. I'm using a streaming Comet model such that my back-end would update the front-end's screen every time the log file is updated.

Unix has a nifty utility called 'tail' that can continuously monitor a file for updates and display them to standard output (which is the usually the monitor). By capturing tail's output via popen(), I was able to make a log file viewer with just a few lines:

exec("/usr/bin/killall tail");
// execute myapp in the background and redirect all of its output to logfile
exec("/usr/local/bin/myapp > /var/log/mylogfile.log 2>&1 &");

$handle = popen("/usr/bin/tail -F /var/log/mylogfile.log 2>&1", 'r');
while(1) {
$buffer = fgets($handle);

if (trim($buffer) == '-- ok') { // this string signifies end of execution
pclose($handle);
exec("/usr/bin/killall tail");
exit();
} else {
echo trim($buffer);
// if you're using Comet, push output to the stream here
}

ob_flush();
flush();
}
Very cool...

Wednesday, January 21, 2009

HOWTO Revert your Git repo to a certain commit

Get the SHA1 hash of the commit that you wish to revert to.

% git log

...

commit 9ce5e10ac4fe43e9b580344454dd27172b6c4456
Author: Simon Cornelius P. Umacob
Date: Tue Jan 20 16:30:42 2009 +0800

show/hide icmp6box

commit f193cf92b2c925a2f3f71a713d766efd1e4d81e0
Author: Simon Cornelius P. Umacob
Date: Tue Jan 20 15:52:39 2009 +0800

Merge IPv6 changes

commit 1f9f2a95b7b42cf33e730535092e56e214fdb848
Author: Simon Cornelius P. Umacob
Date: Tue Jan 20 14:55:07 2009 +0800

Merge IPv6 changes

commit ce996bd3014b05fea5eaffd7c738c5c549fd7677
Author: Simon Cornelius P. Umacob
Date: Tue Jan 20 14:30:27 2009 +0800

add IPv6.inc and NetUtils.js

...

% git reset --hard ce996bd3014b05fea5eaffd7c738c5c549fd7677

HEAD now points to ce996bd3...

To go back to the "original" HEAD, find its SHA1 hash and reset your current HEAD to that state.

% git reflog
simoncpu@pfsense:/home/pfsense/simoncpu-IPv6> git reflog
74fb85b... HEAD@{0}: pull git@rcs.pfsense.org:pfsense/mainline.git: Fast forward
9ce5e10... HEAD@{1}: commit: show/hide icmp6box
f193cf9... HEAD@{2}: commit: Merge IPv6 changes
1f9f2a9... HEAD@{3}: commit: Merge IPv6 changes
ce996bd... HEAD@{4}: commit: add IPv6.inc and NetUtils.js
cfc4dab... HEAD@{5}: clone: from http://gitweb.pfsense.org/pfsense/simoncpu-IPv6.git

% git reset --hard 74fb85b

Note that you need not use the full SHA1 string to refer to an object.
The first few characters is enough.

Friday, January 16, 2009

pfSense IPv6

I'm currently merging our IPv6 changes to pfSense by hand so that I can commit our changes upstream once their migration from CVS to git is complete.

"With a thousand eyes, all bugs are shallow", they say. Sharing this code to the world will most likely uncover many bugs and make our code more stable. I just hope that with a thousand eyes, I won't receive a thousand flak from users in case I break something.

I'll probably break something. :)

UPDATE: As of January 16, 2011, development has been stopped. If you wish to continue development, please contact me (simoncpu at gmail.com) or post a bounty. Thanks! :)


(whoah, I realized that this post was made exactly 2 years ago lol)

Friday, January 09, 2009

HOWTO let lighttpd listen to both IPv4 and IPv6 requests on *BSD

Problem
When enabling IPv6 using server.use-ipv6 = "enable", lighttpd no longer listens to IPv4 requests.

Solution
Set a sysctl knob so that it will accept both IPv4 and IPv6 requests:
root@soulfury:~# sysctl net.inet6.ip6.v6only=0