Creating a ‘difference’ in portraits

Image by Hamed Saber
Image by Hamed Saber

I was reading a magazine where each article had the photo of the author besides it, but in a unique way: looking like something like on the right.

How to get this effect yourself? I will show you today.

In addition to Photoshop you need Microsoft Photo Editor to get this effect. You may have this already on your system, if you have MS Office or you may not – it has been discontinued by Microsoft. If you do not, you can download it from here or here: http://www.brothersoft.com/microsoft-photo-editor-128651.html.

First, open the photo in Microsoft Photo Editor, and then go to File->Properties. In the ‘Type’ field select Monochrome (1 bit) from the drop-down, and press Ok. Save the image.

Microsoft Photo Editor
Microsoft Photo Editor

Second, open the original photo in Photoshop (or any other photo editing tool like GIMP). Also open the photo modified through the photo editor. Drag the modified photo over the original, as to form a new layer on top.

Third, (for the modified image layer) bring up the Selective Color panel, by clicking on Image->Adjust->Selective Color. For ‘Colors’, select ‘Black’ from the drop-down – and choose suitable values for the sliders (or as shown below in the screenshot).

Photoshop
Photoshop

Fourth, select a suitable blending type from the layers window, and suitable Opacity which suits. For this image, we used ‘Overlay’ and 55%.

Blending
Blending

Save the image – flatten it before saving if you want, and you are done. If there is a way to do this without using Microsoft Photo Editor, please post comments.

There are variations possible, if you prefer. One is to ‘Invert’ the original image in Photoshop before submitting it to the MS Photo Editor (by going into Image->Adjust->Invert) and then proceeding as described.

The other is to use only the unicolor image produced by the MS Photo Editor, without blending it with the original. You could use a plain single color layer as the lower one, and do the selective color on the other.

Variation I
Variation I
Variation II
Variation II
Photo by Hamed Saber
Photo by Hamed Saber
Share

Making letter portraits

Manmohan Singh letter portrait
Having been impressed by letter portraits (see right), I wanted to figure out how to do them myself. In addition, I have shown you a lot of my own photos on this blog, without making the readers any wiser on how to do stuff. Better late than never, they say – so lets get started.

Choose a photo that you want to convert. Not every photo is a good candidate: the photo should be simple, not having a lot of detail. A bigger size say 640 x 480 should be available, and should have some contrast. For the purpose of this tutorial we will use this tree:

Tree

The result may not look very good because the photo does not have a unique recognisable shape, but will work fine for this tutorial. You may want to try yourself with this better photo of Indian PM Manmohan Singh:

Manmohan Singh

Step 1 is to open a word editor and type (or copy!) some text into it. It looks best if the text is related to the person whose photo portrait you are making. Times new roman font is preferable, Size 14, Bold. Set the zoom to 70% for good results. Take a screen print using Alt-Print Screen key on your keyboard, and bring into Photoshop. The result looks something like this:

Text

Now crop to retain the text, and copy-paste multiple times to achieve the size you need.

Moving over to the main photo (the tree), go to Window->Show Channels. Click on each channel one by one, and see which one has the highest contrast. Retain that one, and delete the others:

Channels

Now click on Image->Mode->Grayscale and then on Image->Mode->RGB.

Finally, when your two photos are exactly the same size, drag the text over the main photo – or copy paste as a new layer. The photo with the text should be on top and the other below.

Now go back to Window->Layers, and from the blending mode (upper left corner where it says Normal), select Screen. Things should look like this:

Tree

Flatten the image by going to Layer->Flatten Image.

What you want to do after this is up to you. You may want to do Image->Adjust->Threshold for complete B&W look. For, as for example with the PM photo above, you may need to do some cleanup using the Eraser tool for a ‘clean’ look.

If all this is too much work, being a lazy person like me – try this website: http://lunatic.no/img2aschtml.php.
Upload a photo, and it creates a colored text portrait. Its beautiful and you can choose the characters. Take a screenshot (using Alt-Print Screen) of the result and crop in Photoshop, to save as an image.

If something is hard to follow, please post in comments and I will simplify. The Manmohan Singh photo is by ‘ahinsajain’.

Share

Making scores comparable

How to compare scores rated under different tests, or by different people? Find out, and use the ready spreadsheet to crunch your own numbers.

Assume that we have feedback on team members from two different project managers.

People-> U V W X Y Z
Managers |
A 70 63 82 91 56 77
B 68 60 80 80 55 60

Can we say that W performs better in team A compared to team B? It looks like yes, he works better but analyse the scores a bit deeper. Project manager B has rated all team members lower than manager A. It may be that he is using tighter scoring.

In a different situation, it may be that two teams (of different people) have gone through two different tests, and we want to compare the people against others. Or, a university might want to compare people passed out in 2001 with those passed out in 2009.

