Categories
Bookmarked Javascript

Dropzone.js: A great plugin

I recently try Dropzone JavaScript library to ease the upload process. It is really a lightweight and good library. I have a existing PHP form that take multiple images, and transfer/upgrading it to dropzone was as easy as include it’s library.

I have little to mention, but a link to site is what I want to include in this post. http://www.dropzonejs.com a must library if you need multiple image upload by user. I use it for a scientific application, where client need to bulk upload about 1000s of image file for database, and it speed up their process. There is nothing much to add for tutorial as their basic tutorial is good enough to start even for newbie.

Categories
Article Blog: My thoughts

Next step to development team

In my last post I try to define what motivate me to learn new things. Also, I try to show that I really believe in learning new things. In this blog, I will try to define the basic things a team need for developer productivity. This list may not be what most agree, some might see it incomplete, some might found it over burden. But this works well for me till now, and if I found something better I will change this. But from my experience in sub-standard teams and project this will be a good start.

First, there needs to be a team. Yes, that is first requirement because often there is no team to work, there are individual who just do their work. The team consist of at least two entity, at least two human. Now, you might question that I work alone so how I am referring a team to be of two entity. So to answer it, the first person in team is the Client, and you are the second person, the developer. Client is always the first person in team. He/she must be ready to accept you as his team. This is where team builds. If, he just think he hire you for the job, then he will only get a contracted human resource. He will never get a person who even try to understand his business needs. And if that happens the game is over before it starts. This doesn’t mean the role of developer team is reduced, or all the burden is on client to make team. Developer should be truthful. He should be the one, a client can trust on. It doesn’t matter if you fail to achieve deadline, if doesn’t matter if you fail to deliver the expected product. What matter is at end client doesn’t think he is been cheated. He doesn’t feel you are not skilful enough for job. He should not regret his decision about choosing you.

Second, part of ideal setup comes, with tools you use. How you protect what is been done? How you ensure reliability of software/code you are writing? How you ensure that it works on load? What will happen, in case you are not available to maintain the software? Are you using out date technology? Are you using immature technology? And most importantly, how does it affect client and his requirement? I often see these question are neglected at small scale. Developer mainly think, it is small project and not worth taking all extra in account. If we reduce those Version control, documentation it cost less to client and we gain project over competitor as we offer same solution at low price. If you are looking for developer, ask him to explain his stand on above question. And if you like answer then only choose him. I am not saying everything must always be included, but if you understand the risk/profit of not include all these it is win situation.

Third thing is communication medium. This is another important setup. Often, developers are not available to receive phone calls or chat. They reply email after 2-3 days, while client wonders if you are still alive. Same happen when developer ask for feedback and they get a reply after a week saying, “yes”. Whereas developer was asking to choose between two possible scenario or asking to define a problem. You must set a communication channel between all members of team. And there must be a definite time frame between replies. Even if there is nothing to reply, just acknowledge that message is been received.

Once you master these three things, a first step in ideal setup is been done. If you are developer, please always be truthful to client. I am tired of doing Editing job of some other developer’s failure. I want to work on new project more. I am not your debugger.

Categories
Blog: My thoughts

Learning is GOOD

I am working as developer for quite sometime now. I worked as developer in couple of companies, then hire few to assist me. But never need or know the concept of unit test. Or rather I would say it was forgotten to small team like us. But as I start working more and more as one man army, I start to realize that I need something that will help me test what I develop. I need something that make my code readable to me if not world. I need something that make my life easier.

This was never a thought for me, or most developer around us. But as soon as I have to work on old projects that my team start developing and left in between, I realize that I am missing something that make me a better programmer. But, today after practicing few good concepts like unit testing, clean code, code documentation, code formatting, life has been much simpler. I know to any good experienced developer this sounds like, “What? You are talking basic here”. But reality is most 1-200 people companies I worked in around here do not follow these stuffs. They mostly care only to deliver some visual to client so they get paid. This has been a bitter truth around, that never impress me.

I knew, this is not right and what I am doing, no matter how good I do, I am doing it wrong way. So, I start learning new concepts, start upgrading myself. Now, I can see myself standing near the edge of developer crowd that deserve to be called a developer. I am not part of that crowd which just struggle to survive because their code always fails.

If you are starting your career, it is important to find a better company even if he is alone like me, than a companies that pay you better salary, but lack the way a developer should work. In my future post I try to define what needs to be learned for a beginner. As I want beginners to not repeat my mistakes. I don’t want to waste their life’s 10 yrs figuring it out that they start at wrong place.

