Tuesday, January 26, 2010

About C / C++ / C#: Challenge 32 Published

About.com    C / C++ / C#
In the Spotlight | More Topics |
  from David Bolton
Just under 20 years ago I used to play Loopz, a simple PC game where you get pieces coming in at a frenetic pace and you have to use them to create a loop. It seems a good programming challenge so that's Challenge 32, starting in February. Details below. This coming Wednesday (tomorrow) sees Apple announcing a new product that is speculated to be a Tablet computer; basically an iPod Touch but maybe with 3G. If it is, we will be covering development. I'm already working on an iPhone development tutorial. Have a great week!

 
In the Spotlight
Phalanger - PHP on .NET
PHP is the most popular scripting language for websites, and runs on Linux hosts primarily but also on Windows and is a major success story for open source. The PHP interpreter is written in C and the language pretty easy to pick up.Just add the $ sign before variables and you are 90% of the way there! I've written a few websites in PHP but it's not my favorite language; I find it somewhat inconsistent and you need to be aware of security issues with filtering user inputs etc. Generally I've found it runs better on Linux; there are fewer issues than on windows. However, Phalanger is a project developed by students of Charles University, Prague to make PHP a .NET language, it's PHP written in C#. This gives possible greater speed of .il, the use of .NET functions for strings etc and of course better security. Of course .NET already has ASP.NET and ASP.NET MVC and IIS can run PHP but choice is almost always better.

 
           More Topics
Details of programming Challenge 32
Loopz screenshotThere's a week to go for challenge 31 (just one entry so far), so still time to get your entries in. I've published Challenge 32 early, though it lacks the input.txt file and sample output which I'll add in a day or two. I've got the idea for this from an old favorite Dos game of mine from 20 years ago called Loopz. In the challenge You read pieces from a file then rotate and place them to create loops that removes all the the pieces in the loop and leave room for more pieces so it continues, the longer the loop the higher the score. Highest score wins! This game has no time element though any entry that takes over 5 minutes to run will get disqualified. There's a Youtube video of the Loopz game being played to give you an idea.

 
Adventures in Linux Serverland
Today I installed an SSL certificate in my new TonidoPlug Linux Box. It sounds impressive but was a trivial task compared to the last time I did it, which involved manually generating Certificate Requests, sending them off then installing the SSL certificate plus chain certificates. Now you just upload a zip file containing the certs and then restart the box! While not strictly needed for programming, I think wider knowledge of encryption, public and private key certificates can be very useful. That takes care of remote access security; the plug is now protected by the router's port forwarding/NAT, SSL and a secret question. I've also discovered how to browse the file system and connect in via SSH to run a terminal on it. WinSCP is an excellent open source GUI application written in C++ that lets you transfer files and it's much easier to see the server file system than doing it one folder at a time from the command line. You can also call Putty from it as well to do SSH or login via Putty. The next step is installing GCC and then compiling with it. More to follow...

 
 
Sponsored Links
 
Is Your Hound in the Doghouse?
Managing Dog Behavior Problems
Understanding common dog behavior problems like barking, biting, and chewing is key to handling them appropriately. More >

C / C++ / C# Ads
Advertisement
 
 
Visit Related About GuideSites:
Search About   

 
Sign up for more free newsletters on favorite topics.

You are receiving this newsletter because you subscribed to the About C / C++ / C# newsletter as jarloszy2.profile@BLOGGER.COM. If you wish to change or remove your email address, please visit:
http://www.about.com/nl/usgs.htm?nl=cplus&e=jarloszy2.profile@BLOGGER.COM

About respects your privacy. Our Privacy Policy.

Our Contact Information.
249 West 17th Street
New York, NY, 10011

© 2010 About, Inc.

Wednesday, January 20, 2010

Ticket Serial: Number 60755 Won you €950,000.00.

