kirit.com

Created 26th April, 2005 13:12 (UTC), last edited 5th July, 2007 06:59 (UTC)

Writing about C++, Programming, FOST.3™, Mahlee™, the web, Thailand and anything else that catches my attention—with some photos thrown in

Fost 4 release 4.10.06.39877 now out

Posted 21st June, 2010 03:18 (UTC), last edited 21st June, 2010 03:36 (UTC)

This release contains mostly a lot of work on the HTTP client (user agent) and the HTTP servers. For the Mac we now also support 32/64 bit fat binaries, and the iOS (iPhone/iPad etc.) support is much better.

If you want to get started the best place to look is the fost-hello example project.

Linux & Mac
svn co http://svn.felspar.com/public/fost-hello/tags/4.10.06.39877 fost-hello
cd fost-hello
Boost/build
hello/compile
dist/bin/hello-world-d

On the Mac you will need to set DYLD_LIBRARY_PATH before running hello-world-d

export DYLD_LIBRARY_PATH=dist/lib
dist/bin/hello-world-d
Windows
svn co http://svn.felspar.com/public/fost-hello/tags/4.10.06.39877 fost-hello
cd fost-hello
Boost\build
hello\compile
dist\bin\hello-world-gd

The next release is due out on September 21st.

Download locations

Everything is available through our Subversion repository. Below are the locations for the tagged releases for Fost 4.10.03.39008 components.

Detailed change log

  • Exception handling
    • Allow us to throw not implemented exceptions based on Boost system errors.
  • String handling
    • Added coercion from string::hex_string to std::size_t
  • Fost authentication
    • Added a utility function to add the authentication to a user agent.
    • Fixed the signature so that it signs the query string when there is no post data.
  • Parsers
    • Removed the parser instances because they're not thread safe.
  • Host
    • Added JSON coercions for fostlib::host.
    • A host can now be configured with a port number as the service.
    • Added Python binding for the host class.
  • URL
    • The host and port number are now mutable fields of the URL.
    • Fixed a bug where port numbers weren't properly shown in URLs converted to strings.
    • Query string values may now contain forward slashes and colons.
    • Fixed a bug where query strings were being thrown away when URLs were parsed.
    • The query string can now be any sequence rather than only a map of key/value pairs.
  • TCP/IP
    • Most errors should now end up with a fostlib::exceptions::exception which allows the error to be annotated.
  • HTTP client/server
    • Fixed a bug in chunked encoding that was causing the chunks to end up in the data block in the reverse order.
    • The user agent request can now be built from passed in MIME data.
    • The response body can now be detached from the client response as can the request body from the server.
    • The HTTP server now accepts additional verbs, more correct resource paths and can return all status codes supported by HTTP 1.1.
    • The fget example now allows us to save to a file by using an extra parameter.
    • There is a new MIME type binary_body for handling in-memory binary MIME data.
    • Added more allowable characters to the resource parser for HTTP requests.
    • The server request now supports handling of bad requests.
    • The HTTP client post and put short cuts now accept all data types supported by the request.
    • Changed the type of the server request query string to match that of the URL.
    • The parsing of the beginning of the HTTP request by the server is now protected by a mutex because Boost.Spirit is not thread safe.
    • Corrected behaviour for 304 responses.
    • Added the 207 response code
    • URLs may contain bangs (!)
    • The request data can now be retrieved from the Python request object.
    • The user agent body is now returned as a Python string rather than as a Unicode string. Interpretation of the data is now up to the Python code.
  • POP3 client
    • Improved the error reporting by annotating exceptions in as many places as possible.
  • fget example
    • Now supports the use of FOST authentication through the -authentication, -key and -secret command line switches. There's also a -user switch to handle authentication where the REST end point supports impersonation.
  • MIME
    • Improved handling of headers that don't have values.
    • Added support for multiple headers of the same name.
  • Object pointers
    • Implemented more of the pointer dereferencing operators.
  • Model initialisation
    • There is now an explicit type for the parameter used to initialise a model instance. This will allow the available information to be extended in a sane manner.
  • Mac builds
    • Added support for Postgres installation into /usr/local/pgsql/
  • Code layout
    • Moved all non-private fost-internet headers out of include/fost/detail
    • Moved a number of fost-orm headers into much more sensible locations
    • Changed the layout of the internet Python code.
    • Moved internal headers in fost-py to a better location

Categories:

Reds versus Yellows and everybody loses

Posted 20th May, 2010 04:50 (UTC), last edited 20th May, 2010 17:10 (UTC)

This is really just a dump of what I've been learning about what's been going over here in Thailand. There are long term themes (going back to the elections that first brought Thaksin in and even to long before that) and short term themes (the current crack down and breaking up of the red protests in central Bangkok and the resulting chaos).

As always with Thailand there are wheels inside wheels here.

The simple way of looking at this is that the red shirts are protesting to get Thaksin back into power after he was ousted in the coup in 2006. The red shirts are largely rural poor who say that they've had their lives improved immeasurably under Thaksin and want him back.

The yellow shirts on the other hand point to Thaksin's corruption, censorship and obvious use of foreign policy to further his own business ends.

The exact point scoring between the two sides quickly descends into madness and eventually trivia. Of course nobody really knows what either side wants to say as every thing is censored and the only people who get to talk to anyone are the army through their media assets.

Behind that is the current government which came in “democratically” after the party that won the election was banned by the courts (it's illegal to comment on that decision so I won't). This government is supposedly supported by the army who have really been calling the shots since the coup (actually, all the time except for maybe under Thaksin).