I am looking for some developer to assist me, if they are ready to work like professional should. But I am very unfortunate, as I only meet countable few which are ready to take on better steps, most only sounds like they want to do good. My hunger for learn will never die. I can comfortably says, learning is my food for life. It is new things that keep me on edge of my seat, and I will learn everything I can.

I am no more a Desktop Only Programmer, I am not only a Web developer, but I am a Mobile App Developer and I can built app for Apple, Android and Windows. This is addition to my skills of Windows Desktop, Linux command line tools, web apps and Web site add-on.

I just keep repeating to myself, that I should always keep looking something to learn. I will keep doing that.

Categories
Bookmarked MS SQL Server SQL

SQL Update if Record Exists or Insert

Quite often we need an approach where we need to Insert record if it is not already present. Sometime to manage relationship. There are few different way of doing it, like “If Exists”, or “Insert on Duplicate Key” (mysql) but the best I found is one from MSDN Blog Entry ( http://blogs.msdn.com/b/miah/archive/2008/02/17/sql-if-exists-update-else-insert.aspx)

The approach is to simply try update the record, if record present it got updated, if not then it insert new based on “Row Effected variable”.

Categories
.NET ASP.NET

ASP.NET MVC 5: Session not working

Just encounter an issue with ASP.NET MVC 5, the sessions are not working. i.e. when I put a value in controller like Session[“mysession”], it do not shows the same value in Views or in fact anywhere else. Search online, some create custom classes to manage them, and some give different patch, finally got the easiest solution. Just add “Session_Start” function call in Global.asax file and we are good to go.

Categories
C#.NET Concept/algorithm Operating System

Refreshing USB ports using C#

Finished a project in which I need to refresh the USB ports by just before we start some particular benchmarking application my client has. Seems pretty easy job, if you know to gain access of system resource. But, it become fun job, when I found that knowledge of system is not even necessary for this job. Thanks to Microsoft’s `Devcon` utility, that already take care of it. So, in all what I have to do is just pass the correct parameter to it. The parameter is pretty easy, just pass the Hardware ID of USB port to refresh.

Yeah, that’s pretty easy. But …

Yes, but how we get the hardware id of USB port? Do we still need access to system resource for that? Well, it seems so. So we are back to square one. Well not really. I found a solution on web that points to `System.Management` namespace in .NET. What it does is it give you the list of all resources that are otherwise available through Computer management or such system resources. Here is main piece of code from article

public static List GetUSBDevices()
{
	List devices = new List();

	ManagementObjectCollection collection;
	//Win32_PnPEntity
	//Win32_USBControllerDevice
	using (var searcher = new ManagementObjectSearcher(@"Select * From Win32_USBHub"))
		collection = searcher.Get();

	foreach (var device in collection)
	{
		devices.Add(new USBDeviceInfo(
		(string)device.GetPropertyValue("DeviceID"),
		(string)device.GetPropertyValue("PNPDeviceID"),
		(string)device.GetPropertyValue("Description"),
		device.ToString()
		));
	}

	collection.Dispose();
	return devices;
}

This provide the list of all USB port in system, and then you can pass the “DeviceID” to devcon and we are done.

For further clarification:

Categories
Wordpress

WordPress: Custom Post Permalink giving 404

In most of wordpress project we do, we have few custom post type and taxonomy. We use a nice plugin called “PODs” for the same. It is good plugin, we try some other in different project and most of them serve the purpose pretty well. But today we found something, or rather just an overlook stuff. In our project we need a taxonomy to hold “year” of manufacturing for product, client request that year to be a taxonomy (yes, out client is intelligent and know such stuffs. So?). We follow him and quickly create a taxonomy with slug “year”.

Now, what we did is we broke the permalink of wordpress. It either work for our custom post permalink or default wordpress page. We spend 5 hours to realise that “year” is one of wordpress keyword in sense that wordpress use it for “archive” or dated url permalink structure. I didn’t go in depth of why and what got it broken, but since wordpress use year it is bad idea to use it. Infact this post is reminder for me to not to use words like year, month, archive, category, date, day as my taxonomy of custom post type. They are just not good. Period.

And advice of word for pods, or any plugin that allow creation of such post type. PLEASE, put some validation to stop user from doing such things. User may not read this blog post soon.