If you have created a Windows App (Application / Software I mean) and it is all messed up when displayed on a Windows 7 machine with display zoom set to 125% /150% here are a few things you can try.
First thing first, never design your UI while your system is at any display resolution other than 100%, unless you manage it properly to be displayed same on all zoom levels (see further steps to achieve this)
Make sure you create your app with flexible controls and add re-sizing procedure to appropriate events (specially Resize)
If however you have a fixed background that can not flex when you zoom in you should pick appropriate setting for Form.AutoScaleMode You can choose it to be either none (default on most systems), Font (resizeable controls expands in proportion to font size), DPI (resizeable controls expands in DPI % increase) and Inherit (usual zoom in effect, works best for fixed background)
The tips is generic for Visual Studio most versions (6.0, .NET, 2005, 2008, 2010, 2012) and not dependent on language choice as well (C#, Visual Basic (VB) / VB.NET). This also applies on older Windows version where you can set the DPI to 120 instead of default 96.
I was trying to signup for google apps for a company that has office in Kyrgyzstan and the form was coming back with error.
Invalid Input (right next to phone number)
I tried every way possible (at least I thought) to enter the phone number with no luck. A search on Google showed many unanswered similar queries. That is when I had an idea. I searched for the yellow pages for the country and searched for a random company. The listing came back with their phone number with following format:
(512) 123 - 2345
I reformatted my number on this and voila! it worked. So seems like whichever validator Google Apps is using it is using most used local format to verify (at least in this case). Best of luck if you have a similar problem.
Last year Facebook released Hip Hop for PHP which was their key development to make their systems efficient. They have now released a VM which is basically a PHP execution engine based on the HipHop language runtime.
Second of the biggest trap new programmers (and some experienced ones) can fall into is not structuring their code logically. This might save you a few minutes when you are building something but should really be avoided. Not only you will save a lot of time in future but will also love yourself that you did something better. Things to keep in mind when programming to a better structure are:
Comment, Comment and Comment As somebody said before, comment your code as if your program will be maintained by a serial killer who knows your address. You would not mess with such a person so why risk it, comment all the things.
Your program should read better Your code should be written with your very junior colleague in mind. If you do not have a junior now just hope you will get a junior to help you out and your code should be structured easy enough for a student to read. Big hint: read comment, comment and comment again
Structured code makes it easier to find mistakes Your mind is a great optimiser and data compressor. Amazingly your mind has the the ability to skip information based on assumptions. For most of you, the brain would have assumed there is only one “the” in last sentence and skipped the second one. Similarly when you have very small but crucial spelling or syntax mistakes your mind can easily skip it unless you spot it due to character mis-alignment.
Which one you found easier to spot mistake in? Another example in Android SDK
Structured code leaves no place to hide for that evil semi-colon It is one of the most time wasting issue when you can not figure out why your loop is not running.
Indentation makes code more obvious to read If you are going to logically analyse your code for mistakes you should better indent it logically. This is another one of benefits that are explained better with an example.
Look out for false indentation Carrying on with above logic, make sure you do not have false indentation on code that should not be indented. This is another one of benefits that are explained better with an example. Quick example:
user_permissions = 10 printf(“Checking permissions”); if (user_permissions>3) printf(“Welcome user”); printf(“Your permission level is good at: %d”,user_permissions);
Use indentation with blocks of code and use comments to specify start & finish of a block Generally the consensus is that each code block gets indentation, and a sub code block gets another indentation. If you think that it could get worse to read with 6 levels of sub-blocks then you should better worry about re-structuring your code logic to lesser sub-blocks. Never forget to comment the end of block. Specially in IDEs that do not auto highlight the ending of a block when you select the start of a block
Use a helpful IDE/Editor A lot of above issues can be reduced if you use an intelligent IDE/Editors. Some IDEs/Editors give your variable highlighted colour when you select a variable name. i.e. Notepad++, IntelliJ. Some of IDEs/Editors highlight block of code you are in or simply highlight the end of block when your cursor is on start of block. i.e. Notepad++ with plugins, IntelliJ, Dreamweaver, Eclipse with plugins
As always, if I remember anything else I reserve the right to edit my post later. If you think I have forgotten something please do message me.
Just a quick list for anybody who happen to come across same issues as me. If you have built an app and for some Godforsaken reason had to use PackageMaker following are things to watch out when moving your project to XCode 4 / Lion. (Yes you read correct, if you do not have to please please do not use PackageMaker, even Apple does not use it themselves)
XCode 4 output directory is now in Library
Not just that it builds your product in ~/Library it also creates a folder consisting of your productname-some_random_characters. Trouble with the folders in ~/Library is that these are not selectable in folder browser from PackageMaker (or elsewhere). It is also not guarenteed to work if you copy paste the complete path from Terminal. Copying the product does not copy everything needed and will fail the installer build as well.
There are two ways to change build location:
XCode > Preferences > Locations (Change the default to Relative for a subfolder in workspace or Change to custom for a custom location) - this change is global and recommended.
File > Project Settings > Build (similar changes as above) - this change is per project basis.
Double check location of resources and images
PackageMaker will not always give a helpful error if you have changed your core path of resources and product. Make sure you check path on everything including but not limited to Interface Editor - Background, app (as explained in first step), any other files and scripts.
Triple check location of scripts / jump into XML
If you have pre-install, post-install scripts then not all settings are changed (annoyingly) when you edit the path to your scripts in PackageMaker. Specially post-flight path in many cases. If you are still getting “Script not copied” error then you need to right click Project.pmdoc and click Show Package Contents and then double check paths in .xml files in any text editor. Re-open your PackageMaker file to try.
As always I will add anything if I remember, leave me a note if I saved you some time or if I forgot something.
I promised myself about ten years ago that I would start writing about programming pitfalls, you know common mistakes programmers make. Sometime these mistakes are very common, silly and minuscular. So much so that you want to hit your head to brick wall while you are figuring the issues out and hit your monitor with your head when you find out where you were going wrong. Let’s start here, shall we, I am already ten years late:
Name your variables sensibly
Explain what it is in a quick look. year is a bad choice, current_year is better. You might think that in this small snippet of code there is only one variable that holds information like this, you will come to regret this when the project scales.
Avoid generic names including banana, potato, i, j & k. First ones because you are really not storing a banana or a potato Second ones because using loop_i or i_records makes more sense and are more searchable
Not too short that it loses meaning in few days when you revisit your code. rs1 is a really really bad choice, rs_students is much more sensible, again you might know each and every cryptic variable now that you are working on it. You will come to curse yourself in as few as 1 day when you come back to a piece of code with bananas and potatoes
Not too long that it becomes overkill, I am looking at you ObjectiveC ಠ_ಠ. students_manager_view_records_record_set_students : please just don’t, first we know we are in student manager application and secondly we are in view records controller, so record_set_students becomes longest sensible version
Follow the convention even if you have to ignore my last advise, when in ObjectiveC NameAsObjectiveCWillNameThings. Weather it is snake_case or the CamelCase pick one that is more conventional to language, framework or team you are working with and stick to it. student_age = current_year - DateOfBirth_Year breaks so many pro-codes in a single lines I personally prefer snake_case and will recommend it if you are at beginning of a project and can make the choice
Specify data type, it might help you identify mixed up names far quicker Speaking in office about this blog post, James Matthieson reminded me of this good technique. You basically add the prefix of data type to your variable name to avoid confusion when using these variables. int_current_year and str_student_name are good examples.
This is not going to be a tutorial I am afraid, just a quick overview of a couple of projects.
SCM Manager
SCM manager claims to be
“The easiest way to share your Git, Mercurial and Subversion repositories over http.”
and quite rightly so. After trying gitolite, gitosis, svn+apache and a few other options manually and managing to run all I got a nice surprise when I tried SCM Manager. Most definitely the easiest way to do it. But wait, there is more:
SCM Manager supports Central user, group and permission management, I have tried creating developers group and can easily put as many users I want into developers and they get all needed permissions automatically on all repositories.
SCM Manager is not limited to one platform, it supports both second and third generation version control systems, naming: Git, Mercurial and Subversion, all from just single install, this promise includes no need to install Apache or DB server
It provides full RESTFul Web Service API (JSON and XML), Simple Plugin API and there are quite a few useful plugins available ( f.e. Ldap-, ActiveDirectory-, PAM-Authentication)
Installation is very easy and so is management, you do not need to mess with any config files. The interface will let you configure everything. There is however marmite on top of this slice of bread, the interface is in Flash, so you will either love it or hate it.
Correction: I am a lazy guy for not checking above about Flash and making assumptions, the interface is built with pure HTML, CSS & extjs3 and Sebastian is a nice guy for mentioning it very politely.
Disclaimer: I have not tried this enough to give a fuller review as SCM Manager above, expect an update in next year.
This is an up and coming clone of GitHub, the idea and interface looks promising. The install is easy enough (albeit it runs on rails, I know few of you complained before about how difficult is to set the environment up). There is even a demo online for you to try GitLabHQ demo online.