Tag Archives: code

My sysinfo program updated with new code. Even better than before!

http://www.securitronlinux.com/files/sysinfo.kdevelop-1.0.tar.gz.

This is the link to my newly updated sysinfo program. This has code added using the sysinfo struct. This means that the memory and uptime information that is output is actually readable now. This is what the output of the memory and uptime section looks like now.

homer@deusvult:~/Documents/sysinfo.kdevelop-1.0$ ./sysinfo 2
		Ram & swap information.
Filename				Type		Size	Used	Priority
/dev/sdb2                               partition	12287996	0	-1
/dev/sdb5                               partition	2559996	0	-2

System uptime : 0 days, 2:23:45
Total RAM   : 5900.9 MB
Free RAM   : 147.0 MB
Number of running processes : 368

Stackoverflow has been a great help in terms of getting this code to work.

Here is the code section in question. This outputs much more readable output. A great result.

	if (argc > 1 and strncmp(argv[1], "2", BUF) == 0) {
		printf("\t\tRam & swap information.\n");
		kernel("/proc/swaps", 2);

		/* This code from:
		 * http://stackoverflow.com/questions/14345937/sysinfo-returns-incorrect-value-for-freeram-even-with-mem-unit
		 */
		/* Conversion constants. */
		const long minute = 60;
		const long hour = minute * 60;
		const long day = hour * 24;
		const double megabyte = 1024 * 1024;

		/* Obtain system statistics. */
		struct sysinfo si;
		sysinfo (&si);

		/* Summarize interesting values. */
		printf ("System uptime : %ld days, %ld:%02ld:%02ld\n", 
		    si.uptime / day, (si.uptime % day) / hour, 
		    (si.uptime % hour) / minute, si.uptime % minute);
		printf ("Total RAM   : %5.1f MB\n", si.totalram / megabyte);
		printf ("Free RAM   : %5.1f MB\n", si.freeram / megabyte);
		printf ("Number of running processes : %d\n", si.procs);


	}

A nice sample of code that will render a spiral on your terminal screen. This could be useful indeed.

This code sample will render a spiral on your terminal when you compile and execute it. Very interesting indeed.

#include <sstream>
#include <iostream>
#include <string>

std::string rle =
"32 2@14 1n16 11@9 2@10 1n13 3@13 3@8 1@7 1n10 2@21 2@7 1@5 1n7 2@27 1@6 1@4 "
"1n6 1@10 10@10 2@5 2@2 1n4 2@7 4@9 4@9 1@5 1@2 1n3 2@6 3@15 3@8 1@5 1@1 1n3 "
"1@6 2@18 3@7 2@5 1@1n2 1@6 2@20 3@7 1@5 1@1n2 1@5 2@21 3@7 1@5 1@1n1 2@5 2@2"
"1 3@7 1@5 1@1n1 2@5 2@11 3@6 3@8 1@5 1@1n2 1@5 2@11 11@8 2@5 1@1n2 1@6 2@11 "
"8@9 2@5 1@1 1n3 1@6 2@26 2@5 2@1 1n3 2@6 2@24 2@5 2@2 1n4 2@6 3@20 2@6 2@3 1"
"n6 1@8 3@14 3@7 1@5 1n7 2@9 13@9 2@6 1n9 2@27 1@9 1n12 3@19 3@11 1n16 5@7 4@"
"16 1n22 5@21 1n";

int main()
{
	std::stringstream ss(rle);
	while (!ss.eof())
	{
		int n = 0;
		while (ss.peek() >= '0' && ss.peek() <= '9')
		n = n * 10 + ss.get() - '0';
		char c = ss.get();
		while (0 < n--)
			std::cout << (c != 'n' ? c : 'n');
		}
}

Very cool code that prints a tick sign in asterisks. This is awesome C++ code.

This code prints out a tick sign using asterisks. I tested this code on Fedora 19 and gcc 4.8 and it compiles without any problems.

#include <iostream>
#include <iomanip>

using std::cout;

int main() {

	cout<<std::setw(8)<<"*"<<"n";
	cout<<std::setw(7)<<"*"<<"n";
	cout<<std::setw(6)<<"*"<<"n";

	cout<<"*  *"<<"n"<<"* *"<<"n"<<"*";
	cout<< "n";

	return 0;
}

This is what you should get when you compile and run this code sample.

homer@neo $ ./loop 
       *
      *
     *
*  *
* *
*

Very cool indeed.