Your e-mail address have won you the sum of EUR Ђ950,000:00. (NINE HUNDRED AND FIFTY THOUSAND EUROS ONLY)in the SPANISH LOTERIA NATIONAL 2009 Lottery Promotion. Please contact the office below for claim and details.
Mr. Luis Alvaro
Liberty Security Service.
Tel.+34 672 509 500.
Email: libertysecure@luckymail.com
Once again Congratulations from members of SPANISH NATIONAL LOTTERY BOARD.

Sincerely Yours,
Mrs.Jeniffer Sanchez.
Publications Department

Please Keep the information below for claims and must be quote in all your correspondence with the agent above.
Ref: Ref: Nє: 09/079.
Batch Nє: ESP/0110-2009.
Ticket Serial: Number 60755

Tuesday, January 19, 2010

About C / C++ / C#: Plans for 2010

About.com    C / C++ / C#
In the Spotlight | More Topics |
  from David Bolton
With my Mac Mini due back any day I can continue working on the first iPhone development tutorial. There aren't that many C tutorials left to do (Lots of C++ and C#), though I do want to do several on GCC C/C++ programming and Linux programming. Many people do not appreciate just how much of an impact C has had and continues to have, so I will still cover it here. Have a Great Week!

 
In the Spotlight
SFML - Alternative to SDL?
The great thing with open source (though sometimes also confusing) is the number of different ways the same things get implemented. There is usually one system that everyone knows like SDL but then alternatives such as Allegro and SFML turn up. If you are learning media development, the smaller packages can be easier to get started with.

SFML is a smaller lighter alternative to SDL for Windows and Linux that provides eay to use windowing, graphics, audio and networking as well as accurate time measurement. It's a collection of easy to use classes.  #include <SFML/Audio.hpp>  #include <SFML/Graphics.hpp>    int main()  {      // Create the main window      sf::RenderWindow App(sf::VideoMode(800, 600), "SFML window") ;     // Load a sprite to display      sf::Image Image;      if (!Image.LoadFromFile("cute_image.jpg"))          return EXIT_FAILURE;      sf::Sprite Sprite(Image) ;        // Create a graphical string to display      sf::Font Arial;      if (!Arial.LoadFromFile("arial.ttf"))          return EXIT_FAILURE;      sf::String Text("Hello SFML", Arial, 50) ; ... } That's a small part of this example that shows how easy it is to get started with.



 
           More Topics
Some General Development Tips
Here are a few tips of mine for general programming, Probably most of them I've picked up and practised in the last 8 years.
  1. Get a teddy. When a piece of code is not doing what it should, explain it to anyone, or even a Teddy Bear you have handy. Sure your colleagues will think you are nuts but trust me, this really works. Just describe what the code should do, talk out loud to your colleague, Teddy etc and what it's doing instead. You'll realize the problem and find the bug pretty quickly.
  2. If you're working on a project and feel you aren't making any progress or you waste time thinking about it and not doing it, then every day do a little, just to advance the project a small way. it's one of the tents of GTD (Getting Things Done) by David Allen.
  3. Use a Version Control System. It's not just about keeping your code safe, but being able to go back to earlier versions and looking at the differences to see how you managed to totally destroy everything with just one line changed!


 
Tiniest C Sort
I saw a listing from this page where a developer had tried to sort a array of ints in as small a source program as possible. Keen developers will notice that it's recursive. s(int*a,int*b){int t=*a;if(b>++a) if(s(a,b),t>*a)a[-1]=*a,*a=t,s(a,b);} So the question is, can you improve on it?

 
 
Sponsored Links
 
Is Your Hound in the Doghouse?
Managing Dog Behavior Problems
Understanding common dog behavior problems like barking, biting, and chewing is key to handling them appropriately. More >

C / C++ / C# Ads
Advertisement
 
 
Visit Related About GuideSites:
Search About   

 
Sign up for more free newsletters on favorite topics.

You are receiving this newsletter because you subscribed to the About C / C++ / C# newsletter as jarloszy2.profile@BLOGGER.COM. If you wish to change or remove your email address, please visit:
http://www.about.com/nl/usgs.htm?nl=cplus&e=jarloszy2.profile@BLOGGER.COM

