Monday, August 10, 2026

Exporting and Importing all MySQL databases

If you are having troubles in importing mysql dump file, then re-export source mysql with the --add-drop-table and --add-drop-database flags. This forces the backup file to clean up the target server automatically during import.


Export with drop flag

mysqldump -u root -p --all-databases --single-transaction --add-drop-table --add-drop-database > all_databases_backup.sql


Import normally:

mysql -u root -p < all_databases_backup.sql

Use code with caution.

Monday, September 9, 2019

How to duplicate a column in mysql

I wanted to copy a column's data into a new column in my MySQL database or rather say I wanted to create a new column and copy data from an already existing column in same table.

If you too want to do the same just issue below commands either in MySQL console or SQL tab in phpmyadmin:

ALTER TABLE `table_name` ADD `new_column` varchar(700);  
UPDATE `table_name` SET `new_column` = `old_column`;

First command creates the new column. Change the "varchar(700)" to whatever you want.
Second command copies the data from old column to new column.

Friday, May 25, 2018

Letsencrypt renewal command thats working for me

I had problem with my configuration for letsencrypt certificate so I searched a little. I did not wanted to waste too much time in fixing the configuration. I just figured out how it will work for me.
I am noting down the renewal command here for further usage.

I am using the standalone method for renewal so first stop the nginx server to free up the port
service nginx stop

then run this command for renewal:
sudo certbot certonly --standalone --preferred-challenges http -d domain.com

Thats it

Saturday, September 23, 2017

Joining two hobbies this time

I am a huge fan of creating forums. They are easy to make but very difficult to make them successful. My first successful site was a forum that grew up to 60,000+ members and thousands of posts.
I also look up hostings and servers very frequently. Even though I do not buy them but still I like to surf around looking at them. I never made a successful website about it though.
This time around I am joining these two hobbies of mine and making a web hosting related forum webhostinghelp.org.
I recently purchased this domain and installed discourse.
I am finding it very comfortable working on it than the one health-related forum I tried to make earlier.
Have any question about web hosting, VPS or dedicated servers you should ask it in this forum.

Sunday, August 27, 2017

Two new websites

I have been planning to do this youtube video making thing for quite some time now and once made one or two videos too. You can find them here. But never managed to do it long term.
I taught in a dental college for 3 years and learnt that most of the students were struggling in my subject human anatomy and it was mostly because we were teaching them in english.
English and all those new words in anatomy were making it very difficult for students to understand things as almost all of the students were hindi speaking.
When I started teaching them in hindi they responded very well.
My classes saw more attendance than other teachers and students learnt and enjoyed far more.
After I left that job I thought about making videos of what I was teaching and make them available for new students. Never managed to do that.
Recently I registered this domain hinditutorial.in and now I am planning to make not only the videos for anatomy students but videos of whatever I know and put them on youtube and on this website too.

And now about the second website.
Recently I started observing that I like to optimize websites for fast loading and actually wasting a lot of time doing it.
As Google also ranks websites with faster loading time higher lots of other people also do that.
So I registered this domain fastwebsite.org and I am going to write whatever I have learnt about website optimization and server optimization for faster websites.

The first website will need a lot of work but the second will not.

Lets see what fate these websites hold.

Sunday, March 19, 2017

I am missing something

I have learnt so much still very little productivity.
I need to figure out what I am missing.

Saturday, March 18, 2017

Political

Most of my life I have been apolitical. I never found politics any enjoyable but in recent years because of all the political discourse on social media I gained interest in it.
I went inactive on Facebook few months before 2014 general elections because my known people started posting lots of fake/propaganda statuses on Facebook and I found it annoying. I left Facebook because if I told them the truth many people will take it as personal insult and if they don’t get offended the discussion will waste a lot of my time. Staying silent was not peaceful for me.
The party who was doing most propaganda actually won in that election.
I thought the propaganda will stop after the elections are over and I will return to the old merry Facebook again. Rather the propaganda became more and more aggressive and that is still going on. This made me sad.
I got more active on twitter as not many of my friends are active there thus less chances of loosing friends there.
Doing so I gained some knowledge about politics and I am finding it rather amusing now. Yes sometime annoying too. So decided to write about my political thoughts so I can get some clarity of mind. This is important because politics is so confusing that you don’t realize when you becomes a hypocrite.
If you support a party you start supporting it no matter what. The party or its leader may be doing wrong but as you are their supporter you find a reason to support them while opposite goes with the other parties.
This time around I am choosing a topic that is in news currently and I think is going to explode in coming elections. I am learning about it and making a blog on it.

