Skip to content

Instantly share code, notes, and snippets.

View rcgalbo's full-sized avatar
:bowtie:
Pleas frickin hire me

Rick Galbo rcgalbo

:bowtie:
Pleas frickin hire me
View GitHub Profile
@rcgalbo
rcgalbo / fish-default-on-osx.sh
Created April 10, 2018 16:44
Setting Fish as your default shell on Mac OS X
$ brew install fish
$ echo "/usr/local/bin/fish" | sudo tee -a /etc/shells
$ chsh -s `which fish`
@rcgalbo
rcgalbo / scp.sh
Created April 10, 2018 19:20
scp because u will forget how
# download: remote -> local
scp user@remote_host:remote_file local_file
# upload: local -> remote
scp local_file user@remote_host:remote_file
@rcgalbo
rcgalbo / pytorch_keras_gcloud.txt
Created April 12, 2018 15:21 — forked from motiur/pytorch_keras_gcloud.txt
Keras and Pytorch in Google Cloud VM
# This script is designed to work with ubuntu 16.04 LTS
# with keras 1.2.2 and the latest Pytorch with CUDA 8 support
##########################################################################
#This is used to install CUDA 8 driver for Tesla K80
##########################################################################
#!/bin/bash
echo "Checking for CUDA and installing."
# Check for CUDA and try to install.
if ! dpkg-query -W cuda-8-0; then
@rcgalbo
rcgalbo / condaenv.txt
Created April 16, 2018 14:51 — forked from pratos/condaenv.txt
To package a conda environment (Requirement.txt and virtual environment)
# For Windows users# Note: <> denotes changes to be made
#Create a conda environment
conda create --name <environment-name> python=<version:2.7/3.5>
#To create a requirements.txt file:
conda list #Gives you list of packages used for the environment
conda list -e > requirements.txt #Save all the info about packages to your folder
@rcgalbo
rcgalbo / install_jupyter.txt
Last active August 30, 2018 16:17
Install conda package in jupyter notebook into environment
import sys
!conda install --yes --prefix={sys.prefix} numpy
@rcgalbo
rcgalbo / ploy_heatmap.py
Created July 25, 2018 21:50
Plotting an interactive heatmap of lat, long
import folium
def plot_heatmap(data):
'''
Args:
takes a list of lists [[lat, long]]
Returns:
Folium map object with heatmap overlay
'''
heatmap = folium.Map(tiles="CartoDBpositron", prefer_canvas=True)
@rcgalbo
rcgalbo / structure_keras_dir.py
Created August 8, 2018 14:20
move images into sub directories for keras ImageDataGenerator
import os
with open('../data/labels.csv','r') as labels:
lines = [line.split(',') for line in labels.readlines()][1:]
for line in lines:
image = line[0]
label = line[1].split('/')[-1].replace('\n','')
if not os.path.exists('../data/train/'+label):
os.mkdir('../data/train/'+label)
os.rename('../data/train/'+image+'.jpg', '../data/train/'+label+'/'+image+'.jpg')
@rcgalbo
rcgalbo / list_blobs.py
Last active August 21, 2018 18:23
list the contents of a gcs bucket
from google.cloud import storage
def list_blobs(bucket, prefix):
"""
Lists all the blobs in the bucket
make sure prefix ends with '/'
"""
storage_client = storage.Client()
bucket = storage_client.get_bucket(bucket)
@rcgalbo
rcgalbo / cols_to_datetime.py
Last active August 22, 2018 15:50
Converting list of columns to date time
def convert_to_datetime(df, columns):
return df[columns].apply(pd.to_datetime, axis=1)
@rcgalbo
rcgalbo / convert_pdf_image.py
Last active August 24, 2018 14:18
convert a pdf file to an image
from pdf2image import convert_from_path
image = convert_from_path("path_to_pdf.pdf")