Now, the reds are not army supporters (and that's from even before the army started shooting at them over the last few days) — or at least, they're not so in the same was as the yellows — so who controls the government in September is critical. This is because that the current army head (and some would say the actual power in Thailand) retires then and the government gets to choose who is next. Clearly the yellows would like one of their people in there. Notice Abhisit (the Prime Minister) offered elections in November — enough time for the new head of army to get his feet properly under the desk before the reds win the next election.

Behind this of course is a fight for the succession, but Thai laws certainly don't allow discussion about any of that.

Some bonus points:

  • The red "menace" has turned otherwise reasonable yellows into blood lusting maniacs who have been calling for the army to go in and slaughter all of the protesting reds. Yesterday it seems they got their wish :(
  • Many urban yellows are in complete denial about the extend of red support. Of course the official media downplays the number of reds (more or less the entire rural majority).

There is so much more, but I don't really have the patience right now to try to go through it all.


Categories:

Mad house

Posted 19th May, 2010 15:39 (UTC), last edited 19th May, 2010 15:46 (UTC)

Everything's a mad house here in Thailand.

The reds are now without leaders so are out of control, which goes really well with the army who was already out of control — expect a sharp increase in deaths on both sides. It looks like the army has been killing even more today, and it looks like the reds are now also killing. They have set fire to many buildings.

The government has at least been busy doing important things: Facebook has been banned and un-banned in the last hour. Twitter has been banned, unbanned then promptly broke (fail whale).

Oh yeah, there's a curfew on as well and there's very little moving out on the streets even out where we are. In central Bangkok “not even the roaches are crossing the streets”, but buildings are burning

On the plus side we're safe well outside the area. We have one refugee from central Bangkok staying with us, but everybody we know is safe and well.

Will wait to see what tomorrow brings…


Categories:

Square golf

Posted 25th March, 2010 03:57 (UTC), last edited 25th March, 2010 05:04 (UTC)

Square roots are fairly slow to calculate (well, compared to other things our computers can do anyway). Here is an even slower way of doing it.

Say we want to find the square root of some number r, for example, let's take 13.

  1. Find two integers that are next to each other, one of which squared to a larger number than r and the other to a number smaller than r. For 13, 3 squares to 9 and 4 squares to 16 so our initial boundary is 3, 4 — we know the square root is between these two numbers.
  2. Find the number which is half way between our bounds. If this number squares to more than r then it becomes our new upper bound, if it squares to less than r it becomes the new lower bound.
  3. Repeat step 2 until we have our answer.

This is a kind of binary search to find the required value.

'''Write the smallest possible program that implements this algorithm''

  • The answer should be as precise as possible and at the same time the program must produce a single answer and then terminate.
  • If you end up in an infinite loop then the program is disqualified.
  • The input should be read from standard input and the result displayed to standard output.

Categories:

Fost 4 release 4.10.03.39008 now out

Posted 21st March, 2010 09:10 (UTC), last edited 21st March, 2010 13:03 (UTC)

We think this is the best and most stable release of the new Fost 4 libraries so far. There are a huge number of changes since the last release. So many in fact that it highlights a major problem with the way that we put together release notes, and with the next release we'll be using ChangeLog entries to make it easier to see what is in each

As well as restructuring the file layouts to make the projects easier to use we've also stared to add in some experimental support for iPhone and will soon be looking at Android support (through the use of the NDK).

If you want to get started the best place to look is the fost-hello example project.

Linux & Mac
svn co http://svn.felspar.com/public/fost-hello/tags/4.10.03.39008 fost-hello
cd fost-hello
Boost/build
hello/compile
dist/bin/hello-world-d

On the Mac you will need to set DYLD_LIBRARY_PATH before running hello-world-d

export DYLD_LIBRARY_PATH=dist/lib
dist/bin/hello-world-d
Windows
svn co http://svn.felspar.com/public/fost-hello/tags/4.10.03.39008 fost-hello
cd fost-hello
Boost\build
hello\compile
dist\bin\hello-world-gd

The next release is due out on June 21st.

File layout changes

The file layouts for all of the projects has been changed to move the project code into a lower level folder. This makes room for dependant projects to be part of the same check out via Subversion's svn:externals support.

This means that a project with pretty much everything that is needed to build it can be done by simply checking it out.

Library re-structuring

fost-aws has been split off from fost-internet. The should make it easier for people who don't care about Amazon Web Services support to use the libraries.

Platform specific changes

The MFC build options for Windows have been improved. Build variants are now used which means on Windows as well as debug and release variants debug-mfc and release-mfc variants are supported. The build targets still have the same names as the non-MFC versions so they should not be mixed. The fost-windows project examples can only be built using MFC builds.

We've also added in better support for the free Express compilers from Microsoft. Everything should work properly with Microsoft Express 2008 compiler.

On the Mac we have improved all sorts of things. We now have new testing procedures which means that we're much happier with the Mac support that in any previous release. Mac stability is probably slightly better now than even Windows.

Download locations

Everything is available through our Subversion repository. Below are the locations for the tagged releases for Fost 4.10.03.39008 components.

Known issues

  • The fost-windows examples must be built with either the debug-mfc or the release-mfc build variants as the ADO COM bindings use MFC.
  • OpenSSL must be explicitly checked for fost-windows. All the other libraries include it in the their externals already.
  • The build script in the root of the fost-windows check out doesn't pass on arguments. Use the fost-windows\compile script instead.
  • The Mac build for fost-postgres assumes PostgreSQL 8.4. For other versions, or non-standard install locations you may need to change the paths in the Jamroot.
  • Replacing the version of Python that ships with the Mac is very unlikely to work.

Categories:

Felspar