Ralph using a computer.

Useful code snippets and commands for Linux.

Alternatives to the ping and traceroute commands on a Linux system.

There are many alternatives to the ping and traceroute commands on a Linux system. The mtr command is one of them. This command will trace the route the network packets are taking to the target IP address.

bash 06:42:02 Mon Jul 22 [homer@deep-thought $ mtr 8.8.8.8

This code will ping a server and use tcp, udp, icmp, stream, and syn packets to do so. This is useful to see if a server is up, but they block icmp packets, this script will work regardless of this and still allow you to see if the server is up or not. Good if you are behind a proxy at a college or something like that. There is also a tcpping command for Linux that can work when you are behind a restrictive firewall. There is some information about this here: http://xmodulo.com/2013/01/how-to-install-tcpping-on-linux.html.

#!/usr/bin/perl

use warnings;
use strict;

use Net::Ping;

# code source: http://www.perlmonks.org/?node_id=943892
# More: http://stackoverflow.com/questions/3960595/how-can-i-ping-a-host-with-a-perl-one-liner-with-netping

#$| = 1;
print "Please type a host to check: -:\n";
my $host = <>; #Reading input from STDIN.

if (length($host) < 3) {
    print "You did not type a host!\n";
    exit(0);
}

my @proto = ("tcp", "udp", "icmp", "stream", "syn");

foreach my $pro ( @proto ) {
    print "#-Protocol $pro \n";
    my $p = Net::Ping->new($pro);
    chomp($host);
    # Specify source interface of pings
    print "$host is ";
    print "NOT " unless $p->ping($host, 2);
    print "reachable.\n";
    $p->close();
}

exit(0);

This is a good alternative for tracing the route taken from one host to another.

homer@deep-thought ~ % sudo tcptraceroute 127.0.0.1
[sudo] password for homer: 
traceroute to 127.0.0.1 (127.0.0.1), 30 hops max, 60 byte packets
 1  localhost (127.0.0.1) <syn,ack>  0.031 ms  0.004 ms  0.005 ms

This is how to ping the TCP port of a remote host. This is using the netcat tool.

homer@deep-thought ~ % nc -zvv yahoo.cn 80
Connection to yahoo.cn 80 port [tcp/http] succeeded!

The hping3 command on Linux Mint 15 is very useful for sending TCP packets to a remote host to test the configuration of the server.

Type this command to install this utility: sudo apt-get install hping3.

And this is the output you get when you are pinging the Yahoo website with hping3.

bash 09:32:38 Mon Jul 22 [homer@deep-thought $ sudo hping3 -S -p 80 yahoo.com
HPING yahoo.com (eth1 206.190.36.45): S set, 40 headers + 0 data bytes
len=46 ip=206.190.36.45 ttl=112 id=51335 sport=80 flags=SA seq=0 win=8192 rtt=208.4 ms
len=46 ip=206.190.36.45 ttl=110 id=53804 sport=80 flags=SA seq=1 win=8192 rtt=197.2 ms
len=46 ip=206.190.36.45 ttl=110 id=56362 sport=80 flags=SA seq=2 win=8192 rtt=211.5 ms
len=46 ip=206.190.36.45 ttl=110 id=58939 sport=80 flags=SA seq=3 win=8192 rtt=211.0 ms
len=46 ip=206.190.36.45 ttl=110 id=61474 sport=80 flags=SA seq=4 win=8192 rtt=197.5 ms
len=46 ip=206.190.36.45 ttl=112 id=64019 sport=80 flags=SA seq=5 win=8192 rtt=195.7 ms
len=46 ip=206.190.36.45 ttl=112 id=998 sport=80 flags=SA seq=6 win=8192 rtt=194.8 ms
len=46 ip=206.190.36.45 ttl=112 id=3556 sport=80 flags=SA seq=7 win=8192 rtt=210.2 ms
len=46 ip=206.190.36.45 ttl=112 id=6243 sport=80 flags=SA seq=8 win=8192 rtt=210.6 ms
len=46 ip=206.190.36.45 ttl=110 id=8839 sport=80 flags=SA seq=9 win=8192 rtt=197.2 ms
^C
--- yahoo.com hping statistic ---
10 packets transmitted, 10 packets received, 0% packet loss
round-trip min/avg/max = 194.8/203.4/211.5 ms
Ralph using a computer.

Ralph using a computer.

Wrapping the printf() statement onto multiple lines in C and some other useful samples.

This code sample shows how we are wrapping a printf() statement onto multiple lines using backslashes.

#include "stdio.h"

#define hello "Hello World."

int main(int argc, char* argv[])
{
	printf("This is a very long sentence we are handing down\n"\
		   "Mr smith, do you have anything to say for yourself"\
		   "?");

	printf("%s\n", hello);

	return 0;
}

This is the most obfuscated version of the C “Hello World” program that I could find.

#include 

#define e 3
#define g (e/e)
#define h ((g+e)/2)
#define f (e-g-h)
#define j (e*e-g)
#define k (j-h)
#define l(x) tab2[x]/h
#define m(n,a) ((n&(a))==(a))

long tab1[] = { 989L, 5L, 26L, 0L, 88319L, 123L, 0L, 9367L };
int tab2[] = { 4, 6, 10, 14, 22, 26, 34, 38, 46, 58, 62, 74, 82, 86 };

main(m1, s)
char *s;
{
	int a, b, c, d, o[k], n = (int)s;
	if (m1 == 1) {
		char b[2 * j + f - g];
		main(l(h + e) + h + e, b);
		printf(b);
	} else
		switch (m1 -= h) {
		case f:
			a = (b = (c = (d = g) << g) << g) << g;
			return (m(n, a | c) | m(n, b) | m(n, a | d) |
				m(n, c | d));
		case h:
			for (a = f; a < j; ++a)
				if (tab1[a] && !(tab1[a] % ((long)l(n))))
					return (a);
		case g:
			if (n < h)
				return (g);
			if (n < j) {
				n -= g;
				c = 'D';
				o[f] = h;
				o[g] = f;
			} else {
				c = '\r' - '\b';
				n -= j - g;
				o[f] = o[g] = g;
			}
			if ((b = n) >= e)
				for (b = g << g; b < n; ++b)
					o[b] = o[b - h] + o[b - g] + c;
			return (o[b - g] % n + k - h);
		default:
			if (m1 -= e)
				main(m1 - g + e + h, s + g);
			else
				*(s + g) = f;
			for (*s = a = f; a < e;)
				*s = (*s << e) | main(h + a++, (char *)m1);
		}
}

This is a program that writes to a text file. You are of course free to use this code in your own projects.

#include 
#include 

#define EQ ==
#define log "hello.txt"

int main(int argc, char *argv[]) {

	int x;

	x = 0;

	FILE *f;
	char Kyo[40];
	int Fsize;
	f = fopen(log, "w");
	Fsize = sizeof(f);
	if(!f) {
		printf("Sorry, I cannot open: %s.\n", log);
		exit(1);
	} else {

		while (x < 100) {
			fprintf(log,"*");
			if (x EQ 50) {
				fprintf(log,"-\n-");
			}
		x++;

		}
		fprintf(log, "\n\x78*----* Done. *----*\x78\n");
	}
	fclose(f);

	return 0;
}

Miscellaneous Perl programming information. How to use for loops and printing HTML properly.

Opening a folder and listing the contents, and not listing certain files. This is the Perl code I was using on my very old Tripod.com website.

opendir(DNAME, "$folder") || die "I cannot open the requested directory $folder \n $!";
@dirfiles2 = readdir (DNAME);
@dirfiles2 = sort(@dirfiles2);
foreach $x2 (@dirfiles2) {
    if ($x2 eq ".") {
	$x2 = ' ';
    }
    if ($x2 eq "..") {
	$x2 = ' ';
    }
    if ($x2 =~ /REMOVED/) {
	$x2 = ' ';
    }
    if ($x2 eq ".cgiclean") { # What is this?
	$x2 = ' ' ;
    }
    if ($x2 eq ".htaccess") {
	$x2 = ' ';
    }
    if ($x2 eq "$archive") {
	print "\n";
    } else {
# Simple hack to weed out those annoying zero length() strings...
	if (length $x2 > 3) {
	    print "\n";
	}
    }
}

closedir(DNAME);

How to get the date and time with Perl scripting. All you need to do is print “$date”; and you are done.

my @Days = ('Sunday','Monday','Tuesday',
	    'Wednesday','Thursday','Friday',
	    'Saturday');
my @Mon1 = ('January','February','March',
	    'April','May','June',
	    'July','August','September',
	    'October','November','December');

my ($Sec,$Min,$Hour,$MDay,$Mon,$Year,$WkDay) = (localtime)[0,1,2,3,4,5,6];
$Year += 1900;
if($Sec < 10) {
    $Sec = "0$Sec"
};
if($Min < 10) {
    $Min = "0$Min"
};
if($Hour < 10) {
    $Hour = "0$Hour"
};

$date = "$Hour:$Min:$Sec - $Days[$WkDay] $MDay $Mon1[$Mon] $Year";

Here is an example showing how to do a for() loop in Perl.

for ( $i=  0; $i <  32; $i++) {
	print "*";
}

This comprehensive script will print a HTML page to the terminal when you run it. This is a good starter for writing a CGI script that will print out its own HTML. This is using the CGI.pm module. This also sets a cookie containing the date that expires in 3 days.

#!/usr/bin/perl

use CGI qw/:standard -nosticky/;
my $query = new CGI;

print $query->header(-type=>'text/html',
		     -expires=>'+3d',
		     -cookie=>$date,
		     -charset=>'UTF-8');

print $query->start_html(-title=>'CGI Viewblog CGI Script.',
			 -meta=>{'keywords'=>'Blog Doom2 Level Editing Linux Doom',
				 'copyright'=>'Copyright 2004 John Cartwright.',
				 'definition'=>'General Viewblog Script.',
				 'Appeal'=>'Wide',
				 'description'=>'CGI Viewblog Script.'},
			 -BGCOLOR=>'#FFFFFF',
			 -TEXT=>'#000000',
			 -LINK=>'#888fff');

print $query->h1("CGI HTML Script.\n");

print $query->p("This script prints HTML to the terminal.\n");

print $query->end_html;

Finally, this code will write some information to a log file.

open FILE, ">> log.txt" || die "I cannot open the file: log.txt:\n $!\n";
print FILE "Visited: $date\n";
if ($user_ref) {
    print FILE "Referrer URL: $user_ref.\n";
}
print FILE "Users Browser: $user_agent.--\n\n";
close FILE;

Useful old C code of mine. Might be useful for reference.

This is a nice little program I wrote ages ago.

/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/

/********************************************************************
* Description:
* Author:  
* Created at: Wed Jan 19 13:06:21 EST 2011
* Computer: myhost
* System: Linux 2.6.33-ARCH on x86_64
*
* Copyright (c) 2011   All rights reserved.
*
********************************************************************/

#include 
#include 

#define format "At this time: %H:%M:%S"
#define text "OP is a Troll."

int lineofstars (void) {
	int x = 0;
	while (x < 64) {
		printf("*");
		x++;
		if (x == 31) {
			printf("<|>");
		} else if (x == 64) {
			printf("\n-\n");
		}
	}
	return 0;
}

int main (int argc, char** argv) {

	lineofstars();

	char *File;
	char String[60];
	struct tm *ptr;
	time_t tm;
	char length[60];

	tm = time(NULL);
	ptr = localtime(&tm);
	strftime(length, 100, format, ptr);

	File = "log.txt";
	snprintf(String, 100, "%s, %s\n", length, text);

	FILE *f;
	f = fopen (File, "a+");

	if (!f) {
		printf("Sorry, I cannot open the file %s.\n", File);
		return 0;
	}

	fprintf(f, String);

	fflush(stdout);
	fclose(f);

	return 0;
}

Miscellaneous programming tricks with C.

This is a very simple Hello World program in C.

int main() {
	write(1, "Hello World\n", 14);
}

Counting how long a text string is.

#include 
#include 
#define MSG "Hello Doctor, let's get back to the TARDIS!"
int main() {
int g;
g = strlen(MSG);
if (g < 1) {
printf("The string is not very long!\n");
} else {
printf("The length of the string `MSG' is: %i characters.\n", g);
}
return 0;
}

Code sample to check for a certain argument to a C program. using strncmp() to read from the argv[1], which is the first argument to the C program and checking if it contains the value “2″. And the value BUF sets the maximum length of the string expected.

if (argc > 1 and strncmp(argv[1], "2", BUF) == 0) {
	printf("\t\tRam & swap information.\n");
	kernel("/proc/swaps", 2);
	printf("-Uptime: ");
	kernel("/proc/uptime", 2);
	kernel("/proc/meminfo", 2);
}

More code from my sysinfo C program that reads in files and processes them accordingly.

#ifndef SYSINFO_H_
#define SYSINFO_H_

#define BUF 0x05

/*
 * Function prototypes. Sexy... And unlike on the show `24', function
 * prototypes have nothing to to with hard disk sectors!
 */

void kernel(char,int);

/*
 *  @brief  /proc file opener
 *  @param  File  An output stream.
 *  @param  len  A string length.
 *  @return  none.
 *  @pre  @a len must be a non-NULL int.
 * I hope this little function is not offending anyone. it is the only
 * way I could think to have a single function that would be able to 
 * load the different files quickly and without fuss. And it works just
 * fine, and that is what matters in the end.
 */

struct _kern1 {
	char *File;
	int len;
	char Kyo[40];
} *kern1 = (struct _kern1 *) 0x80;

void kernel(const char *File, int len)
{
	FILE *f;
	char Kyo[40];

	if (len > 10 or len < 2)
		return;

	f = fopen(File, "r");
	if(!f) {
		printf ("Sorry, I cannot open: %s.\n", File);
		printf("Please check your permissions with\n"		\
			"your supervisor. The feature may not\n"	\
			"be compiled and\\or enabled in your\n"		\
			"kernel version. Or a scsi device, eg,\n"	\
			"a USB drive may not be attached.\n");
		return;
	} else {
/* Based on sample code from:
 * www.koders.com/c/fid84CFEFBF311605F963CB04E0F84A2F52A8120F33.aspx
 * Specifically the section on parsing the /proc/version.
 */
		while (feof(f) != 1) {
			fgets(Kyo, len, f);
			if (strncmp(Kyo, "((", 1) == 0)
				printf ("\n-");
			if (strncmp(Kyo, "#", 1) == 0) {
				printf ("\nVersion: #");
			} else {
/*
 * This function is fast, owing to this i feel. especially with gcc 
 * 4.3.2 & glibc 2.5+. it is faster than using: printf (Kyo);
 */
				fprintf (stdout, "%s", Kyo);
			}
			fflush(stdout);
		}
	}
	fclose(f);
}

#endif /* sysinfo.h */

Linux kernel 3.3 released, including some Android code?


The Linux kernel 3.3 has been released and among other features that have been included, there is some code from Google Android included. This is an interesting development, this does not mean that you can run Angry Birds on a Debian or Linux Mint system, but this could lead to something cool in the future. The Linux kernel is a free kernel that makes up a free operating system called Linux. The whole operating system is sometimes called Linux, but Linux is only the kernel, you could build a UNIX operating system using the GNU Coreutils, gcc, and Xorg, but have a different kernel maybe one you developed with your own team of developers and then you could distribute that as something else. FreeBSD uses Coreutils, gcc and the same software available on Linux distributions like Ubuntu, but FreeBSD uses a different kernel and a different executable format. The FreeBSD kernel is available for Debian with Debian KFreeBSD, that is an interesting idea, I prefer the Linux kernel, the hardware support is pretty good now, the need for binary firmware will not go away anytime yet, but at least you have a reasonable expectancy that the WIFI dongle you have bought will work with Linux. Netgear is a good brand. I am having some problems with my Internet connection right now, but I am wanting to try Debian Stable again.

The Linux kernel is truly a massive achievement, it would have cost a staggering, amount if a major corporation had developed the Linux kernel instead of a worldwide network of kernel hackers that have helped develop the Linux kernel and get this kernel to the state that is right now. There are many devices in the world that are running the Linux kernel including the Android operating system that is using the Linux kernel to provide a Linux powered operating system, as an alternative to Symbian and IOS. The Apple Macintosh operating system is built on top of the Darwin UNIX operating system kernel, the Darwin kernel is free to download, the interface and software placed on top of the underlying UNIX kernel is what you are actually paying for. I downloaded the Darwin operating system ISO, burned it to a DVD  and tried to boot it on a PC, but it would not boot, I just got an error. I guess that I need the expensive hardware to run the Darwin operating system, but I could just run OpenBSD  or FreeBSD if I wanted a UNIX operating system to experiment with. FreeBSD has the standard Linux Gnome desktop, the Desktop BSD live disc has a nice desktop as well, but the BSD desktops are lacking GEM/KMS support at the moment, something we take for granted with Linux. But this is coming slowly but surely. I might consider switching to FreeBSD if they added V4l support as well.

My PHP code for my Linux pages index.

This code is on my http://securitron.securitronlinux.com page. It shows a random image and a random webpage link.
<?php
$time = strftime(“%A %d %B %Y. %r – %Z”);
srand(time(NULL));
$day = rand() % 6;
$string = sprintf(“<font size=\”2pt\”><p>Welcome to my website.</p>\n”);
$links = array(“BejArray” => array(“0″ => “perl_code.php”, “1″ => “psx_doom.php”,
“2″ => “cgi_code.php”, “3″ => “doom_wadfiles.php”,
“4″ => “my_linux_system_2.php”, “5″ => “linux_configs.php”,
“6″ => “my_linux_system.php”
));

echo $string;

switch($day) {
case 0:
$string2 = “Perl CGI Code”;
break;
case 1:
$string2 = “PSX Doom goodness”;
break;
case 2:
$string2 = “Misc programming code”;
break;
case 3:
$string2 = “My Doom wadfiles”;
break;
case 4:
$string2 = “My Linux system tips part 2″;
break;
case 5:
$string2 = “My Linux configuration tips”;
break;
case 6:
$string2 = “My Linux system tips part 1″;
break;
default:
$string2 = “Take pot luck”;
}

printf(“<p>Random page: <a href=%s>%s</a>.</p>\n”, $links["BejArray"][$day], $string2);
printf(“<p>Welcome to my GNU/Linux pages. Server time is: %s.</p></font>”, $time);
echo “<img src=\”maps/00$day.png\” width=\”320\” height=\”200\” alt=\”Random Doom screenshot.\” style=\”float:right;padding: 8px\”>”;

?>

Good Firefox 11.0 setup for safer web browsing.

Good Firefox 11.0 setup for safer web browsing.

The Firefox web browser truly is a very good and safe browser for everyday use, but with the addition of some extensions, the browsing experience can be made even more secure. Firstly, the Noscript extension is the best and most useful extension for blocking web scripts that can perform malicious actions against your browser.

Secondly, the Ghostery extension will further block tracking code embedded in the HTML code of web pages, as well as the 1×1 pixel tracking images that are sometimes embedded in web pages to track user visits. This extension will pop up a small purple dialog that will display the blocked content on a website. This extension as with Noscript allows you to whitelist a domain that you trust whilst automatically blocking tracking code as you browse the Internet.

The Adblock extension allows the Internet user to block web ads they find annoying. This extension has drawn some criticism from web masters for a reduction in ad revenue caused by the blocking of Adsense advertisements on web pages, but if someone is blocking ads, they were not interested in clicking the advertisement and making a purchase anyway, so that is a moot point. This extension may also be used to block certain elements on a web page, such as an Iframe or large annoying logos on the website, making subsequent visits faster. A very useful plugin indeed.

[My Firefox 11.0 toolbar. Showing the extensions I have installed.

The LinkExtend extension for Firefox gives you a Google toolbar styled toolbar that displays the pagerank of a website and the SiteTraffic rating as well. Above you may see a screenshot of this toolbar in action, you can also see the Ghostery popup and the icons for Adblock and Ghostery on the Firefox 11.0 toolbar. I can not get the Google toolbar to install with Firefox 10.0 or Firefox 11.0, so this is a good alternative.

Flashblock is another good extension that is invaluable when you are browsing a PHPBB message board and someone posts a long post with about 30 Youtube embeds in it, that can really slow down the page. With this extension installed, you do not need to worry at all about all of that loading at once. This will replace all of those video embeds with a button that will allow you to enable the flash embed and play the video if you want, putting control back in your hands. and it will block those annoying hidden flash embeds that play repeating music when the website loads. Some imageboard websites are notorious for that.

Firefox eating the competition.

Firefox eating the competition.

Internet Explorer 9.0 has a good script blocking feature built into the browser, you have to add some Tracking Protection Lists to the web browser using the inbuilt tracking protection system in the web browser. But since I am no longer using Windows it is strictly Feuerfuchs for me. Even the old Mozilla 1.7 web browser was better than Internet Explorer 6.0, that is still being used these days even though it is totally insecure. Firefox with these extensions installed is far more secure and reliable. The Ghostery extension will block facebook tracking as well as other nasty stuff. Just whitelist some blocked elements if the website you are using appears to break.

Finally Downloadhelper is an extension that allows the user to download video content from Youtube and other video sharing websites. This can be useful if you wish to download the video you are watching to enjoy later on. I do not see the downside to talking about this extension, what is the difference between watching a music video online and being able to download it for your personal use? This extension also allows you to download pictures from a website as well.

Useful C++ snippet. A better way to read in a sentence with STDIN.

Tsar Bomba on a car. A misfire?

Tsar Bomba on a car. A misfire?

This is a very useful C++ code snippet for reading in a line of text into STDIN. Hopefully this will be useful to someone.


#include <iostream>
#include <string.h>
#include <sstream>

using namespace std;

int goku(void) {
cout << "Hello, Please enter your name.\n" << endl;
return 1;
}

int main(int argc, char **argv) {

goku();

string name = "";
getline(cin, name);

cout << "Welcome "<< name << ".\n"<< endl;

return 0;
}

I have just installed the linux xdoom source code on Linux.

I have just installed the linux xdoom source code and I have managed to compile this code. I got it to run on my Debian 3.1 laptop, but I need to set up X Windows with a 256 color pseudo color display to get it to run. That seems like a lot of trouble to go to to get this running, but this code is pretty old. I am happy that I got it going at all. I mean this is the precursor to Prboom Doom Legacy and Zdoom that we know and love these days. Oh, well as I said the code is very old, I guess the age of this code is showing, but I just had to get this running to see how it would work. But I would rather use prboom or zdoom, This code would be just like the Doom2 v1.666 game in action I would think. But if there was a way to patch the code to allow running at high resolutions in a window or fullscreen in X then I would be very happy indeed. Building a binary for Linux with full Doom v1.9 compatibility would be the best thing, better than running doom2 with dosemu. Once I fix the problem with the video, I can conconcentrate on fixing other problems with the code. I should get the sound server code as well and get this working, that will make the game a little more entertaining. Just been working on Nexus of Evil for Doom2 and I have made the level a little easier and added more health and the Cyber platforms now lower, allowing them to be used to clear out the monsters in the citadel yellow key area. Some people have complained that this map is too hard, but I stand by it. Anyway, if you think this map is hard, try to play Hell Revealed MAP32 or Plutonia MAP22 coop… The afforementioned MAP32 HR is goddamn impossible, you fight 2 Archies right at the start of the map.

It is actually harder than HR2 MAP32 which has 1651 monsters in UV. Although I have made an extreme map of my own which has more than 2800 monsters, but that is not really playable by mere mortals. But I am just about skilled enough to do MM2 MAP32 easily, I can do Community Chest MAP19 in UV as well. Having JBL taunting Batista is not the smartest move when he is coming to Smackdown to smash in every window of your expensive limo.

But I cannot wait for the barbed wire steel cage match at No Way Out! The 470 pound giant the Big Show up against John Bradshaw layfield in a match to end all matches. I cannot wait to see what will happen in this matchup. If batista comes to Smackdown, then the current US champion John Cena can challenge him for the US championship. They both respect each other so there would be quite some showmanship in that match. Batista vs Luther Reigns would be even better, He thinks his so tough, but the Undertaker scares him, so what about a 318 pound animal like Batista. And there is Mohammed Hassan, the Arab-American who is conflicting with the Ayatolla of Rock ‘n Rolla Chris Jericho. Their battles are very funny with Jericho calling Jabari Hassan’s special little valentine :). But with JBL’s limo coming to RAW and trying to run over Batista what did he expect!

Coming back to xdoom, the features that it has namely laser barriers and horizontally sliding doors would be very good if they were in the prboom source code, then it would beven better. It should be very easy to put these into the lxdoom or prboom source code and make something very special indeed. I am loving the Boom features but I just love to hack on the Lxdoom code and so it should be easy to put in some more features into the codebase. I could make my own personalised source port building on the good work of the authors of our favourite source port. I have unpacked the lxdoom-1.4.4 source code and I have built this source port. This works very well running at 640-400 and I will certainly be hacking on this code as I get more aquainted with the inner workings of the lxdoom source code. I will be comparing the lxdoom source with the xdoom source code to see if I can improve the code somehow. Then I can build the perfect source port that I have always wanted. The Zdoom .93 source code is always a possibillity, but that is very hard to get working. With lxdoom, all you need to do is type the standard ./configure, make then make install-strip to install the program. With Zdoom it is a nightmare of autoconf and messing about with diff patches to get the code to a workable state. It should not be that hard at all, I am trying to compile it on Debian and I have to compile a new version of autoconf just to get this working. I wish I could just get it to work, I want to do some hacking on the code and maybe improve it somewhat. Oh, well, maybe I should just stick with lxdoom.

I have been playing prboom in coop and I was disappointed that there did not seem to be any coop monsters in MAP31 Doom2. It would have been cool with a Spider Mastermind ;). But TNT MAP28 & Plutonia MAP32 are very wild and challenging levels to play if you like to fight many Cybers and Revenants. But Plutonia MAP22 is the king of the levels. I can get through half of this map, but when I drop down the hole into the nukage area there are 4 Cybers and countless chaingunners to fight!. Sure this is wild and carefree, but how are you supposed to fight this many monsters at once! Now if only I could do HR MAP32. I wish I knew why I had problems compiling the lxdoom source on Mandrake 10.0, but it worked so well on Debian. Mandrake’s include files are problematic, but that is what you get for using the download version. But I was trying to fix a Windows XP machine today, a machine running Windows XP `Professional` and this machine was totally drokked to say the least. The network had disappeared and also the dial up connection as well had just disapeared for no apparent reason. It was setup again but it still would not dial at all. Some virus scanning was done by the idiot in charge, but the problem was not that at all but the Service Pack 2 `Modifications` to the system. Somebody should be shot for releasing this crap into the wilds. If this was my machine, `which it would not be!` I would be really upset and shouting obscenities to the Microsoft Tech Support people. Since it is their fault for this patch after all. I would be rampaging through the streets with a shotgun taking names at the local Microsoft outlet.

Everyone who runs XP must be an idiot, I would never run this shit! Why bother with the Microsoft Windows XP Service Pack 2, I am sure that it can be bypassed by a determined cracker. It would not take much at all. In the old days there was Back Orifice for hacking Windows and now there are many ways to hack into Windows I am sure. It would not take much effort to hack into an OS that has so many security holes. At least Debian 3.0 and Mandrake Linux 10.0 are far more secure than Windows XP. I shudder to think about Windows Longhorn. There would be about 2TB of data with this OS so how many security holes would there be in this amount of data? Oh, well at least my Debian laptop always works without mysterious failures of various drivers. On the XP system in question, the sound stopped working for some reason, the device manager reported it as working fine hardware wise yet there was an exclamation mark next to the sound device reporting it as having a problem which was that the drivers were corrupted! The network was also not working at all, something to do with corrupted drivers. Why the fuck would anyone put up with this at all? I would rather use Debian as that is easier to setup than Windows XP which uses the complex Registry to keep track of software installation. On a RPM based system such as Mandrake, you type ‘rpm -q foo’ to see what version of package ‘foo’ is installed. This is much simpler. Windows XP can have programs loading at startup that you cannot find anywhere in the registry at all, yet they are running at startup.

In Linux you have control over which programs and services are running at startup and can manage this to customise the system, which is very important for security purposes. And if you want to find files on your filesystem you can just type ‘locate foo’ to find file ‘foo’. This is much better than the Windows XP search function which I find to be frustrating to use. I much prefer to use the BASH shell whenever possible. And using VIM and VI is a lot better than using Notepad. And using the DOS Shell to navigate the filesystem and execute commands can be frustrating, as unlike Freedos it only uses tab key for autocompletion of files and not commands. I would not expect anything better from Microsoft though, they cannot do any better at all.

Not the best example from Microsoft, I hope Windows Longhorn is a little better, I cannot wait to see this new OS, when it is released it will set a new standard for System Requirements and people everywhere will be rushing to upgrade their machines with new boxes from Harvey Norman. The thing I hate about Windows is that you need to install heaps of software upon finishing the installation just to do more than run Minesweeper and Notepad. And Window Maker and Enlightenment are better desktops than the Explorer interface. I have just found out that the Knoppix hard drive installation of Debian 3.1 has Apache installed. Pages go in /var/www and scripts ‘Perl’ go in /usr/lib/cgi-bin I have put a copy of my CGI Guestbook script in the directory and it works perfectly.

So it has mod_perl and mod_ssl so you could develop CGI Perl scripts on a Knoppix installation and test them too! just run `apachect1 start` to start up the apache server as it does not start at boot, although this is easily solved. But for testing CGI scripts this would be very useful. And I have my Debian CD’s so I can type `apt-get install apache` and update my server with the packages from debian-stable. Fucking Windows has nothing on Debian for cool software. I have been trying to get freedos working on my desktop machine recently, I formatted & partioned the hard drive and installed the dosemu files but every time I try to load it it crashes! Some problem with the command.com or the kernel.sys or something. But it should be easier than this for sure, I need a DOS environment but if I can get dosemu working, I will not need to partition and format a hard drive just for this.