Lets see how it goes.

Monday, September 12, 2016

Life is too short to..

Life is too short to be shy.
Life is too short to satisfy your ego.
Life is too short to do things other wants.
Life is too short to not to fight for what you want.
Life is too short to give up something you love.
Life is too short to not to be with people you love.
Life is too short to waste in keep saying no.
Life is too short to not to take risks.
Life is too short to not to make mistakes.
Life is too short to not to play with your kids.
Life is too short to miss the memorable moments.
Life is too short to keep procrastinating.
Life is too short to holding yourself back.
Life is too short to stop your heart take control once in a while.
Life is too short to hold your head high.
Life is too short to have that body you always wanted.
Life is too short to not live the life you should.
Life is too short to keep doing chores.
Life is too short to finding your peace.
Life is too short to keep sleeping.
Life is too short to..

Friday, May 13, 2016

To be successful

You will have to do chores.
You can't be special all the time.
Talent is not enough.
Working hard and learning is not enough.
Success lies in doing routine work better.

Sunday, April 24, 2016

Discourse or nodeBB

Serious confusion.
Can't decide between discourse and nodebb. Discourse is perfect, other then its looks and more importantly its initial load size. Whereas nodeBB is around half in size for initial load but its buggy with many things like mod_pagespeed, Cloudflare etc. All this good in discourse but initial load size is big turnoff for me.
I really liked flarum but don't know when will it come out of beta. I am OK with beta if its working decently but developer themselves are advising strongly against using it in production. So its gone.
While evaluating I am not counting the server requirements here. Nodebb works on far lesser resources than discourse, which won't even start on Server below 1GB RAM and recommended is 2GB RAM. They say even with lesser resources nodeBB can serve far more users than discourse.
After the initial load nodebb and discourse are almost on same speed. May be nodebb is a bit snappier.
What I notice is that while nodebb Developers have focused on all the fancy stuff like chat system, theming, UI etc discourse developers have focused on doing basic forum stuff nicely. Discourse looks very well built and everything goes very smoothly. You get lots of finely thought out functions in discourse whereas in nodebb you get those old controls that we are seeing since vBulletin but mixed with fancy stuff.
With what i have written above you can guess i am inclined toward discourse a little bit. But the main problem is i am planning to build an Android forum and i suspect initial load size of discourse is going to cause some troubles on the mobile devices specially the cheaper ones with less RAM. Even one of the lead  developer of discourse says JavaScript performance on Android device is a serious problem and you are bound to lose visitors who visit your site from Android devices. And here i am planning to build a forum for Android users.
Gotta think more and decide.

Wednesday, March 2, 2016

Clear mod_pagespeed cache

This command I found somewhere on the internet is working for me on my ubuntu 14.04 vps.
touch `grep "^ *ModPagespeedFileCachePath" /etc/apache2/mods-enabled/pagespeed.conf | awk ' { print $2; } ' | sed 's/"//g'`/cache.flush

Monday, January 25, 2016

Reading Parse.com docs

