Blog

The blog is mostly about recent roadblocks I encountered while working or something that eat up lot of time solving, I share it here for my personal future references, apart from that recent small snipts of codes, or whatever I feel like posting when I have nothing to do.

Elastic Beanstalk deletes EFS mountpoint during deployment

posted Mar 19, 2017, 11:00 AM by Ankit Sharma   [ updated Mar 19, 2017, 9:49 PM ]


I like aws elastic beanstalk to deploy high availability and scalable php applications without worrying about the underlying server operations. Recently I was a testing EFS for zend application, here is the sample directory structure of Zend Framework 3 app:
config
vendor
public
module
data

As I wanted to share the `data` directory between EC2 instances, I thought to try EFS to share `data` folder between instances and so i created a EFS  outside of beanstalk and used .ebextensions to mount the by providing the ID in the config script.

After the first deployment, everything went smooth. But after 2nd and 3rd deployed, I noticed an error in application and to my surprise the data directory was empty, even though it was showing as mountpoint.

I thought may be the EFS was not mounted properly or EFS is having downtime, after checking everything, I concluded that EFS is indeed empty, and now the question is how?

After doing few sample deployments I found out that the Elastic beanstalk during deployment deletes everything in the whole /var/app/current directory and copies the new application code, which indeed deletes the data folder, which is a mountpoint of EFS.

I think elastic beanstalk should use CodeDeploy to deploy the app which would have given error during deployment if a non versioned file is found, rather then deleting all files and copying. Otherwise I am not sure how EFS can be used in elasticbeanstalk unless you are mounting the directory outside of /var/app/current, because `eb deploy` will delete the all content of data directory everytime.

Thankfully i was working on dev environment and only lost of about few Mbs of application's data files.

Clear Google Spreadsheet content daily

posted Jan 19, 2011, 8:43 AM by Ankit Sharma   [ updated Jun 25, 2016, 1:30 PM ]

Recently a potential employer posted a Job on odesk, wanted a script to clear the Google Spreadsheet content daily using Google Spreadsheet PHP API. I told him about Google Apps Script, and how we can use it to achieve this as using PHP API wasn't a requirement.

Using Google Apps Script we can clear the content of the Google Spreadsheet daily or on specific time of the day.

1) Open the spreadsheet and click Tools > Script Editor.



2) Copy and Paste the following Google Apps Script

function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet(); // gets opened spreadsheet
var menuEntries = [ {name: "Clear", functionName: "clear"} ]; //adds menu
ss.addMenu("Script", menuEntries); //adds submenu 'Script'
}

function clear() {
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheets(); // get all sheets
ss[0].clear();  //we can set which sheet to clear
}


Save and give relevant name to the script.

3) Set Trigger to execute the 'clear' function at midnight  
    Triggers > Current Scripts Trigger > Add New


This script also adds a new menu to toolbar, Scripts > Clear
We can set different type of triggers, for more read script guide.

-
P.S. Tad, Enjoy!

My First Video Testimonial

posted Jan 18, 2011, 6:43 AM by Ankit Sharma   [ updated Jun 9, 2011, 12:15 AM by Ankit Sharma ]

Recently got my first Video Testimonial from one of my employer Mr. Gavin Allinson, a Sports Nutritionist, as I don't have a Video CV of myself, this reference stand top of my testimonials, So decided to post it on the blog.



Since I started freelancing after my college, I have worked on about 100 projects across oDesk.com and vWorker.com. Its been nice learning curve to chat & work with clients across the globe.
It always feels good when your hard work is appreciated. I no longer look for new projects unless I am really really free or really bored with what I am doing, my old clients employers/clients always come up with new work to keep me busy. So if you are interested in hiring me, I am just an email away.

Here are some of the many feedbacks that made me feel good:

I was very fortunate to have found him, since I had to go through too many developers before we found him, and finally settled in his expertise. As far as his work goes with our company, everything you see on the site has been coded by Ankit. We provided the desired layouts, the blue print so to speak, and from there he performed what I like to call magic. I say magic because we had lost hope with the offshore developers. We thought it was either a language or cultural barrier for being over promised, but always left disappointed. That is until we found Ankit.

I like to compare Ankit with Steve Jobs' philosophy where he and Apple as a whole always under-promise to analysts, but end up far exceeding expectations. Furthermore, if he cannot do something, he will tell you so, and that we found quite refreshing.

I hope I have been able to satisfy your inquiry about him. Had you asked about the previous developers I would either have not bothered to reply, or just said no comment, or given a scathing review.

And

Short review: Epic Awesomeness!

