Skip to main content

Posts

Simple book keeping basics

There are tons of jargon on accounting. But a lot of them are rubbish that used for categorizing the incomes, expenses and Tax. What really matters are Balance Sheet and P&L (profit & loss) statement. If you really knows to read and understand these two then you know the basic language in business.  I'll go deeper on these if you guys interest or else please Google and read about these two. Let me share a real world example of what I am talking about. Here is the Access Engineering PLC / Annual Report 2015/16 http://www.accessengsl.com/wp-content/uploads/2016/07/Annual-Report-2015-16.pdf Please go to page 149 of the report and you will see the Statement of Profit or Loss. And on page 150 of the report you see the Balance sheet (they call it as Statement of Financial Position). And you can see it is balanced (of cause it is balance sheet) Total Assets = Total Equity and Liabilities Basically these are the things that people are supposed look at before invest...

My two cents on new year resolution

What is the plan for the new year ? - need to think on what are we trying achieve during next year 2018 - basically the life goals - may be personal or professional - and also it should be realistic (not something like going to Mars ;)) Why we need a plan for the new year ? - basically a goal without a plan is a DREAM - And also should be able to measure (what you cannot measure, you cannot manage) How to prepare a new Year resolution/plan ? - Leave some buffer time - Make changes during the year (life is changing/evolving) - Plan is only for you (do not share it) - When a milestone is achieved, celebrate - Try to stick to the plan - otherwise no point of planing

Assets and Liabilities as Rich Dad, Poor Dad explains

I was reading "The rich dad poor dad by Robert Kiyosaki" here is a one point that he mentions on that. Basically Asset as he says is little bit different than on books. If something puts money in your pocket it is a asset. And Liabilities are the ones that takes money out of your pocket. OK for example a house or a car may seems like an Asset but it takes money out of you pocket to maintain them. But if you rent them or make them to make money at the end of the day you can convert it to a asset. Basically that what rich people do. They buy assets. Middle class buy liabilities (thinking those are assets) and stuff (a lot of them that not used or that not needed). Lower class buy to consume (basic needs like foods).

11 Rules from Bill Gates

I watched a youtube video and thought to share with you all. Bill Gates recently gave a speech at High School about 11 things they did not and will not learn in school. He talked about how to feel-good. Politically correct teachings have created a generation of kids with no concept of reality and how this concept set them up for failure in the real world. Rule 1 : Life is not fair - get used to it! Rule 2 : The world doesn't care about your self-esteem. The world will except you to accomplish something BEFORE you feel good about yourself. Rule 3 : You will NOT make $60,000 a year right out of high school. You won't be a vice-president with a car, phone until you earn both. Rule 4 : If you think your teacher is tough, wait till you get a boss. Rule 5 : Flipping burgers is not beneath your dignity. Your Grandparents had a different word for burger flipping: they called in opportunity. Rule 6 : If you messed up, it's not your parents' fault, so don't wh...

Time Management by Brian Tracy

Was lucky to have a chance to watch a video done by Brian Tracy on Time Management. It was great and thought to do a short note on that. Here is the note and the video. Here is the note I took by listening to it. Goals - what is it you want to accomplish ? personal/family goals business/financial goals self development goals Plans of Action - put it in writing Analysis - Make a list (make the list of day before evening - to do list) Set Priorities - what is relevant and irrelevant ? what is the most valuable use of my time ? Concentration - Learn how ! - work on single task at time until it is completed Deadlines and Rewards - positive logical consequences. Time Log - where is all your time going ? Procrastination - positive or negative - Do it now! Do it now! Do it now! - get the job done fast Delegate - delegate everything you can - Clarity Think what you want done - write it down Pick the right person to do it Crystal clear on what you want done and wh...

Safari is randomly switching images on ios 5

Developed a Facebook app for mobiles and it was loading a lot of images through several AJAX requests. And was working fine on simulators tried and was given to Client for testing. But suddenly was receiving screenshots of the app that appears sooo wired. With the details of the versions and devise he was testing I just Googled regarding this and found it is an error or a bug or a mistake or something that happens on Safari on iOS 5. Best result found on this matter, http://tech.vg.no/2011/12/14/safari-on-ios-5-randomly-switches-images/ Successfully tested on latest iOS versions and also on few android devices and they were fine. My suggestion is please update your OS if you still got iOS 5.

Concat columns on GROUP BY in MySQL by Using GROUP_CONCAT

I was asked to give a report on the Invitations table as follows. What I wanted to give as the result is the invitee details per inviter. So simply I do not want to repeat the "inviter". Invitations invitee_name inviter invitee gayan          345         4654 kosala          345         7655 chamara          567         7653 nilanka          567         1236 So basic query for the demanding result is "SELECT * FROM Invitations GROUP BY inviter;"  But then what happens is some results are omitted. So I need to concat the "invitee" and "invitee_name" columns when grouping by 'inviter'. For this MySQL simply gives a function as “GROUP_CONCAT”. Details can be seen on http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_g...