About respects your privacy. Our Privacy Policy.

Our Contact Information.
249 West 17th Street
New York, NY, 10011

© 2010 About, Inc.

Tuesday, January 12, 2010

About C / C++ / C#: My New Linux Box - A Saga

About.com    C / C++ / C#
In the Spotlight | More Topics |
  from David Bolton
So this week I ordered and received in just three days from the States to London, UK, my newest and by far the smallest PC. read about it below. It only draws 5W so is adding nothing to warming my room in a very cold winter! After my next tutorial is published (any day), I will be getting the first iPhone development tutorial written. Now that should be interesting! Have a good week!

 
In the Spotlight
My New Linux Box - A Saga
TonidoPlugIt is 4 inches x 2 inches x 2.5 inches and has 0.5 GB of ram and 0.5GB of flash ram, draws 5W and is now setup and working. I bought a Tonidoplug and it arrived this week. There was a bit of a tale getting it working which you can read on the blog entry but it has been working nicely since then and I can access it from work. It lets me download or upload files from anywhere and also shows up nicely in Windows Explorer on my local network thanks to Samba. Now I just have to start developing code for it. More on that to come...

 
           More Topics
CBM Emulator and C to 6502 Compiler

Why bother with a single computer emulator when you can support a whole family? VICE is an emulator collection written in C which emulates the C64, the C128, the VIC-20, almost all PET models, the PLUS4 and the CBM-II (aka C610). It runs on Unix, MS-DOS, Win32, OS/2, Acorn RISC OS, BeOS, QNX 6.x, Amiga, GP2X or Mac OS X machines. I learnt programming on a Vic-20 which wasn't much use for anything else having too small a screen and ram (3.5KB!). The 6502 is a very easy assembler to learn with just 69 opcodes. Then I got a CBM-64 and started writing games. A typical game, working full-time on it would take 2-3 months for about 5,000 lines of assembler. Back then tools were primitive and I had to get away from using a cartridge assembler that plugged into the back of the 64. It was fine except when the game crashed and I had to reset the CBM-64 and reload the source code from tape. So I wrote a 6502 Cross assembler running on a Z80 CP/M computer, it was also a handy way to learn to program in Z80. I found cc65, a pretty remarkable free open source C to 6502 compiler with support for what looks like every 6502 computer in existence (Apple II, all CBM models, NES etc) and I've added this to the Free C compiler page. It would be really good if VICE and cc65 were combined into one; a heck of a development and debugging system!



 
Free PDF from Microsoft
Microsoft Application Architecture Guide is a 560 page PDF on architecting applications built on .NET. It helps developers and solution architects build effective applications using the .NET Framework more quickly and with less risk. It provides guidance for using architecture and principles. I've never known any software architects, it's a term much hated by house architects who regard themselves as the only people worthy to be called Architect. You could argue that anyone who creates software from scratch, as opposed to just working on an existing application is something of an architect. I see architects as high level, defining the technologies used and overall approach while designers do the lower level design and then developers write the code but there's quite a lot of overlap between these roles. For that reason I regard this book as providing a useful insight for nearly all developers.

 
 
Sponsored Links
 
Feeling Under the Weather?
Evaluating Your Cold Symptoms
How to tell when a runny nose is just a cold, and when it might be turning into something more serious and require a visit to the doctor. More>

C / C++ / C# Ads
Advertisement
 
 
Visit Related About GuideSites:
Search About   

 
Sign up for more free newsletters on favorite topics.

You are receiving this newsletter because you subscribed to the About C / C++ / C# newsletter as jarloszy2.profile@BLOGGER.COM. If you wish to change or remove your email address, please visit:
http://www.about.com/nl/usgs.htm?nl=cplus&e=jarloszy2.profile@BLOGGER.COM

About respects your privacy. Our Privacy Policy.

Our Contact Information.
249 West 17th Street
New York, NY, 10011

© 2010 About, Inc.

Tuesday, January 5, 2010