I got less time to do my things today. Most of the day went by playing with my son as maid took leave today.
Most part of the remaining time i read parse docs. Learnt a lots of new things about parse and also got some ideas out of it for my app.
When i turned on my system to work I managed to get the comment thing sorted out.
Actually i never mentioned it before here. So here it goes.
In MySQL i was using id for the content that were integers and they were getting incremented automatically on every new row added. I was using this id in the comments table to label which content this comment belongs to. Easy stuff that is.
But here in parse they use NoSQL database that doesn't give auto incrementing integers as id rather they give a alphanumeric objectId. So if i add a new row to content it will not generate same type of integer id so i will have to use objectId in comment table to link comments to newer content.
Now the problem arises how to write the query because old content will not have new objectId in comments and new on will not have the old content id.
To sort this out i needed to add objectId of the content to all the respective comments. I couldn't do it manually because there were 22,000 comments in all.
I needed an automated approach.
I had two options:
1. I use the cloud code facility that parse provide. To use it i needed to write a JavaScript function and run it on the data.
2. I extend my existing android code and update the ids using the app.
First option was little difficult for me as i have never done any of that stuff before. I mean i never used parse cloud code or the tools required to write cloud code. And also i never wrote such a JavaScript function before. But it could have been a nice learning experience.
I chose second option because it required very less time in comparison to first one and also i could track the changes i was introducing with android logcat, so i would not corrupt the data. Although i backed up all data before hand.
I wrote a java method that pulled all the comments attached to old content id and then update each of them by inserting new content objectId in it. I could have done it to all the data at once but i chose to go with one at a time approach. I tapped on the content and all the comment rows related to that content got updated and i tracked it in the parse interface and logcat window.
Took time but finally managed to update all.
Finally i updated the query to use the objectId rather than old content id in the android app to pull the comments. Working nicely.
Yesterday i updated the android app to send objectId for new comments so nothing was required to change in that method. 
Reading through the parse documents i learnt about the caching the data in device so i won't have to query it every time i needed more data. Nice function. Would use it. It will make things faster. Tomorrow will try to implement this caching thing.
One thing that went unexpectedly nice as i switched to parse is that when i was using JSON to get and sent data to and from app i was not getting the emoji working. They were changing into question marks. But now i can use all the emoji in content as well as in comments 🙌.
Later.

Sunday, January 24, 2016

Moved to Parse

Yesterday i mostly read few things. Also downloaded and installed the Mac updates. Was tired in the evening so slept early.
Yesterday while reading through Google app engine docs i came across this service called firebase. Its a service built in keeping in mind making it suitable for mobile backend. Looked promising to me and thought of using it rather than going to google app engine. On app engine i will have to write all the code both Android and python app engine app. Will also have to check all the caching and other optimizations. I already wrote earlier that i am no expert in either python or app engine so it will mean i will have to learn much.
While browsing through firebase docs and pricing model i remembered i tried using parse.com before i moved the PHP api to my VPS from appfog. I found it difficult at that time because i was not that fluent in java then. I am more familiar in it now so i compared the pricing model of parse, firebase and google app engine. I found using parse will be much economical and easier to me than using other two.
I am planning to serve images too along with text in my app and parse give more space and bandwidth in free tier than other two and also they have well cooked SDK that will fasten up my development speed. I will also won't have to write the cloud code on my own.
I had already imported the data when i earlier tried parse to i only had to write the android code using parse SDK today. I managed to write it very quickly and found a bug in the parse SDK. I found two workarounds and now my api is up and running on parse.
Will write a post about the bug and how i managed to workaround.
I must confess if i had little patience then when i tried parse earlier i won't have wasted so much time in writing app engine code and all. But then parse SDK has bug that made it impossible for me to make it work with my little knowledge.
Also, parse is not zippy as my app engine code is. But its workable and my development time is significantly reduced by using it.
Now i am reading parse docs so i won't get caught up this time in the bugs and other possible problems.
Later.

Friday, January 22, 2016

हिंदी ब्लॉग

एक हिंदी में ब्लॉग बनाने का मन है। क्या कहते हो बना लें?

Too little productivity

Most of the day passed in trying to solve the problem, about which i wrote yesterday, my Mac was facing since few days. It was not loading few website while other websites were loading fine. The problem was not with the network or the router as other devices connected to same WiFi were working fine and loading the same websites well that my Mac was refusing. Even the phone with which i am USB tethering Mac was loading the problem pages fine. So it was the system issue. I was most concerned of the chances that my Mac has caught some kind of virus that is doing all this. Although I have ESET smart security pro installed on the system, not all viruses get caught in the filters.
I tried changing the DNS to all the possible values but to no avail. The problem persisted. I cleared the DNS cache many times but nothing changed. So i searched and found posts with similar problems and the solutions suggested didn't worked for me. I did a lots of trial and error and finally downloaded and installed the newest security update for the operating system Mac OSX Yosemite. Don't know its because of it or because of any of the numerous tit bits i did before installing update my system started working fine and now all the pages are loading nicely.
Clearing of DNS was another issue in itself. Apple changed the commands few version back and then they again switched it back so which command will work and which not was to be found with trying all the commands.
Now what i did productively today is i finished the api then created new project in app engine, uploaded the api to app engine and imported the JSON into the datastore. I did not try to import comments today. Will try it out tomorrow.
While testing the api by updating URLs in my android app i noticed the textviews were jumping when ads were loading and that wasn't looking good so i spent some time in fixing that. Finally managed to get it to not jump.
Also i noticed that when i am pulling data from the datastore to build JSON i need to check that the data is fine before saving it to memcache. Its because if the data is not successfully queried then i will save the empty or wrong JSON in the memcache and all the subsequent request will be served with that wrong JSON. It will spoil the experience completely.
I also added the comment queries to the memcache. There also i need to keep check of the data.
Its 2 am already so
Later..