Longer review: Ankit is a jack of all trades. He has an amazing ability of not only being an amazing developer, but he has what most engineers develop – creativity! Additionally he has an amazing sense of humor that had us cracking up into the wee hours as project was coming along. He also has a good eye for things that look out of place, goes not only the extra mile, but more like an additional marathon to ensure there are no holes left at all! I could write about him forever simply because of the satisfaction he has brought to our site, the quickness, sharpness, and consulting as well on site elements!

We will hire him again, and again! And we already have to projects coming to fruition which we will hire Ankit for!

Ankit, THANKS from all of us at AccessoriesforiPhone.com !!!!

And


Words cannot describe Ankit's work ethics, skills, knowledge, approachability, and creativity – something which in my experience most engineers lack. As I have said before, I could write a book about Ankit and how great he is, how quick, efficient, honest, overall great engineer, and person, but it would not do him justice for my words would always fall short.

Hence, I part with these simple words. Ankit is AWESOME!

-Mr. Yashar Marcelo Ahmadpour
Accessories For Iphone




I HAD GREAT WORKING EXPERIENCE WITH ANKIT, 3 OR 4 TIMES BETTER THAN SO CALLED PROGRAMMERS U SOMETIMES FIND ON ODESK.

I GOT WHAT I NEEDED THE SAME DAY WHILE OTHERS TOOK WEEKS TO FIGURE OUT.

THANK U WE WILL WORK SOON AGAIN.

LEA

-Mr. Lee Goodman
mGlobe Network




I have worked with a lot of providers, and I must say Ankit is by far the best one to work with. We have been able to complete jobs together in half the time as others quote the job for, and he understands 100% what is needed on his end for the job. I am sad to see him leave, but will look forward to working with him again.

-Mr. Nick Kremer
Nine Dot Systems




Wish I could give him a higher rating as he's like a 20 out of 10. Great communication, lightning fast turnaround and a joy to work with. I think I might start to consider him my IT web guy! If you are thinking about using him, stop thinking and go for it as he is the best out there.

-Technomonkey




Very very excellent friendly coder. Easy to talk to and very knowledgeable about alot. A+ and also very affordable then most of the other prices other coders offer. Will definitely use services again in the future.

Thanks Ankit

-CakedUp




I certify that Mr. Ankit sharma of India - Jamnagar has done a job of Web-site design and its implementation for my organization.

He is also our Freelance Consultant for IT and software related projects across India.

As a person Ankit is very sincere and hard working. He is expert in his related Subjects and is able to finish the assign job in time.

-Mr Khushal Trivedi
TRiVEDI Computers


Get rid of Auto Enclosure of Media Files from Wordpress Feed

posted Nov 16, 2010, 9:43 AM by Ankit Sharma   [ updated Nov 16, 2010, 9:54 AM by Ankit Sharma ]

Wordpress Logo
When you add any media files link in wordpress page/post content (mp3, asf, wmv, avi etc), it creates a automatic meta key(Custom Fields) in the post called "enclosed" with value as actual path of that media file.

Furthermore, the Website feed(RSS)  embeds the enclosed media as  a link "Download Now" or "Filname" linked to the actual media file.

It creates problem when your website have regular posts with media links for eg. podcast, background music etc. hence the feed subscriber get a download link in their feed subscription.

Just paste the following lines of codes within your themes functions.php file, and then, say goodby to automatic enclosures.
(/wp-content/[yourthemename]/functions.php)

function delete_enclosure(){
    return '';
}
add_filter( 'do_enclose', 'delete_enclosure' );
add_filter( 'rss_enclosure', 'delete_enclosure' );
add_filter( 'atom_enclosure', 'delete_enclosure' );


What it does is, override the function do_enclose() in /wp-includes/functions.php(line 1164 - Worpress v3.01) and return blank string hence no enclosure code is executed.

Have fun!

Random Quotes - Google Gadget

posted Jul 28, 2010, 4:25 PM by Ankit Sharma   [ updated Jun 29, 2011, 11:32 PM by Ankit Sharma ]

Created a sample gadget while learning about Google gadgets . This gadgets displays random quotes on every page refresh, quotes are embedded in gadget XML file.


Magento - Free shipping on Specific Category/Product

posted Jul 28, 2010, 3:14 PM by Ankit Sharma   [ updated Jul 28, 2010, 4:14 PM by Ankit Sharma ]

magento logo
Once again I encountered a Magento query in my freelancing career and here is the solution.
Recently a client also wanted to sell "Gift Certificates" as a product with no shipping rate since its a virtual gift card.

I search around a lot but didn't got solution any solution, also found that so many people asking the same question on Magento forum with no answer except only solution was to purchase an extension ranging from price 80$-360$ to handle shipping rates. Hence I suggested my client to purchase the extension.

But that wasn't convincing solution to me because if an extension can do it then there must be a solution. After few days, I found that new Magento version has a feature called "Shopping Cart Rules".

