Skip to content

Instantly share code, notes, and snippets.

View fabsta's full-sized avatar

Fabian Schreiber fabsta

View GitHub Profile
@fabsta
fabsta / VGG from scratch.md
Last active November 26, 2017 17:26
[Deep learning] #deeplearning

model setup

from numpy.random import random, permutation
from scipy import misc, ndimage
from scipy.ndimage.interpolation import zoom

import keras
from keras import backend as K
from keras.utils.data_utils import get_file
from keras.models import Sequential, Model
@fabsta
fabsta / unix.md
Last active March 9, 2017 14:20
unix

sorting files by user

ls -l | sort -k3,3

find ignore errors
find / -name livy_server 2>/dev/null
@fabsta
fabsta / spark_io
Last active June 20, 2018 05:05
Spark snippets
# Hive
```
```
# Oracle
```
val oracle_db = sqlContext.load("jdbc", Map("url" -> "jdbc:oracle:thin:user/passwd@//server.com:1526/serviceID.com", "dbtable" -> "table"))

Metadata

#Selecting a database	
USE database;	USE database;

#Listing databases	
SHOW DATABASES;	SHOW DATABASES;
@fabsta
fabsta / python cheat sheet.md
Created March 5, 2017 21:47
python cheat sheet

[TOC]

Pure Python

Types

a = 2           # integer
b = 5.0         # float
c = 8.3e5       # exponential
d = 1.5 + 0.5j  # complex
@fabsta
fabsta / pandas cheat sheet.md
Created March 5, 2017 21:46
pandas cheat sheet

[TOC]

Preliminaries/Import

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from pandas import DataFrame, Series
@fabsta
fabsta / spark_basic_build.sbt
Created October 25, 2016 18:02 — forked from vgiri2015/spark_basic_build.sbt
spark_final_build_sbt
name := "Spark2.0-and-greater"
version := "1.0"
//Older Scala Version
scalaVersion := "2.11.8"
val overrideScalaVersion = "2.11.8"
val sparkVersion = "2.0.0"
val sparkXMLVersion = "0.3.3"

Preliminaries

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from pandas import DataFrame, Series

MATH

basic operations

10 + 4          # add (returns 14)
10 - 4          # subtract (returns 6)
10 * 4          # multiply (returns 40)
10 ** 4         # exponent (returns 10000)
10 / 4          # divide (returns 2 because both types are 'int')
10 / float(4) # divide (returns 2.5)

Exceptions

try - except

try:
    image_data = (ndimage.imread(image_file).astype(float) - 
                    pixel_depth / 2) / pixel_depth
      if image_data.shape != (image_size, image_size):
        raise Exception('Unexpected image shape: %s' % str(image_data.shape))
 dataset[num_images, :, :] = image_data