Amazon EC2

Posted by: on Dec 9, 2008 | No Comments

Amazon EC2 is an amazing service for those who want stability, scalability, and extensibility. Technically speaking, EC2 is an on-demand VPS (Virtual Private System) for which you pay when you need. EC2′s upside is that no customer service and additional payment transactions are involved if a server is “purchased.” EC2′s service is paid by instance hours. If an instance is not running, you do not need to pay for it. EC2′s instances support up to 8 cores and 17GB memory. Its elastic block store supports unlimited storage space that is pay-as-you-want.

Considering how unstable the MediaTemple (gs) that I am using, EC2 is the next round for me. EC2 provides better supported, more stable, flexible, and robust than any other VPS competitors in the market, iff you are geek-enough to use it.

In FA

Ragel State Machine Compiler

Posted by: on Dec 3, 2008 | No Comments

Ragel is a State Machine Compiler that supports generating code from Ragel’s regular expressions. Ragel provides code generation for C, C++, Objective-C, D, Java, and Ruby. Regular expressions and finite automata can be used in protocol analysis, data parsing, lexical analysis, and input validation. Implementing Ragel’s C code is very easy. Here is an atoi implementation for C’s standard library. It is several times faster than C standard library’s implementation.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * Convert a string to an integer.
 */
 
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
 
%%{
	machine atoi;
	write data;
}%%
 
long long atoi( char *str )
{
	char *p = str, *pe = str + strlen( str );
	int cs;
	long long val = 0;
	bool neg = false;
 
	%%{
		action see_neg {
			neg = true;
		}
 
		action add_digit {
			val = val * 10 + (fc - '0');
		}
 
		main :=
			( '-'@see_neg | '+' )? ( digit @add_digit )+
			'\n';
 
		# Initialize and execute.
		write init;
		write exec;
	}%%
 
	if ( neg )
		val = -1 * val;
 
	if ( cs < atoi_first_final )
		fprintf( stderr, "atoi: there was an error\n" );
 
	return val;
};
 
#define BUFSIZE 1024
 
int main()
{
	char buf[BUFSIZE];
	while ( fgets( buf, sizeof(buf), stdin ) != 0 ) {
		long long value = atoi( buf );
		printf( "%lld\n", value );
	}
	return 0;
}
This website uses a Hackadelic PlugIn, Hackadelic Sliding Notes 1.6.5.

Supported by Webinit Consulting