Google API v3 with PHP using Blogger service

It was really hard for me to understand how the Google APIs are working at the first point and took few days for me to figure out. But after a successful working prototype it seems very easy. And also when I am searching for a simple example I was unable to find a good one that I can understand. So let me list down step by step what I have done with URLs and as simple as I can. Create a Google app location -  https://code.google.com/apis/console Switch on the "Blogger API v3" Get the latest APIs client library for PHP location -  https://code.google.com/p/google-api-php-client/downloads/list Upload the files to your host location on on localhost Extract the files to folder  named "GoogleClientApi" Create your php file outside of the folder  Copy paste following code into the file and do the changes as needed  By changing the scope and the service object you can access all the services that is given by Google APIs through the PHP API l...

A solution for PHP fopen from url issue

I had to read a web page and grab values and show on my web page by using PHP. The easiest way came to my mind was "fopen" . When I develop that on my local machine it worked perfectly but when I put that on live site it was not reading from external URL. If I need to continue on that I have to modify php.ini file to allow access which is not possible on  a shared hosting. So it was tie to Google and find a better solution. And I found one and thought to share it with you all. This following php code developed by knkk and was shared on http://www.webdeveloper.com/forum/showthread.php?t=230985 function disguise_curl($url) { $curl = curl_init(); // setup headers - used the same headers from Firefox version 2.0.0.6 // below was split up because php.net said the line was too long. :/ $header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,"; $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; $header[] = "Cache-Control: m...

Format Javascript

I had to analyze and change a JavaScript if it is required, but it was a big huge JavaScript file and all the code was on one line. So it was the time to find a good was to do format the JS. I found following site and thought to share it with you all. http://jsbeautifier.org/

Definer issue on MySQL

I had a main issue when I am trying to deploy a PHP, MySQL project by using CPanel. This might be occurred on any hosting provider. The issue is I have stored procedures on MySQL and when deploying it says I cannot deploy procedures which contains ‘DEFINER’ in it. So what I did is remove all the ‘DEFINER’ parts on procedures and executed the MySQL dump file. It went alright. But when we connect to PHPMyAdmin via CPanel the logged in user is same as CPanel user. On MySQL if there is no definer on a procedure it generates the currently logged in user. Now I have procedures with a CPanel user but my PHP code is connected to that DB by using a MySQL defined user. When I am trying to browse the site it throws an error saying Definer is different. Then I was in the middle of a dead lock. Then what I thought was to execute the create procedures by using PHP. Then definer will be same as PHP connected user to MySQL. So I had to write a PHP code to read the MySQL dump fil...

NASA - 2012: Beginning of the End or Why the World Won't End?

There is a big heho going on about the end of earth on 2012. But I like you to quote what NASA says about that. I believe what they say. Remember the Y2K scare? It came and went without much of a whimper because of adequate planning and analysis of the situation. Impressive movie special effects aside, Dec. 21, 2012, won't be the end of the world as we know. It will, however, be another winter solstice. Much like Y2K, 2012 has been analyzed and the science of the end of the Earth thoroughly studied. Contrary to some of the common beliefs out there, the science behind the end of the world quickly unravels when pinned down to the 2012 timeline. Below, NASA Scientists answer several questions that we're frequently asked regarding 2012. Question (Q): Are there any threats to the Earth in 2012? Many Internet websites say the world will end in December 2012. Answer (A): Nothing bad will happen to the Earth in 2012. Our planet has been getting along just fine for more than 4 bi...

Why Why there is no Trim function on JS

It was pretty bad when you find that the JS dos not have a inbuilt function on strings to do Trim. But not to worry. It can be implemented easily. function LTrim(str){ var whitespace = new String(" \t\n\r"); var s = new String(str); if (whitespace.indexOf(s.charAt(0)) != -1) { var j=0, i = s.length; while (j < i && whitespace.indexOf(s.charAt(j)) != -1) j++; s = s.substring(j, i); } return s; } function RTrim(str){ var whitespace = new String(" \t\n\r"); var s = new String(str); if (whitespace.indexOf(s.charAt(s.length-1)) != -1) { var i = s.length - 1; while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1) i--; s = s.substring(0, i+1); } return s; } function Trim(str){ return RTrim(LTrim(str)); }

Download file by IE error with SSL

It took a long time to figure out what was going wrong since on all the other browsers the file was able to download but IE (6,7 & 8) . Tried a lot of things which the forums said but at last at last found the solution. Microsoft agrees this as an issue of IE and they have given the patch here.  http://support.microsoft.com/kb/323308 And also if a header was added as  "CACHE-CONTROL":"NO-CACHE" it will not work on IE even with the fix MS given. It should be changed as "Cache-control:no-store". 