It provide multiple ways to handle shipping rate, in short, you can create any sort of rule of your own to handle shipping rates.

Let’s run through a scenario to get a better understanding of how to configure Magento for free shipping on specific category/products.

1) In this scenario we will be offering free shipping to Products in Category "Gift Certificates" having category Id : 10

2) Set up through Promotions -> Shopping Cart Price Rules -> Actions so that the free shipping will automatically apply if the conditions are met.

magento shipping

3) Since our Shopping Cart Rule is not limited to any product attributes, we can either choose “For matching items only” or “For shipment with matching items” in the Shopping Cart Price Rule Actions as Free Shipping option.

4) Now here, if we select “For matching items only”, if there are multiple items in the shopping cart, the free shipping will only apply for the product within the "Gift Certificates" category and other shipment charges on non-"Gift Certificates" items will be calculated separately.

magento custom shipping price

This is just of many techniques to offer free shipping to your customers.

P.S. I would suggest to purchase Extension if you have more complex shipping requirements.

Weather widget using Google Weather API

posted Jul 28, 2010, 2:58 PM by Ankit Sharma   [ updated Jul 28, 2010, 4:23 PM by Ankit Sharma ]

Recently a client approached me to create weather widget for Wordpress, which will display weather information using Google Weather API.
The API call was simple but the main thing was the design of the widget and similar to the one the client saw on some other site.
The main thing about this particular design is that, it displays icons according to the weather condition i.e cloudy, sunny, clear , rainy etc

Here is the screen shot of the widget:


Download php code here :
Google Weather API Code

Magento : Display all products in 1 page

posted Jul 28, 2010, 2:44 PM by Ankit Sharma   [ updated Jul 28, 2010, 2:57 PM by Ankit Sharma ]

magento logo
I was looking for solution to display all products in 1 page in Magento version 1.4 then I came across an article showing all special products. I made the changes in products filter to display all products.

All the files are attached here:
Attachment

1) Add Special.php on the following location :
app/code/core/Mage/Catalog/Block/Product/Special.php

2) Create Folder Special and Add Toolbar.php on the following location :
app/code/core/Mage/Catalog/Block/Product/Special/Toolbar.php

3) After you are done with this you have to now move to
/app/design/frontend/YourTheme/YourTheme/template/catalog/product
folder and add special.phtml

4) Now you can go to Admin Panel->CMS->Pages create a New Page and in the content paste this line:
{{block type="catalog/product_special" template="catalog/product/special.phtml"}}

Now you can save this page and assign this page’s link anywhere on the site.
You’ll get a list of products.

Very rare photos of SSD (Sleeping Software Developer), Dont miss it!!!

posted Jul 27, 2010, 7:18 PM by Ankit Sharma   [ updated Oct 22, 2010, 3:19 AM by Ankit Sharma ]

Today received a funny email from my past employer & friend, Jasmit Vala with the subject title:

Very rare photos of SSD (Sleeping Software Developer), Dont miss it!!!


So curiously when I opened it, I couldn't stop myself laughing, as it had my own pics sleeping while at work. These are pics of my Training Period from Jan-2009 to July-2009, myself getting caught red handed by my boss.



Here is what I think:


It was really difficult for me to work after LUNCH, I don't know how people do it, Yeah its true, I have been caught sleeping  many times during working hours BUT I used to stay in office late till 10pm -2am and always completed my work. I cannot work constantly for 8 hrs, not even 10 mins, that doesnt mean I suffer from ADD(Attention Deficit Disorder) Smile Thatswhy I think freelancing is good, I can work from bed, take a nap in-between, suits my kind of style.

Overall, it was good company to do my training, I learned a lot from My bosses, Jasmit and Himanashu, Both are real talented Programmers & great Individuals to work with.

Apart from that, the most enjoyable time was watching my bosses arguing with each other.

Original Post Date : April 21 2010 5:59 PM

RentACoder to vWorker - New Logo & Looks

posted Jul 27, 2010, 7:00 PM by Ankit Sharma   [ updated Jul 27, 2010, 7:17 PM by Ankit Sharma ]

 


 


  =>
 

Finally, RenaACoder team decides to change the looks of website, not only that But they have come with the new Company name 'vWorker'.
Reason:
Why the change? We're changing to reflect the diversity of the many talented workers we have on the site. Back when I founded the company in 2001 we concentrated just on technology and programming, and the name Rent a Coder fit us. But today in 2010, the site is not just coders, but also graphic artists, writers, translators, marketers, personal assistants and numerous other types of workers. Our new name will reflect that and reminds employers that they can find all kinds of talent here. Read More

Checkout the new looks HERE

I personally liked the old name "RentACoder", as I am being a coder, But I agree with company's propective and wish them for their continued success in future.

Original Post Date : April 16 2010 1:02 PM

1-10 of 13