The question is, how do we compare people when the scores that we have do not use the same basis.

Bell Curve - CC Attribution License
Bell Curve - Created using HSB Grapher

The answer is: normalization. We fix the mean score, and the degree of deviation that we would like to see. For a 100 marks test, we may want 50 as the score and a 20% deviation. Now, we will compare this with the actual mean and the deviation of each of the sets, and modify the scores as needed. Please refer to the attached spreadsheet which helps you do this.

 

 

 

In the given example, A has a mean of 73, and a deviation of 13. B has a mean of 67 and a deviation of 11. Let us bring both to a mean of 70 and a deviation of 15.

People-> U V W X Y Z
Managers |
A 66.3 58.1 80.4 91 49.9 74.5
B 71.2 60 87.9 87.9 53.1 60

So we note that A is indeed better in project A, but only slightly. Also from the initial figures we might have concluded that U is better in Project A, but actually the reverse is true.

Mathematically this process is called Normalization and is useful in fitting scores to a bell curve. Read more about it here if you are interested. However the spreadsheet attached is sufficient to get you started.

Share

Top 10 considerations when preparing a software test plan

testing

Click on images to enlarge

-> Test the parts of the application that have changed since the last cycle / go live

This part of the test plan is very obvious: test the changes to the application. Each change needs to be tested individually if possible, or as groups if the number of changes is large, and is known by the name regression testing.

For example, if you added a new field called ‘maximum pay by date’ to the voucher batch interface, then you could test the interface for this – having both data with this date entered, and with this date set to blank.

There is nothing more to this one – its normally the facet of testing that does receive the due focus during testing.

-> Test sampled parts of the application that have NOT changed

Now we come to something that does NOT receive the due focus. The parts of the application that remained unchanged. No, you do not have to test ALL if it. If you can test all of the application (especially with automated tools, as discussed below) – nothing like it. However, at least test 10-15% of functionality that has not changed.

For example – as discussed above – if you changed the voucher batch interface, then you can test the online voucher entry. Under the online voucher entry, test at least one scenario that has not changed.

The rule of the thumb is that if in a module having 100 test cases, 40 have changed – then test those 40 that have changed, and test 6-10 of those 60 that have not changed.

-> Look at it from the end users perspective: do one full cycle end to end

Next to include in the plan is something you can call integration testing: if your application is about users entering vouchers and getting paid – perform this cycle as a user would do. Many times we IT folks test only our application – the one we are developing and forget the rest of the glue technology. It falls into the category where we want to do it, yet are lazy at – so we find some short-cuts.

Once I was asked to carry out testing for a reconciliation report that had already been tested by the developers. I uploaded the same input twice, which ended up showing double on the final report. It turned out that the developer had missed this because he tested only on the basis of data that already existed in the system, and did not upload any new vouchers.

-> Stress testing

stress testing

Stress testing should again be a very critical part of your test plan. How many users are expected to use the application? during normal hours? during peak hours? Plan for all such scenarios. Design the business process that would take place if the application does fail – the idea should be that the user’s work doesn’t get halted.

There are stress testing tools available both free and commercial that you can use to simulate users.

In one of my projects, a web application that was created for 800 users, failed under a load of 35. Increasing the number of processors, or the number of server boxes is not a guaranteed way of handling load on the application: the application has to be designed to support the load from the ground up, and tested suitably.

-> Performance testing

performance testing

How long does a file take to get processed? How long does the user expect it to take? How long it takes for the screen to open/save?

The user expectation part is sometimes ignored. Please go ask the users of your application now what their expectation is – or it might already be too late in terms of coding.

The developers might think if a process runs for one hour its good enough. However, the users might be needing to run it six times a day during the closing period. Hence one hour might not be fast enough. In such a scenario we had to run four parallel instances of a process to achieve the user specified timing.

-> Concurrency testing

Can two different instances of the new process run together? The panel you just created: can it be used by two persons at the same time? Does it cause deadlocks at the database level if 100 instances of the process are run together?

Can two different versions of the application exist on the same machine?

These are the kind of questions that you ask yourself while working on the ‘concurrency’ aspect of test plan/execution.

A team of developers once needed to clone a process, and create slightly different functionality. However, it turned out that when both the processes were run together, 1 times in 10, one of the processes would fail. This was noted after go live πŸ™‚ Turned out the cause was incorrect use of the shared temporary tables by one of the processes.

If you are interested in Deadlocks technically please read my posting: “Oracle Deadlocks: the What & the How“.

-> Unit test before Integration testing

Our laziness at work again: we ‘trust’ our work and want to move directly to integration testing. Partially, the waterfall model of software development is also to blame here.

