Skip to content

Instantly share code, notes, and snippets.

View harshalbhakta's full-sized avatar

Harshal Bhakta harshalbhakta

View GitHub Profile
@harshalbhakta
harshalbhakta / mount.md
Created March 14, 2015 05:26
Mount usb on Ubuntu server.

Mount

$ sudo fdisk -l
$ sudo  mkdir /media/usb
$ sudo mount /dev/sdb1 /media/usb

Unmount

$ sudo umount /media/usb

@harshalbhakta
harshalbhakta / setup.md
Last active April 25, 2016 07:30
Setup Ubuntu for Rails development.
@harshalbhakta
harshalbhakta / ps-export-layers-to-png.jsx
Created February 26, 2015 07:46
Export groups to png files in photoshop.
#target photoshop
// $.level = 2;
/*
* Script by Tomek Cejner (tomek (at) japko dot info)
* based on work of Damien van Holten:
* http://www.damienvanholten.com/blog/export-groups-to-files-photoshop/
*
* My version adds support of nested layer groups,
* and exports single layers in addition to groups.
@harshalbhakta
harshalbhakta / hard-restart-unicorn-nginx-rails-capistrano.sh
Last active January 13, 2018 07:37
Unicorn doesn't pick changes after deployment. Hard restart. (Rails, Nginx, Unicorn & Capistrano)
#-- local machine
$ cap production unicorn:stop
$ cap production nginx:stop
$ ssh deployer@example.com
#-- server
$ rm ~/apps/:app_name/current/tmp/pids/unicorn.*
$ rm /tmp/unicorn.:app_name.sock
@harshalbhakta
harshalbhakta / gist:949a109d2b7b7555078e
Last active August 29, 2015 14:09
Rails asset precompile failing. Create SWAP Space on Ubuntu.

http://stackoverflow.com/a/22272491

Your precompile process is probably being killed because you are running out of RAM. You can confirm this by running top in another ssh session. To fix this, create a swap file that will be used when RAM is full.

Create SWAP Space on Ubuntu You will probably end up needing some swap space if you plan on using Rails on Digital Ocean 512MB RAM droplet. Specifically, you will run out of RAM when compiling the assets resulting in the process being quietly killed and preventing successful deployments.

To see if you have a swap files:

sudo swapon -s No swap file shown? Check how much disk space space you have:

@harshalbhakta
harshalbhakta / commands
Created October 29, 2014 06:12
Ubuntu cleanup
# autoclean removes partial packages from the system.
$ sudo apt-get autoclean
# Removes .deb packages that apt caches when you install/update programs.
$ sudo apt-get clean
# Removes packages installed as dependencies after the original package is removed from the system.
$ sudo apt-get autoremove
# What gtkorphan does is to find packages that were once used but no longer have any purpose.
@harshalbhakta
harshalbhakta / read_csv.rb
Created September 23, 2014 04:48
Read CSV file in Ruby.
require 'csv'
filename = ARGV[0]
CSV.foreach(filename) do |row|
puts row
end
@harshalbhakta
harshalbhakta / commands
Created August 31, 2014 06:51
rsync cheatsheet.
# -a: Syncs recursively and preserves symbolic links, special
# and device files, modification times, group, owner, and permissions.
# -n: dry run
# -v: verbose
# sync contents of dir1 to dir2
$ rsync -anv dir1/ dir2
@harshalbhakta
harshalbhakta / bash.md
Created August 31, 2014 06:17
Using ssh-add to manage multiple ssh keys.

If we have multiple ssh keys in the ~/.ssh folder.

- ~/.ssh/id_rsa
- ~/.ssh/id_rsa.pub
- ~/.ssh/hb
- ~/.ssh/hb.pub

To use hb key when executing $ ssh user@server.com add the key to ssh-add.

$ ssh-add ~/.ssh/hb

@harshalbhakta
harshalbhakta / remove_old_kernels.md
Last active March 31, 2023 09:10
Ubuntu Software Updater: Not enough free disk space

The upgrade needs a total of 81.5 M free space on disk '/boot'. Please free at least an additional 17.4 M of disk space on '/boot'. Empty your trash and remove temporary packages of former installations using 'sudo apt-get clean'.

http://askubuntu.com/questions/142926/cant-upgrade-due-to-low-disk-space-on-boot

Run below command as suggested in the error message.

$ sudo apt-get clean

First check your current kernel version.