Skip to content

Instantly share code, notes, and snippets.

View rohitfarmer's full-sized avatar

Rohit Farmer rohitfarmer

View GitHub Profile
@rohitfarmer
rohitfarmer / tensorflow.md
Created November 2, 2018 16:18
Cheat sheet for tensorflow

Using Tensor Board

import tensorflow as tf

a = tf.constant(2, name='a')
b = tf.constant(3, name='b')
x = tf.add(a,b, name='add')

writer = tf.summary.FileWriter('./graphs', tf.get_default_graph())
with tf.Session() as sess:
@rohitfarmer
rohitfarmer / vim.md
Last active November 2, 2018 16:29
Commands for VIM

Commands for Matt's implementation of VI

Toggle nerd tree: / + n
To open a file in the nerd tree in split window: s
Switch screen: ctrl + ww
To run the script without quitting VI: :! python name.py

Visualization mode to cut, copy, paste etc.
shift + v

@rohitfarmer
rohitfarmer / pandas.md
Last active March 14, 2019 19:21
Pandas examples

Merge, join and concat

To merge dataframes when their indexes are same but may not be of equal length i.e. some samples may be missing in either of the df.
p_m_smi = pd.merge(p_smi, met_smi, left_index=True, right_index=True, how='outer', sort=False)

[left, right]_index : True to use indexes to merge on. For columns set left_on or right_on.
Outer: means union, Pandas will put NaN for the rows that are missing in either of the dataframes.
Sort: keep false if the dataframes are already sorted for efficiency.

To concatenate column wise

@rohitfarmer
rohitfarmer / python_cheats.md
Created November 8, 2018 16:29
Example code in Python

To get the index of a value in a list
indx = [i for i, v in enumerate(lis) if v == 1]

@rohitfarmer
rohitfarmer / tensorboard.md
Created November 16, 2018 16:29
Commands related to tensorboard

Script to write tensorboard logs during execution.

import tensorflow as tf

a = tf.constant(2, name='a')
b = tf.constant(3, name='b')
x = tf.add(a,b, name='add')

writer = tf.summary.FileWriter('./graphs', tf.get_default_graph())
@rohitfarmer
rohitfarmer / screen.md
Created November 19, 2018 16:34
Commands for Linux Screen

To scroll in screen session
Press "Ctrl-A" on the keyboard and press "Esc."

Press the "Up" and "Down" arrow keys or the "PgUp" and "PgDn" keys to scroll through previous output.

Press "Esc" to exit scrollback mode.

Screen output logging to a file
screen -L -S testscreen

@rohitfarmer
rohitfarmer / helper.md
Last active January 30, 2019 22:20
Helper functions

Function to add indicator column(s) in a Pandas dataframe.

def add_indicator(df):
    """
    Purpose
    -------
    Add indicator column next to any column that has one or more NaNs.
    The indicator column contains 1 at the index that has NaN in the parent data column.
    The NaNs in the parent data columns are replaced with 0.
@rohitfarmer
rohitfarmer / gromacs.md
Created February 5, 2019 01:30
Gromacs

Gromacs 2019 installation on Dell (14 7000)

tar xfz gromacs-2019.tar.gz
cd gromacs-2019
mkdir build
cd build
cmake .. -DGMX_BUILD_OWN_FFTW=ON -DREGRESSIONTEST_DOWNLOAD=ON -DGMX_GPU=ON -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda -DCMAKE_INSTALL_PREFIX=/home/rohit/bin/gromacs/gromacs-2019
make
make check
@rohitfarmer
rohitfarmer / imagemagick.md
Last active March 14, 2019 21:43
Imagemagick

Stack Pictures Vertically
convert png_print/Accuracy_print.png png_print/AdaBoost_print.png -resize '1024x682^' -bordercolor black -border 2 -gravity center -append test.png

Inline CSS

<p style="text-align: justify; font-style: italic; font-weight: bold;">

Hyperlink

Open in a new tab <a href="url" target="_blank">Text</a>