I see, learn and rediscover… everyday!
 
Category: <span>code</span>

Advanced Git Commands

Git is a powerful tool and I’ve been using it for years. But there are few commands that make me feel like a power user. I use the basic commands like git add, git commit and git push everyday, there are some advanced commands that can significantly workflow and troubleshooting process.

Thank you generator

This task/project started with a simple comment from our team. Mindy (who is the EA to Vivek) shared this comment in one of the internal Google documents. It was very unusual to get a coding task from Mindy. Usually, whenever I’m assigned a coding task, it is for some customer or any feature I’ve worked on in the past. It …

WordPress Setup

I set up my first website using WordPress way back around 2007 or 2008. I was amazed by the simplicity to install WordPress. My website was up and running within 2 minutes. Even now, the setup process remains the same. In this post, I’m sharing my WordPress setup. Hosting This entire website is hosted at Linode.com. Linode gives a 2GB …

Advice for a junior software developer

Every year, I work with a smart bunch of college kids during their summer/winter internship at HackerRank. While I’ve learned a lot of things from them, they usually ask for feedback/advice at the end of the internship. The individual feedback varies from person to person, but there is a standard set of links/books I share with them to read to …

Inbox Pause

I follow Inbox Zero to take control of my inbox. Initially, it was great and ‘felt’ very productive. But later at some point, it became an addiction to check email very often. The urge to keep the email at zero made me check inbox regularly. After a few weeks, I wasn’t sure if I was even doing my job. I …

WebAssembly 101

WebAssembly has been there for quite some time. While I understand the overall idea, I never had a chance to build anything production-ready so far. I had a chance to play around with WebAssembly during our company hackathon and one of the engineers explained in detail how WebAssembly works. I wanted to build something with WebAssembly and wanted that to …

Mail Merge to PDF Files – V2

This is a follow up of the post I’ve shared earlier to create files earlier at https://sp2hari.com/mail-merge-to-pdf-files/ While the first version of the post I made for creating multiple PDF files from Google Doc and Google Sheets still works, it is a lot hackerish. Copying the ID from the document, and managing the ‘Config’ in the sheet is a lot …

Request War

This contest started as a fun chat with an employee at HackerRank and how it ended up with a coding contest. One of the engineers from our team, Aditi Tayal, has recently started learning to build a web app using Mysql and Redis. She built a simple task manager and shared this link with me https://aditiflaskcrudapptutorial.herokuapp.com/. My first instinct is …

Improving font load performance

This post is a result of an article I came across recently. https://csswizardry.com/2020/05/the-fastest-google-fonts/. This is a nice post which in detail about improving the performance of a website when loading fonts from Google. There is a lot of interesting items going on to make the web page load faster. font-display: swap Instructs the browser to use the fallback font to …

Suicide

This post is the result of writing a LOT of Google apps scripts and watching a lot of ‘Forensic Files‘ in Netflix. An interesting function I used so far to attach a menu is the onOpen() function. The code inside the onOpen() function executes when the file is opened. For example, following code is an example of onOpen from my …

Mail Merge to PDF Files

Mail merge is a great feature (truth be told, everything that automates a repetitive job is a great feature). One of the tedious repetitive task our team keeps doing often is generating PDF files for our employees (usually one file per person). We are going to automate this using Google Docs, Google Sheets, and Google App Scripts. Step 1: Create …

Remove all your friends from Facebook.

Very rarely, you will want to delete all friends from Facebook and start a “fresh” facebook account. Now, it’s hard to do this manually. Thanks to phpunit + selenium + a few lines of code, this can be done now. The following script removes all your friends from facebook 🙂 Replace and with your username and password respectively. <?php require_once ‘PHPUnit/Extensions/SeleniumTestCase.php’; …

Vim tutorials

VIM is an awesome editor, but comes with a big big learning curve. These are the the top 3 Vim tutorials from where I learnt to use Vim. 1. http://www.vi-improved.org/tutorial.php 2. http://vim.runpaint.org/toc/ 3. http://www.swaroopch.com/notes/Vim_en:Table_of_Contents If you want to learn more, checkout http://thomer.com/vi/vi.html#manuals

Git reflog and git force push

Git reflog saves you from all screw-ups you do while using git. Here is a sample output of git reflog. hari@hari-desktop:/var/www/recruit$ git reflog e458f54 HEAD@{0}: checkout: moving from test1 to e458f54fe99202c82c2690be4fa2fe2d7aa7be32^0 a3281d1 HEAD@{1}: checkout: moving from master to test1 f265802 HEAD@{2}: checkout: moving from test1 to master ef08492 HEAD@{3}: ORIG_HEAD: updating HEAD e458f54 HEAD@{4}: commit: Implement phpunit testcase. 1ecf2c3 HEAD@{5}: …

Compare branches in git

Want to check if all changes in your new branch is merged to main branch before you delete the new branch. git log feature1 ^master The above command displays all commits which are present in feature1 and not present in master. Note 1: You can also try “git branch -d feature1”. If the new branch is not totally merged, git …

HTML5 Experiment 1 – Burst the Balloon

HTML5 seems to be the buzz word now. People around me are excited about HTML5 or already working on something with HTML5. Curious to know what the hell is this HTML5, I started reading something from https://developer.mozilla.org/en/HTML/HTML5. Well, truth be told, I finished the overview in say 15 minutes and didn’t know what exactly to do after that. I was …

Delete a remote branch in git

We use Git here at interviewstreet. Using Git, branching, testing and reverting is so easy. Almost all commands are simple and easy to remember in Git, except for deleting a remote branch. The command to delete a remote branch “feature1” is git push origin :feature1 Just wanted to note this down.

Advanced Bash Scripting – Part 2

The problem statement is as follows : The Playfair Cipher encrypts text by substitution of digrams (2-letter groupings). It is traditional to use a 5 x 5 letter scrambled-alphabet key square for the encryption and decryption. Each letter of the alphabet appears once, except “I” also represents “J”. The arbitrarily chosen key word, “CODES” comes first, then all the rest …

Query String in URL using Codeigniter

CodeIgniter by default won’t allow you to use query strings in the URL. This is how you enable query string in url in codeigniter. 1. Set $config[‘uri_protocol’] = “PATH_INFO” in config.php 2. Set $config[‘enable_query_strings’] = TRUE in config.php 3. Make you sure you have QSA in your .htaccess. For example, RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^(index\.php|images|includes) RewriteRule …

Security settings for a LAMP Server : Iptables

Security is the major concern for anyone hosting a website on the internet. These are the preliminary security settings to be performed to protect your server. iptables Our server stack is LAMP. Hence iptables as the firewall is the most natural choice. The requirements are like 1. Block everything except Ping, SSH, Apache, and SSL. 2. Enabled SSH only from …

Apache Fix : NameVirtualHost *:80 has no VirtualHosts

I get this error every time I install apache web-server in an ubuntu machine. We use LAMP stack at Interviewstreet and this error was nagging me all the this while. The error message shows up something like this. root@interviewstreet:~# /etc/init.d/apache2 restart * Restarting web server apache2 apache2: Could not reliably determine the server’s fully qualified domain name, using interviewstreet.com for …

This is sweet :)

The other day, I was poking a few sites on the web lazily, looking how they’ve designed the CSS, HTML etc blah blah blah.. I take a quick look at the tumblr source code and find this in the header 🙂 #Like