Skip to content

Instantly share code, notes, and snippets.

View deepaknverma's full-sized avatar
:atom:
Building something new

Deepak Verma deepaknverma

:atom:
Building something new
View GitHub Profile
sudo sync && sudo echo 3 | sudo tee /proc/sys/vm/drop_caches
@deepaknverma
deepaknverma / Tail commands
Last active February 26, 2020 14:27
highlight keyword while tail
replace 503 with your keyword
tail -f /var/log/apache2/access.log | perl -pe 's/ 503 /\e[1;31;43m$&\e[0m/g'
sudo bash -c 'tail -f /var/log/apache2/access.log| grep "[0-9] 5[0-9][0-9] \"" | (while read; do date; /usr/local/sbin/profile-php; done)'
@deepaknverma
deepaknverma / Deploying app on heroku
Created February 10, 2015 23:33
Create new project in any of your fav editor
cd my-project
heroku login
heroku create appname
git init
You've a lot unused kernels. Remove all but the last kernels with:
sudo apt-get purge linux-image-{3.0.0-12,2.6.3{1-21,2-25,8-{1[012],8}}}
This is shorthand for:
sudo apt-get purge linux-image-3.0.0-12 linux-image-2.6.31-21 linux-image-2.6.32-25 linux-image-2.6.38-10 linux-image-2.6.38-11 linux-image-2.6.38-12 linux-image-2.6.38-8
Removing the linux-image-x.x.x-x package will also remove linux-image-x.x.x-x-generic.
The headers are installed into /usr/src and are used when building out-tree kernel modules (like the proprietary nvidia driver and virtualbox). Most users should remove these header packages if the matching kernel package (linux-image-*) is not installed.
To list all installed kernels, run:
@deepaknverma
deepaknverma / remove_mongo_osx.sh
Created February 9, 2015 14:27
remove mongodb from os x
#!/usr/bin/env sh
# checks to see if running
launchctl list | grep mongo
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
launchctl remove homebrew.mxcl.mongodb
pkill -f mongod
@deepaknverma
deepaknverma / jQuery SerializeObjects
Last active August 29, 2015 14:14
By default jQuery does not allow us to convert our forms into Javascript Objects. Following snippet do that for us. Simply call it via `$(form).serializeObject()` and get a object returned.
$.fn.serializeObject = function(){
var o = {};
var a = this.serializeArray();
$.each(a, function(){
if(o[this.name] !== undefined) {
if(!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
@deepaknverma
deepaknverma / Building Nodejs server on ubuntu
Created January 12, 2015 14:44
Building Nodejs server on ubuntu
Node.js is a Javascript platform for server-side programming that allows users to build network applications quickly.
Building nodejs server in ubuntu is fairly simple and easy. With few commands you can make a nodejs server up and running in not time.
Nodejs generally runs of port 3000 but that is not mandatory, you can use any other port you want to make your server more customised.
There are few path, you can follow to get your Nodejs up and running on Ubuntu 14.04
======================
Distro-Stable Version
======================
@deepaknverma
deepaknverma / Auto mount network share at boot in ubuntu
Last active August 29, 2015 14:07
Auto mount network share at boot in ubuntu 12.0 or newer
Ubuntu newb running 11.04. Seems like a lot of other people are having trouble mounting the network drive at boot in fstab. Tried a bunch of things and cruising the forums but just ended up being a mess. Finally got it going and I though I would share for others and if I need to do it again later.
Also worth noting is that it is not very secure as the file you save the credentials in is in plain text, but I didn't care at this point.
1. Install smbfs:
sudo apt-get install smbfs
2. Then create a folder inside of the /media directory to mount the share in:
sudo mkdir /media/server
@deepaknverma
deepaknverma / 10 Tips for Optimizing NGINX and PHP-fpm for High Traffic Sites
Created October 20, 2014 01:22
10 Tips for Optimizing NGINX and PHP-fpm for High Traffic Sites
Please take a look at the original article (http://www.softwareprojects.com/resources/programming/t-optimizing-nginx-and-php-fpm-for-high-traffic-sites-2081.html) as it includes excellent configuration file examples.
1. Switch from TCP to UNIX domain sockets:
When communicating to processes on the same machine UNIX sockets have better performance the TCP because there's less copying and fewer context switches.
2. Adjust Worker Processes:
Set the worker_processes in your nginx.conf file to the number of cores your machine has and increase the number of worker_connections.
3. Setup upstream load balancing:
Multiple upstream backends on the same machine produce higher throughout than a single one.
@deepaknverma
deepaknverma / NGINX on EC2
Created October 20, 2014 01:13
NGINX and PHP-FPM setup on AMAZON-EC2 for heavy lifting
--------------------------------------------
Install PHP 5.4.x
--------------------------------------------
yum install \
php54.x86_64 \
php54-bcmath.x86_64 \
php54-cli.x86_64 \
php54-common.x86_64 \
php54-dba.x86_64 \
php54-devel.x86_64 \