Posts

Generate Date from a range in Mysql and pad the results where no date is present

If you want to generate dates, MYSQL doesn’t have a range function, so I wrote a work around for the same. So how  it works is I have reused a code to generate numbers from my previous post. So I added date function to that query and reduce the generated  …

Operator Preference Grouping Order in C

Here is a compilation of how the preference of operators are Left to Right grouping or Right to Left grouping in C. Level Operator Description Grouping 1 :: scope Left-to-right 2 () [] . -> ++ — dynamic_cast static_cast reinterpret_cast const_ca …

Simplest way to remove trailing zeros of decimal numbers

This is a simple method I found to remove or strip trailing zeros of a decimal number. The function accepts the decimal number and return the trimmed value back. It removes all the redundant zeros in the number after the decimal point and if no number othe …

Batch Insert/Update for Mysql in Java

Large inserts/Updates are a costly operation. One foolish way that I used to do is to run each update or insert query one at a time. Its incredibly slow. With most of the systems currently the latency is what is killing the performance not the CPU. Hence l …

Group by Date when Stored in Mysql DataBase as Date Time

I have a table called date_count with 2 columns one is a value and another is a date time, say called date_time in mysql. Date Time in mysql is stored as dd-mm-yy hh:mm:ss. The issue comes when I need to get the number of rows per day. As its stored as dat …

Generate 1 to 1000 in mysql

Sometimes its necessary to have thousand rows to join or generate new values, we need to get the thousand rows first. For this I used union of numbers 0-9.  I have joined four of these to get to four digit values. So here is the code:



SELECT @row := …

Automatic Command Archive

The default command storing size of ubuntu is 500 commands. It stores the commands in home folder in the file “.bash_history” . The problem is 500 commands is too short of a size. One method is to increase the command size to a large value by changing the  …

How to Format a Usb in Linux

There are two methods of formatting a usb in linux that I use. The first method is using gparted (or parted non gui version of gparted). This is an easy gui interface that uses shell commands as backend. It is easy to do it. You install this package usin …

Installing Django on Dreamhost

Installing Django in Dreamhost and getting it to run wasn’t straight forward at-least to me. There was lot of issues such as python bin directory not accessible as its shared and so. So the initial step in this to setup python yourself so that you can use …

Download PHD Comics,XKCD and DogHouseDiaries for Offline Viewing (E-book Reader)

If you are like me who wants to read comics on kindle then this is the script for you. You can download all the comics to read it in a kindle. So here is how you do you do it. Download all the comics into 3 different folder s for each comic set by running …