Thursday, January 21, 2016

Lazy day

Today was cold and lazy day.
I wanted to just lay down and not do anything, but you know.. 😔.
So i managed to import the api data to app engine datastore by pulling and parsing JSON from my current api. Actually i have imported 1 table and 1 more yet to be imported but that is not important. Even if i don't import it, it won't effect a thing but i will try to do that just for the sake of learning.
I tested the new api with my app and its working flawlessly.
I imported the data in local datastore, but the script will import it well in production server when i upload the project to app engine. Tomorrow i will be making a new app engine project and upload the api files to test it again.
I also learnt how to use memcache on app engine. Although it was just few line of code but it makes a huge difference in performance and server costs. What you do here is that you check if the data you looking for is saved in the memcache or not. If its there you serve it right away from memcache. If not you pull it from the datastore and save a copy in  memcache and also serve a copy to user. When next time that data is needed you pull it from the memcache and serve it without doing the roundtrip to the datastore. Memcache, as the name suggest is space in system memory(RAM) that is very fast compared to the disk or datastore so performance improvement is very good. And also app engine gives you restricted queries to datastore in free plan so you save that too by using memcache. If you Move to paid plan you will save cost by using memcache effectively.
I think i need to again read the app engine docs. I read it long back and now i have to look up every time i plan to do anything. This looking into is taking too much time and slowing me down considerably. 
Parsing JSON with python was new experience to me. I used simplejson to parse it. That doesn't mean i have learnt it. I found a sample code and adapted it to work by trial and error but afterward when i looked into the code it looked just like java code i wrote in my android app to parse the same JSON. Just a little syntax difference. Will read little more about simplejson. It will come very handy in long run.
As i have never learnt python in the way i should have, i feel little under confident writing the code but as i write it more i find it far more easier to write and way cleaner than either PHP or java. And writing app engine apps using webapp2 is a bliss compared to writing a vanilla PHP code.
In other news ,for some strange reason i am finding that my system is not loading few websites. It just keep on loading and doesn't show anything. If i try same pages from my phone using the same WiFi connection it loads in a jiffy. Don't know what's the problem. Will try to fix it. May be the problem is in the DNS. If it is then its a quick fix. If not then its going to be headache for me. Just chimed in that the problem may be in the host file i edited recently. Will look into it tomorrow.
What more..
Yes I updated more softwares.
Enough typing on phone on this cold and lazy day.
See ya..

Wednesday, January 20, 2016

Software updates and api testing

Today went by updating softwares which i was delaying for some time.
My shitty internet connection was not allowing me to do the updating. Today i installed a download manager on my phone and downloaded all the updates while doing all other works. When i started my system i had all required softwares to start with updating.
I managed to build the api for my android apps using python and tested it with android emulator. Will try with live api tomorrow.
Tomorrow i will try to figure out how to import the data from MySQL database into app engine datastore. I thing i will be able to write a script that can pull the JSON from my old api and put the data in datastore.
If someone read my last post he will wonder why i am trying to move api from PHP to app engine. Its because i use a VPS from VPSdime to host my websites. Although it's powerful enough to withstand the api along with my websites, I still find it far less reliable to host api. Why i think it's OK to host website on that server and not api? Think it this way, if someone downloads my app and opens it for the first time and my server is slow or down at that moment the person will uninstall the app right away and my app will never going to find space in that phone again. Worst case scenario he will write a bad review and give 1 star. And that's not good. A website visitor may try again visiting the page later in time if it's down but app user has to download whole app to use it again. That is too much friction.
Also learnt how to show/hide hidden files and folders in Mac. In doing so i had my first introduction with bash scripting. Will write a post about it later.
See ya

