Skip to content

Instantly share code, notes, and snippets.

View agalea91's full-sized avatar

Alexander Galea agalea91

View GitHub Profile
@agalea91
agalea91 / deepdream-install.md
Last active April 26, 2016 20:09 — forked from robertsdionne/deepdream-install.md
Deepdream installation
#!/usr/bin/env bash

# I did this with OS X Yosemite 10.10.5 in May 2016
# Adding some changes from original

# Install XCode and command line tools
# See https://itunes.apple.com/us/app/xcode/id497799835?mt=12#
# See https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcode-select.1.html
xcode-select --install
import seaborn as sns
sns.set_style('darkgrid')
from matplotlib.colors import ListedColormap
# Enter hex values of desired colors
color_map = ListedColormap(['#00bfff', '#ff8000'])
x = np.linspace(0, 2*np.pi, 100)
for i in range(2):
plt.plot(x, np.sin(x+np.pi/2*i), c=color_map.colors[i], lw=5, alpha=0.7)
___________________________________
TO MAKE CAFFE (NOT FROM SCRATCH)
make all -j2; make pycaffe -j2
make distribute
export PYTHONPATH="/Users/kristinhebert/Documents/GitClones/caffe/distribute/python:$PYTHONPATH"
@agalea91
agalea91 / matplotlib-xkcd.py
Last active June 2, 2016 18:17
python-how-to
import matplotlib.pyplot as plt
import numpy as np
plt.xkcd()
ax = plt.subplot(111)
x = np.linspace(0,4*np.pi,100)
ax.plot(x, np.sin(x)/x)
ax.annotate('Hell ya!', xy=(2, 0.5), xytext=(6, 0.7),
xycoords='data', textcoords='data', ha='right', va='bottom',
arrowprops=dict(arrowstyle='->', lw=2))
see all available commands:
git
grab a repository from git:
git clone ___url___
> COMMANDS FOR MAKING NEW GIT REPOSITORY
git init
git add -A
@agalea91
agalea91 / pandas-commands.md
Last active June 17, 2022 07:26
Useful commands for the pandas dataframe library for python.

Useful commands for Pandas dataframes

import pandas as pd


Loading data

  • from .csv
    df = pd.read_csv('file.csv', header=1)
  • from dictionary
    df = pd.DataFrame(dict)
  • from lists
    df = pd.DataFrame([[y, x1_1, x2_1, ...], [y, x1_2, x2_2, ...], ... ])
@agalea91
agalea91 / numpy-commands.md
Last active June 30, 2016 20:16
All glory to NumPy! Long may it live.

Useful commands for Numpy

import numpy as np


Arrays

  • Random mask for shuffle
    np.random.permutation(size)
  • Split array a into N pieces
    np.array_split(a, N)
  • Initialize empty array and join
    a = np.empty(shape=(0, b.shape[1]))
---
title: "Functions"
---
1. __What are the three components of a function?__
* Envionment, arguments, and body.
```{r}
e <- new.env()
e$body <- print("Schrodinger's cat")
e$a <- function(argument){
@agalea91
agalea91 / photo_batch_resize_constrained
Last active November 13, 2019 04:46
Resize images to given max px size
# -*- coding: utf-8 -*-
__author__ = 'Alex Galea'
"""
* No longer maintained *
See here for newer versions: https://github.com/agalea91/photo-batch-resize
"""
# Usage e.g.
# python photo-batch-resize-constrained.py --images-folder=lightroom-exports --max-px-size=1080
@agalea91
agalea91 / R-tips.R
Last active September 8, 2016 05:12
Tips and tricks with R
### Miscellaneous tips for using R
# Select a set of columns from a dataframe
wage_red = wage %>% select(-sibs, -brthord, -meduc, -feduc)
wage_subset = wage %>% select(hours, lwage)
# Use q + dist type to get confidence interval
beta_iq_mean = summary(lm.wage_1)$coefficients[2]
beta_iq_std = summary(lm.wage_1)$coefficients[4]
qt(p = c(0.025, 0.975), df = 933)*beta_iq_std + beta_iq_mean # t = student-t dist., can also use e.g. qnorm