JQuery API control functions

Image from hoth.entp.com I was doing JavaScript for few years and it was little bit hard to work with "write less, do more" at first few times. Always it comes to my mind as JavaScript (yes I know it is) so I am trying to apply some functions as document.getElementById. And when I wanted to hide and show elements it was style:none and block.Those look bad(when a better way is there) on jQuery and some of them may not work on jQuery elements. OK I am not here to teach you neither JavaScript nor jQuery. For the people like me it is strongly recommended (by me of course) to take a look at the available and right functions on jQuery API official site .t I just found that and thought to share that. If you got a better place or some useful links please share it.

A JavaScript Alert as I want

There are alerts and confirms on JS as you all know. But its look and feel is same old style. I was curious whether we can change it. Of cause we are normally using a div tag and apply some styles to the background to gray out. Then we can use it as a function and call it whenever we need an alert. Isn’t there a better way to do that? I mean much easier way. So what I have tried to do was override the alert functionality on JS and give a customized method to do the job. So then what happens is we don’t need to change the code on each and every place where it used alert(“this is message”); . I have found the way to this on http://slayeroffice.com/code/custom_alert/ This place can be changed so I have pasted the JS code also in here. // constants to define the title of the alert and button text. var ALERT_TITLE = "Oops!"; var ALERT_BUTTON_TEXT = "Ok"; // over-ride the alert method only if this a newer browser. // Older browser will see standard alerts if(docume...

How to call a web method by JavaScript

I didn’t get a time to write something here for a long time. Yes I can say I was busy. (But I was not :)) Anyway I thought to write about something finally and I promise (this is a serious promise) that I will try to do something (do a posting actually) on my blog more frequently. The ability to call the web methods by JavaScript on .net is very very useful and we can implement the web pages more efficiently by using this. For example we do not need to send whole page and update. Yes this is AJAX (that what I think). Here is a web method example. It should be on the aspx page code behind and should be a static (shared) method. I have tried to insert the web methods on user controls and was unable to do so (if you know a way please share with us). This is on VB.net. _ Public Shared Function GetMyData(ByVal studentID As Integer, ByVal schoolID As Integer) As Student Dim studentService As New StudentService() Dim result As Student = studentService.GetStudent(studentI...

JavaScript confirmation disables validation

I had to do a JavaScript confirmation before I perform the post back on a web form. What I have done is just call button.attributes.add("onClick", -- ) and added the confirmation. It worked fine and showed the popup and did the post back if I clicked on the OK button. But if I have implemented some validations on the fields they doesn't fire them if the validation fails. For example if there is a required field validator the post back happens even without the values for that required field. what I want is to do the validation and then do the post back. Luckily I've found a solution at http://forums.asp.net/t/963412.aspx?PageIndex=1 by sukdeb . function Validate() {     var yes=confirm("Update this application?");     if(yes)     {         Page_ClientValidate();         return Page_IsValid;     } return false; } <asp:button runat="server" text="Button" onc...

Sort Fields which contains both Numeric and Characters

It was a long time since my last post. Finally I got something to write about. Store Procedures … something I hate most of the time. But today I felt good about them because I was able to find a solution for a sorting issue. The particular column contained data like “98ABC-76543-DEF-12345-GHI 10 ” and also “GHJ 23 ”. I was supposed to sort this field on Numeric value for the last part in red . And for the other parts it should be treated as Numeric for the Numeric parts and as Strings for the others. So what should I do was to split all parts and sort them separately and get numeric part in red and sort. But wait a minute do we have to all the things??? I don’t think so... I have found ( actually one of my friends ) an easy way to do that. Here it is. SELECT [name], RANK() OVER (ORDER BY CAST(PARSENAME(modifiedName, 5) AS nvarchar ), CAST(PARSENAME(modifiedName, 4) AS INT ), CAST...

Show an animated gif onClientClick

To show an animated gif, something like loading onClientClick is a simple task. You just have to add a JavaScript function on the click event so the JS function will take care until the next page loads from the server. Inside the JS function we just have to hide the excising div and show the div which contains animated loading gif. I have done it and it works fine on every other browser except IE. On IE the gif is shown but it is not animated. I have to do some R&D and what I found was IE doesn't do anything like that when it is loading another page (communicating with server) and was commented as a feature limitation of IE. But there should be a way to do that, that's what I was thinking and I found a pretty simple way to do that. Here it is and if you have a better way please share it here. <div id="divProgress" runat="server">   </div> <div id="Div1" runat="server"> The web form comes here … </div>   The J...