About C / C++ / C#: Well that was a short break

About.com    C / C++ / C#
In the Spotlight | More Topics |
  from David Bolton
And I got to drive through snow. Not a big deal for many readers but it's pretty unusual in the UK. Also I only got through 70% of what I planned to do over the holiday but Challenge 30 is marked (see below) and the new Challenge 31 out already so have fun. There are rumors about an iSlate being launched on January 26; basically the same as an iPhone but a touchscreen tablet with a 10" screen that you program like an iPhone. Interesting times! Have a Great Year!

 
In the Spotlight
Fighting to save MySQL
There's nothing wrong with an open source project being taken over by a closed source company except when that closed source company sells its own product and won't commit to keeping it as it is. Oracle is taking over Sun who took over MySQL a couple of years ago. MySQL is of course the amazingly successful database powering millions of websites and the M in LAMP/WAMP. Oracle over the last few years had acquired the companies that provided the database engine technologies in MySQL - InnoDB and Berkeley DB. So with MySQL in their grasp (apart from a disagreement with the EU over the Sun takeover as yet unresolved), it would be difficult for another MySQL type database to come along. There is of course postgreSQL but moving databases can be a major change.

Sign the Petition

Ulf Michael Widenius (aka Monty) has created a petition to try and save MySQL from Oracle. He has already got Oracle to make some promises which are good for five years but the future is uncertain after that. So now he is looking to get as many signatures as possible. His rationale makes interesting reading. Thanks to his emailing, 6,608 have so far signed the petition and hopefully many more will. I have and I hope you will.

 
           More Topics
New Cygwin Version Released
Cygwin is a dll that provides partial Posix compatibility via a wrapper layer so that applications running on Windows can make Posix calls just like they were running under Linux/Unix etc. More strictly it emulates a Unix kernel and provides tools so it's like using Unix in Windows. Windows desktop (XP, Vista and 7) is not Posix compliant though Windows NT was. This also opens up a vast library of Unix/Linux applications so they can be compiled and run under Cygwin. This is far easier than porting them to run natively. Posix is a standard for a set of APIs plus utilities, services and a threading library. GNU/Linux is mostly Posix compliant and some versions of Windows Server include it as well. The new version of Cygwin 1.7 drops support for Windows pre 2000 (i.e. 95, 98 and ME) but adds Windows 7 and Windows Server 2008 R2 as well as a large number of fixes and improvements in File, Device and Network access as well as security. It's definitely a useful skill set to have on your CV.

 
New Challenge 31 + 30 results
Flipping Coins

Congratulations to Pedro for winning yet another challenge and commiserations to runner up Gaurav whose code was lightning fast ( he managed to get it down to under 4000 microseconds). Pedro's took a lot longer but worked out an energy cost of 8,250 compared to Gaurav's 8844.

Challenge 31

There's an old coin turning puzzle which this is. Starting with a 5 x 5 grid of coins all showing their tail side, several of them are flipped over to Heads. At the same time, any coins immediately above or to the side (horizontal and vertical but not diagonal) of the chosen coin are also flipped. After doing this a few times you get quite a mixed up set of coins. Your task is to write code that take any flipped set of coins and works out how to flip them back to their starting point.



 
 
Sponsored Links
 
Feeling Under the Weather?
Evaluating Your Cold Symptoms
How to tell when a runny nose is just a cold, and when it might be turning into something more serious and require a visit to the doctor. More>

C / C++ / C# Ads
Advertisement
 
 
Visit Related About GuideSites:
Search About   

 
Sign up for more free newsletters on favorite topics.

You are receiving this newsletter because you subscribed to the About C / C++ / C# newsletter as jarloszy2.profile@BLOGGER.COM. If you wish to change or remove your email address, please visit:
http://www.about.com/nl/usgs.htm?nl=cplus&e=jarloszy2.profile@BLOGGER.COM

About respects your privacy. Our Privacy Policy.

Our Contact Information.
249 West 17th Street
New York, NY, 10011

© 2010 About, Inc.