Categories
Continous Integration MySQL PHP Programming Project Management

Experience with BitBucket CI

I have been using bitbucket for quite sometime, and really like their service. Recently, I come to know that they have Beta of CI through pipeline, that can run any docker from Docker hub. I thought to give it a try though I have my own build setup on my local machine and really don’t need it. But why not test something new.

So, my project is regular website, which is coded in Custom PHP (no framework) and using MySQL database. I wrote some Unit Test using PHPUnit test, so all I need is to run those test when I commit to Bitbucket. It seems pretty straight forward as Bitbucket configuration example shows the configuration file for PHPUnit test. I pick it up, change path and run. My test failed, as they never get the MySQL extension for PHP. What? PHPunit test docker doesn’t have database extension installed? So, how we are suppose to test it?

Well, there are few ways, one is you use multiple docker (multi-docker environment) which I recently studied is available and I didn’t yet test it. And other is you create your own docker and use it. Install whatever you need to make it happen. Also, I realize that installing MySQL will not make any good unless I install database on it before test and change it’s certain values for testing. So, I create a new docker that has everything I need for my project, all PHP extension and database server. (You can use it from https://hub.docker.com/r/archergod/phpall/). Then I update configuration file to do following:

  1. Run MySQL service (yes by default docker do not initiate run.d etc, not sure why) and hence no service auto start.
  2. Then run `mysql` to import a Script (SQL) file to create and install database, and users needed. I put everything in that one SQL file and run it as root MySQL user. It is only a docker doing testing.
  3. then Navigate to Directory in respect to my Git folder as my default bitbucket leave your prompt at git folder.
  4. Run your test.

It does a great work, though every time you push to git, it create a CI request and download docker image, set it up based on BitBucket’s script and then run your script. So it take 2 minute extra to set the machine. If you are in habbit to push every 2 hr of work, then you end up running your test every 2 hr on every push.

But basically it is all good and is free too, which I like most. Though I have GitLab at my local machine and it works exceptionally great, but BitBucket’s CI is good and different. And in some cases is better than Gitlab’s CI.

Categories
Blog: My thoughts Operating System PHP Server Configuration

Linux Upgrade from 12.04 to 14.04: Save the day

So, this fine sunday, I think I wake with “lets spoil the day” mood. I start by checking my server to see how it is doing. A regular log view and updates I perform on my VPS. all was good, until I realise an update is available for my billing software. I decide to purchase an update for it. Before buying I forgot to check system requirement. Well it is just an update, and we install it every here and there for other things. So, I have updated copy of my billing software, which I follow the steps of upgrade and upload to my live server. All went well until I reach for software to suggest install PHP 5.6 instead of version I had. Well no problem how hard it is to update PHP in ubuntu 12.04, just matter of running apt-get.

Soon, I realise PHP 5.6 was never release for OS, and I need to use PPA. Found an old tutorial teaching me how to use PPA as it is my first time for it, the blog explain everything good, found couple more article but they are nearly the same. So, I went on and install the PPA and update the PHP 5.6. I run a command line to see what version of PHP is there and it correctly shows 5.6. So far so good, but suddenly “If anything goes wrong will go wrong” statement hit me. It only update CLI PHP not apache version. Damn, what is wrong with it.

PPA on Ubuntu 12.04 LTS need Apache 2.4 and Apache 2.4 never makes to Ubuntu 12.04. So, again there is PPA for apache but that doesn’t work for me well. I mean it does update few things, but cannot make PHP’s Lib for Apache to get installed. At this very moment, I have two options. Either I rollback all updates to my Backup Copy, or I move ahead to upgrade OS to 14.04 LTS. I choose later one.

Simply run “do-release-upgrade” and follow the course of stream. but it stuck as VestaCP’s APT repo didn’t work with upgrade. Not sure why, I just remove them from APT repo’ List and all goes well. All updated nothing is broken but Apache. It is broken because my previous attempt of PPA apache upgrade leave it broken and in conflicting state.

I remove and try reinstall apache without PPA, but that cause more conflict. After hit and trial with PPA and non PPA apache, I end up getting it upgrade and everything running.

There is no technical details shared in this post, as this post is not for Step on how to do it, but what not to do it. And that is only one thing, never miss reading about what upgrades you are going to do, never miss system requirement before paying someone. It only took me 4 hrs to get it all going, and frankly it turns out to be Positive for me, as it get my pending upgrade of OS done. But, I would have save my day if I read the simple requirement before buying the upgrade for billing software. I would have avoided unnecessary upgrade path, and reduce the down time to say 1 hr at most instead of 4 hrs. Good thing my blog is not a business, but never try that at client server.

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.