99% of the times, after the developer moves directly to integration testing – the very first test case for the application fails, and the developer comes back to the unit testing phase. πŸ™‚

Unit testing is a very critical part of your test plan – if you do it right, you will find hundreds of issues that will otherwise never get detected. Even not during integration testing.

Build ‘driver modules’ to iterate through all the ‘ifs and whiles’ that have been coded. Try out all avenues control can flow through.

-> Create test history

Creation of a test history is as important as doing the testing. Being able to, at a later date, answer such questions as: ‘what are cases we tested?’, ‘what are the problems we found?‘ etc is very helpful. Showing a clean slate (a ‘pass’ on all test cases) at the end of all our test iterations is not so helpful. In short, record the problems found, even though they may get corrected later on.

-> Automated testing

Automated testing solutions can be a big help. It does not mean that all testing be delegated to the automated testing mechanism: but it can definitely be an add-on to your manual testing.
In changing the order entry functionality, use it to enter 1000 different orders. There are several solutions available (use google) that will record the user actions, and will repeat those actions later with different data.
At a very simple level, AutoIt is a great tool for automated data entry, and is free (GPL). Its very flexible and has a great library of functions built into its scripting language. I use it all the time, and not just for testing!

-> Code review

While we focus on all these great ways of testing let us not forget our tried and tested workhorse: code review. Being humans, we are tempted to feel that by doing better testing (being easier to do) we can offset the need for a good code review, but there are hundreds of reasons to do code review.
There may be some program flows designed for rare situations which may never get tested. Code review in such a case will contribute ideas for such test cases. Documentation may not be in sync with the code, with the potential to make future changes difficult. There may be code improvements possible: for example, replacing an ‘if condition’ with a more specific check.

There are other things, depending on your scope you may also want to include them:

-> Knowledge transfer/competence testing

-> Backup & recovery testing

All the best, post your comments here.

Share

Hiding WordPress categories

Photo by John Poyntz Tyler
Photo by John Poyntz Tyler

When I wrote my first WordPress related post, I admitted that I was only doing it to attract traffic and it would be my last post on the subject. However, I start again. This time around, however, I want to talk about something which isn’t common knowledge and neither did I get any responses on the official WordPress forum regarding this.

Suppose you do not want some of your posts to appear anywhere: not the homepage, not the RSS feeds, not the archives: nowhere. However you DO want it to appear only when its linked to, as a single post on the page. I regularly need to do this, because some part of the post is more like an ‘addendum’ or when including everything would make the post too long.

There is a standard solution available on the forums: creating a plugin and adding code to this effect:


function hs_cat_exclude($query)
{
if ($query->is_feed || $query->is_home || $query->is_archive ) {
$hsq = $query->gt;get('cat');
if (!isset($hsq)) {
$hsq = '-22';
}
else {
$hsq = $hsq . ",-22";
}
$query->gt;set('cat',$hsq);
}
return $query;
}

add_filter('pre_get_posts','hs_cat_exclude');

Here, 22 is the category number of the category I wanted to exclude.

This code works fine, but the moment you add is_category to the ‘if‘ clause, it doesn’t work for the category page. This was perplexing to me, and I did not understand it. I spent a long time and then decided to dig deeper. I found out that the ‘wiring’ is faulty (this is what I believe). It can’t work like this for the category page. What is needed additionally is something like this:


function hs_cat_exclude_cat($where)
{
global $wp_query;
if ($wp_query->is_category) {
$where = $where . " AND NOT EXISTS(SELECT 1 FROM wp_term_relationships WHERE wp_term_relationships.object_id=wp_posts.id AND wp_term_relationships.term_taxonomy_id='22')";
}
return $where;
}

add_filter(‘posts_where’,’hs_cat_exclude_cat’);

So far so good. What I wanted over and above this though, is for the category to not even appear on the category widget. I tried to find a way to get this done through the plugin but it did not work. Ultimately I had to ‘hack’ one of the core files to achieve this. If anyone knows of a better way to accomplish this, please add a comment. The change is to wp-includes/widgets.php. Find the line of code that looks like:

$cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h);

added an ‘exclude’ clause like this:

$cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h, 'exclude' => 22);

Thats all there is to it.

Update Jan 12th 2010: Since WP 2.8 I believe (I noticed the problem in 2.9.1), the last change above needs to be done to default-widgets.php rather than widgets.php

Share

DNS poisoning – in plain English :-)

What is DNS poisoning, why it affects everyone accessing the internet and how to fix it.

Computers do not have names, only numbers. For example, Yahoo! is 68.180.206.184. When you ask your browser to be taken to Yahoo.com, it looks up this number in something similar to a telephone directory.