Tuesday, January 19, 2016

App engine java python and more..

As i wrote in last post i am planning to use google app engine to host json api for my android apps so today time went into it.
I was using PHP to generate JSON from MySQL database. PHP makes it a breeze to generate JSON. Only few line of code and you are all set. App engine also support PHP but SQL is paid so i am not using it. Not because of the cost but if it can be done with app engine datastore using python or java then why not do it.
I am not fluent in either python or java but have workable knowledge and also know how to find the answers if stuck.
Today i managed to figure how to generate JSON from datastore using  python. Done it with help of django simplejson module.
Reading through the app engine docs i also found it interesting to build a backend using java. Android studio makes it real easy to go through the process but my internet speed killed all the fun. I could have built the whole api with java today but my system spent hours downloading the app engine java SDK and i think that too isn't perfectly working. I tested 2 modules one cloud endpoint and other java servlet. Endpoint one was not running perfectly. The time it took to download java SDK i managed to generate json using python.
Also my Mac(actually hackintosh) was refusing to load the page using "localhost:8080", which is default, as address. So i edited the host file and still nothing worked. When i changed the default port from 8080 to 8888 it started working.
Also genymotion refused to take "10.0.2.2:8888" as address to local api. I had to turn on the android emulator to get it working.
I hope tomorrow i will complete the api and also build the basic app to work with that api. Later i will polish the app.

Again..

Again a big break 😞
Just not getting into the groove.
Good thing that happened in these days is that i continued with all the health stuff.
I managed to loose around 10 KG of weight. Bad thing that came with it is that all my recently purchased clothes are not fitting now😒(but i can now get into old clothes. yay!! 🙌).
Started sleeping early😴. Feeling more refreshed 🙆because of it. Could feel in the morning that i have slept enough which was not the case when i was working late and sleeping even more than what i am at present.
For last few days I switched off the computer to take a break from the work and now getting back into work mode again.
Shifted my desktop to another room to work without any disturbances.
Could write java and android much better now. Planning to launch few apps that does not take much time to build but will earn a penny or two everyday.
Last time i built the JSON api for my android apps on PHP and hosted it on appfog free service. Now as appfog has shut down this time I am planning to write the api in python and host it on google app engine.

Lets see how it goes.

Friday, August 7, 2015

Health First

If you want to bring some positive changes to your life then you should always start with health.

With all the online activities, learning and reading new things I have acquired all the wrong habits regarding health. Mainly what I am doing wrong is I am sleeping late and sometime I even sleep after the morning sun has started shining. That making me rise late and that in turn making me skip breakfast and directly having lunch. So the gap between dinner and my next meal is about 15 t0 16 hours and that’s very bad for the health. This habit was making me feel tired all day.

I was rarely doing my regular exercises and also doing only desk job is not helping me with getting physical activity that in return making my body weaker everyday.

When I thought of changing my habits I thought of joining gym but as I suffer from chronic backache since my college days I thought I should first check whether my body is able to handle the stress of heavy exercising. I downloaded few apps on my phone with some daily exercises one can do without any gym equipment. I am doing 10-12 different kind of exercises for last 8 days regularly. It was very difficult in the beginning to do all those sit ups and crunches and I thought it will take a long time for my body to get use to it but I am getting surprised everyday that how quickly my body is adapting to all these exercises and now I am already thinking about either adding more exercises or increasing the number of sit ups and crunches.

Doing all the internet marketing things has taught me whatever I do I should track as much as I can. So I purchased this Xiaomi Mi band which tracks my daily steps taken and also my sleep pattern. Its not perfect but at least its giving me something to categorise my daily activities. What I have tracked till now is telling me if I continue with all those bad habits I have acquired my body is soon going to be screwed.

What I have in mind now is One, I have to change my diet both in terms of timing and quality. An app I have downloaded says I am already taking less calories than the required, still my weight is above average so I need to change the quality of food I am eating. I am taking too much carbohydrates and very less proteins. That need to be fixed.  Secondly, I need to gain enough muscle strength quickly so I can join the gym and start with some exercise routine.

Lets see how things folds. Will update soon.