All of the interesting technological, artistic or just plain fun subjects I'd investigate if I had an infinite number of lifetimes. In other words, a dumping ground...
Tuesday, 6 November 2007
C++ algorithm examples
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
/* count_if */
void count_if() {
int nums[] = { 0, 1, 2, 3, 4, 5, 9, 3, 13 };
int start = 0;
int end = 9;
int target_value = 3;
int num_items = std::count_if( nums+start,
nums+end,
std::bind2nd(std::equal_to<int>(), target_value) );
std::cout << " nums[] contains " << num_items << " items matching " << target_value << std::endl;
}
/* accumulate */
void accumulate() {
int nums[] = { 0, 1, 2, 3, 4, 5, 9, 3, 13 };
int start = 0;
int end = 9;
int target_value = 3;
int num_items = std::accumulate( nums+start,
nums+end,
target_value);
std::cout << " accumulate result: " << num_items << std::endl;
}
/* adjacent_difference */
void adjacent_difference() {
int nums[] = { 0, 1, 2, 3, 4, 5, 9, 3, 13, 0 };
int start = 3;
int end = 4;
int result = 0;
std::adjacent_difference( nums+start,
nums+end,
&result);
std::cout << " adjacent_difference: result: " << result << std::endl;
}
/* adjacent find */
void adjacent_find() {
std::vector<int> v1;
for( int i = 0; i < 10; i++ ) {
v1.push_back(i);
// add a duplicate 7 into v1
if( i == 7 ) {
v1.push_back (i);
}
}
std::vector<int>::iterator result;
result = std::adjacent_find( v1.begin(), v1.end() );
if( result == v1.end() ) {
std::cout << " Did not find adjacent elements in v1" << std::endl;
} else {
std::cout << " Found matching adjacent elements starting at " << *result << std::endl;
}
}
/* binary_search
Note: list has to be in order beforehand for it to work
*/
void binary_search()
{
int nums[] = { -242, -1, 0, 5, 8, 9, 11 };
int start = 0;
int end = 7;
for( int i = 0; i < 10; i++ ) {
if( std::binary_search( nums+start, nums+end, i ) ) {
std::cout << " nums[] contains " << i << std::endl;
} else {
std::cout << " nums[] DOES NOT contain " << i << std::endl;
}
}
}
/* copy */
void copy()
{
std::vector<int> from_vector;
for( int i = 0; i < 10; i++ ) {
from_vector.push_back( i );
}
std::vector<int> to_vector(10);
std::copy( from_vector.begin(), from_vector.end(), to_vector.begin() );
std::cout << "to_vector contains: ";
for( unsigned int i = 0; i < to_vector.size(); i++ ) {
std::cout << to_vector[i] << " ";
}
std::cout << std::endl;
}
/* copy_backward */
void copy_backward()
{
std::vector<int> from_vector;
for( int i = 0; i < 10; i++ ) {
from_vector.push_back( i );
}
std::vector<int> to_vector(15);
std::copy_backward( from_vector.begin(), from_vector.end(), to_vector.end() );
std::cout << "to_vector contains: ";
for( unsigned int i = 0; i < to_vector.size(); i++ ) {
std::cout << to_vector[i] << " ";
}
std::cout << std::endl;
}
int main ()
{
count_if();
accumulate();
adjacent_difference();
adjacent_find();
binary_search();
copy();
copy_backward();
return 0;
}
The Curse of Xanadu
By Gary Wolf
It was the most radical computer dream of the hacker era. Ted Nelson's Xanadu project was supposed to be the universal, democratic hypertext library that would help human life evolve into an entirely new form. Instead, it sucked Nelson and his intrepid band of true believers into what became the longest-running vaporware project in the history of computing - a 30-year saga of rabid prototyping and heart-slashing despair. The amazing epic tragedy.
Ten Tips for a (Slightly) Less Awful Resume
Today's scientific question is: why are the resumes of programmers so uniformly awful? And how do we fix them? The resumes, that is.
If you've spent more than approximately seventeen kiloseconds as an industry programmer, you've had to review bad tech resumes. It's just part of the job. Programmer resumes ultimately have to be gauged by programmers — it takes one to know one. So it winds up being a kind of karmic revenge on you for bad resumes that you've written. C'mon, you know you've done it. You even knew it was bad when you were writing it. Admit it! You listed HTML under programming languages, didn't you? Argh!
So why are tech resumes so bad? You know what I mean. You see the craziest stuff on resumes. Like the candidate who proudly lists every Windows API call she's ever used. Or the candidate who lists every course he took starting from junior high school. Or the one who lists college extension courses he took while doing time for armed robbery.
Execution in the Kingdom of Nouns
Hello, world! Today we're going to hear the story of Evil King Java and his quest for worldwide verb stamp-outage.
Caution: This story does not have a happy ending. It is neither a story for the faint of heart nor for the critical of mouth. If you're easily offended, or prone to being a disagreeable knave in blog comments, please stop reading now.
Comparison of different SQL implementations
The goal of this page — which is a work in progress — is to gather information relevant for people who are porting SQL from one product to another and/or are interested in possibilities and limits of 'cross-product' SQL.
The following tables compare how different DBMS products handle various SQL (and related) features. If possible, the tables also state how the implementations should do things, according to the SQL standard.
Standard / PostgreSQL / DB2 / MS SQL Server / MySQL / Oracle
Friday, 2 November 2007
Anyterm - A Terminal Anywhere
Introduction
Have you ever wanted SSH or telnet access to your system from an "internet
desert" - from behind a strict firewall, from an internet cafe, or even
from a mobile phone? Anyterm is a combination of a web page and a web
server module that provides this access - see the demos.
Anyterm can use almost any web browser and even works through firewalls.
There is experimental support for mobile phones using WAP. If you join
my.anyterm.org you can access your systems straight away via our server
with no software to install anywhere. Alternatively, you can run the
Anyterm software on your own system - see the deployment examples.
We can also help you to integrate Anyterm-type functionality into your own
applicatons, for example to web-enable a legacy system, or an embedded
system. Contact us for details.
How It Works
Anyterm consists of some Javascript on a web page, an XmlHttpRequest
channel on standard ports back to the server, and an Apache module. The
module uses a pseudo-terminal to communicate with a shell or other
application, and includes terminal emulation. Key presses are picked up by
the Javscript which sends them to the Apache module; changes to the
emulated screen are sent from the module to the Javascript which updates
its display. Performance is quite reasonable and SSL can be used to secure
the connection.
my.anyterm.org
my.anyterm.org is designed for systems administrators and others who want
the benefit of access from anywhere using Anyterm, but who don't want to
risk installing the Anyterm software on their own servers. For a small
charge you can use our Anyterm installation to connect to your own systems.