Skip to content

Instantly share code, notes, and snippets.

@neerajsohal
neerajsohal / count_changed_lines.sh
Created June 6, 2014 19:52
How to count total lines changed by a specific author in a Git repository?
#http://stackoverflow.com/questions/1265040/how-to-count-total-lines-changed-by-a-specific-author-in-a-git-repository
git log --author="_Your_Name_Here_" --pretty=tformat: --numstat \
| awk '{ add += $1 ; subs += $2 ; loc += $1 - $2 } END { printf "added lines: %s removed lines : %s total lines: %s\n",add,subs,loc }' -
@neerajsohal
neerajsohal / forcedcanvas.js
Created May 29, 2014 16:15
Force a webapp to load inside Facebook app canvas
function NotInFacebookFrame() {
return top === self;
}
function ReferrerIsFacebookApp() {
if(document.referrer) {
return document.referrer.indexOf("facebook.com") != -1;
}
return false;
}
if (NotInFacebookFrame()) {
@neerajsohal
neerajsohal / responsive-html-email.html
Last active August 29, 2015 14:01
Absolute minimal responsive email skeleton
<!DOCTYPE html>
<html lang="en">
<head>
<title>Salted | A Responsive Email Template</title>
<!--
SALTED | A RESPONSIVE EMAIL TEMPLATE
=====================================
Based on code used and tested by Litmus (@litmusapp)
@neerajsohal
neerajsohal / setup.sh
Created April 28, 2014 08:10
Setup LAMP + composer + bower in Amazon EC2 Ubuntu 14.04 LTS
# update repo
sudo apt-get update
# upgrade and install latest updates
sudo apt-get upgrade
# generate UTF-8 lang
sudo locale-gen UTF-8
# install lamp
@neerajsohal
neerajsohal / MY_Form_Validation.php
Last active December 28, 2015 16:49
Validate URLs by extending CodeIgniter Form Validation Library
# My Form Validation Class
# Save this in 'core' folder under 'application' folder
class MY_form_validation extends CI_form_validation {
function valid_url($str){
if(filter_var($str, FILTER_VALIDATE_URL)) {
return TRUE;
} else {
return FALSE;
}