Skip to content

Instantly share code, notes, and snippets.

View hemenkapadia's full-sized avatar

Hemen Kapadia hemenkapadia

View GitHub Profile
@hemenkapadia
hemenkapadia / ggplot_multiplot.R
Last active November 13, 2015 23:11
Draw multiple ggplots in a grid layout
# MultiPlot - Arrange multiple R plots in a single grid type layout
#
# Reference - http://www.cookbook-r.com/Graphs/Multiple_graphs_on_one_page_%28ggplot2%29/
#
# ggplot objects can be passed in ..., or to plotlist (as a list of ggplot objects)
# - cols: Number of columns in layout
# - layout: A matrix specifying the layout. If present, 'cols' is ignored.
#
# If the layout is something like matrix(c(1,2,3,3), nrow=2, byrow=TRUE),
# then plot 1 will go in the upper left, 2 will go in the upper right, and
@hemenkapadia
hemenkapadia / Android_Infuse_datadata.note
Last active January 16, 2016 23:17
Resoltuion to the datadata space constraint issue on Infuse
# Important - if the device shows as unauthorized in adb devices -l command. Then go into recovery mode and try adb shell. It will drop to you the shell as root.
# All the below steps needs to be performed in recovery mode.
The fix for the space limitation with yaffs /datadata partion is causing the phone to display low memory error when i enable corporate email on my Samsung Infuse.
The workaround i have is to move some of the data intensive applications to /data/data2 directory which is ext4 based - so far i have not noticed any challanges with performance.
These steps are to be performed in recovery mode. Use CWM to mount /datadata and /data partitions if you notice they are empty.
@hemenkapadia
hemenkapadia / Android_Infuse_KeepAwake.note
Last active November 13, 2015 23:13
Note on resolving the Keep Awake issue on Android Infuse
So this Keepawake problem had been plauging me a lot, a dirty workaround i found was to go to google play services in titanium backup, open system details and then clear the data for the same. This would crash the google play service without any noticable impact to the phone functionality, but would take care of the keep awake problem
But the issue was that after a couple of days the problem would return back and then the cycle repeats.
I needed a better solution and found the below to be working so far
Get the Disable Services App from play store
then in System > Google Play Service disable the three services below
GoogleLocationManagerService
@hemenkapadia
hemenkapadia / dataframe_manipulations.R
Last active November 13, 2015 23:11
Dataframe Manipluations
# Many times we need to delete number of columsn in a data frame, in feature engineering process.
# Deleting the same with column numbers is possible, but is not a good idea from a maintenance standpoint.
# Using column names is a safer option.
# Use below code.
removeCols <- c("colA", "colB")
data.frame <- data.frame[, -which(names(data.frame) %in% removeCols]
@hemenkapadia
hemenkapadia / Ubuntu_High DPI configuration.txt
Last active May 1, 2016 04:41
Ubuntu_High DPI configuration
#### Note about kernel versions ####
Between kernel versions 4.2 and 4.4 there are different options that need to bet set
to get this working. The same is highlighted below when necessary. I have not tested
version 4.3 so not sure which of the two settings work, in which case try either one.
#### GRUB settings during install and first restart ####
Add the follwoing kernel options just before `quiet splash` in the GRUB boot
menu while trying to install using a live USB and the very first start of the
@hemenkapadia
hemenkapadia / Ubuntu 14.04 on Optimus Laptop.txt
Last active May 2, 2023 20:44
[Ubuntu 14.04 on Optimus Laptop] Setting up Ubuntu 14.04 with nvidia drivers and CUDA on Dell 7559 Optimus laptop #Ubuntu #Nvidia #CUDA #setup
### NOTE ###
The below gist is converted to a blog post and available at below link. Refer that instead.
http://hemenkapadia.github.io/blog/2016/11/11/Ubuntu-with-Nvidia-CUDA-Bumblebee.html
#### Note about kernel versions ####
Between kernel versions 4.2 and 4.4 there are different options that need to bet set
to get this working. The same is highlighted below when necessary. I have not tested
@hemenkapadia
hemenkapadia / Configuring SSH Agent for password less login.sh
Last active May 30, 2018 23:13
[SSH Agent Configuration] Configuring SSH Agent to automatically add ssh keys for password less login #ssh #tips #git
# add the below scriptlet to your ~/.bashrc
# File to store the SSH Agent environment
SSH_ENV=$HOME/.ssh/environment
# start the ssh-agent
function start_agent {
echo "Initializing new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo "Agent started...."
@hemenkapadia
hemenkapadia / Git cheatsheet.md
Last active December 3, 2019 19:08
[Git cheatsheet] Git cheatsheet #git #cheatsheet

Git Fundamentals


  • Traditional VCS, like Subversion, CVS etc. are Centralized VCS based on where they store data
  • They are also Delta Version Control Systems (VCS) based on how they store data.
    • base version of the file is created when it was added to VCS for tracking
    • changes are stored as a list of changes (i.e. diffs or deltas) per tracked file.

Delta Version Control Systems

  • Git is a Snapshot VCS
@hemenkapadia
hemenkapadia / gist:a358854e14fbd68873cb5e1bc75d0a53
Created April 6, 2016 08:01
Stream RPi Camera to linux machine
We use netcat to stream video capture from Raspberry Pi to the Linux machine and play the same in mplayer. Moreover we want to do it in such a way that the Linux server and mplayer should continue listening for the video stream and should start the video play back as soon as it is available
For this Open three terminals on your linux box
in terminal 1 make a fifo file using command mkfifo somefile
in the same terminal we start netcat to listen for incoming connections on port 54321 and redirect this stream to the fifo file we created. Moreover it does not disconnect when the stream ends- it continues listening for the next stream to start
nc -lk 54321 > somefile
in terminal 2 start mplayer to play the stream coming in the fifo file we created
@hemenkapadia
hemenkapadia / Ubuntu Post Install Setup.txt
Last active October 1, 2019 22:05
[Ubuntu Post Install Setup] Instructions for installing applications post Ubuntu installation #Ubuntu #setup
#TODO - convert this into an installation script to help quickly setup the machine post installation
0. Time in Windows gets corrupted when dual boot with Ubuntu. (Note needed on 18.04 LTS)
First adjust hardware time in BIOS to UTC time
Windows will automatically recognise it and will display appropriate local time
For Ubuntu, update /etc/default/rcS and change line with UTC=no to UTC=yes, indicating that BOIS time is UTC.
Reboot - and check both systems.
- Follow this method too - https://www.howtogeek.com/323390/how-to-fix-windows-and-linux-showing-different-times-when-dual-booting/