A person by the name Dan Kaminsky has found that it’s possible for someone (called X henceforth) to modify the directory. So, when you ask for Yahoo, the computer would lookup the wrong number, a number to a computer owned by X. Thereafter, it can record the information you give it, thinking that its Yahoo!. The owner may then misuse this information.

So what do you do to make sure this doesn’t happen? First, check your DNS server (the machine that tells your computer what number a website has) by going to http://www.doxpara.com/.
If that says your computer is vulnerable, change your DNS servers. Detailed instructions for different operating systems are here. For Windows, in short you have to change your DNS settings to 208.67.222.222 and 208.67.220.220 by going to Network Connections.

Note: This is not a security update blog, and I do not talk about every vulnerability. However, this one is important and everyone needs to understand it. On the other hand, most forums on the web talk highly techno. Read this one for more information, only if you think you need it!

Share

NTML authentication proxy

What would you do if you had a web proxy that requires NTLM, and the software (for example, HTTrack) that needs to connect to the Internet, doesn’t support it? NTML by the way, is an authentication protocol used by Microsoft.

I had this issue, and downloaded a proxy server(APS) that can connect to an NTLM proxy. The given software (HTTrack in this case) needs to connect to this new proxy server. It works flawlessly. You will need to download Python 1.5.2 – which is an older version of Python. The proxy server can only work under that particular version of Python. For example if APS is running on the same machine as HTTrack (port 6000) and your real proxy is on machine NTLMMain, port 9000 – enter ‘NTLMMain:9000’ as configuration for APS, and enter ‘localhost:6000’ in HTTrack configuration.

Share

Technical analysis

Technical Analysis
Technical Analysis
Technical analysis is a collection of methods to predict future stock prices taking into account only the past and present data – prices and (optionally) volume. There is no consideration given to the fundamentals of the company or the industry under consideration.

I personally use technical analysis(TA) only after I have zeroed in onto a company that I want to invest in. That is, I use it to determine when to enter (buy) and when to exit (sell). Over and above that – I do not execute blindly the output from TA. I look at the market sentiment, company and industry timing etc. Even so, technical analysis does help me big time with the decision making.

How is TA performed? No need to understand that. Attached is a spreadsheet that will help you carry out TA based on different indicators: Moving average, Moving Average Convergence / Divergence or Relative strength index.
The spreadsheet is here: AutoTech.

How is this spreadsheet different from others available online?

  • This sheet doesn’t require you to interpret the graph. While the graph is still created, which you can check, or create additional graphs based on the data, its not really required – you can read the interpretations directly. The sheet gives you buy/sell advice directly based on the indicator you select.
  • The sheet does not require you to buy MS Excel if you do not have it. It works fine with Openoffice Portable. I have already talked about portable apps – this one is free as well.
Share

Color coded invoice

As the project manager of a software project, I need to provide invoicing information every month end. I used to find this task rather boring, especially since I had to count hours and provide numerical data in multiple formats: one for the invoicing system in use by the company, another for the finance team and yet another as per client specifications (since he wanted it on a week basis, rather than on month basis as used by the company wide system).
So the same figures, in different formats – can be done, but was boring each month.

One fine day, I found this, and created this: Invoice_Dashboard

All you have to do is to setup the sheet once, with your employee details. After that, select the holiday periods using colors, and press Update. All the calculations will be done using the colors that you have given to the cells. Its easy to understand and verify: all one has to do is the check the colors – since the rest is automatic there cannot be a mistake. This excel sheet can easily be made to give out the “figures” in any format. Try it out, and post comments. Invoicing is no longer a boring job: in fact this colours approach has lot many more uses.

Note on licensing: this spreadsheet uses third party code, which I have permission to distribute – please do not distribute this spreadsheet or derivatives. The license applicable elsewhere on this blog is not applicable to this spreadsheet.

An example
An example
Share

Deleting zero byte files

In the past I have shown ways to run Linux scripts on windows based system. I have also talked about one use of the find command, in conjunction with grep command to search for files having a given text content (say a word) in multiple folders.

Today I will show you another use of the find command: to automate tasks such as deleting zero byte files. This is a pretty common cleanup task that’s carried out on machines that are involved in EDI file transfers.

Here is the script:

find . -size 0 | sed -e 's/^/rm /' | sh

It deletes all zero byte files in the current folder, and in the folders below it.

In order to understand this, you may need to read about pipes. The task is carried out in three steps:

  1. find . -size 0 searches for all zero byte files in the given folder and the folders below it and returns the filepaths.
  2. sed -e 's/^/rm /' turns the list of names into a script – for example if the name is ‘/data/x’ it changes it to ‘rm /data/x’. More on sed here.
  3. the last steps simply forwards the script to the Linux shell for execution.

This is also a very flexible script and can be customised to carry out a wide variety of tasks. Please post your variations as comments.

Share

Licensing and information about the blog available here.