Skip to content

Instantly share code, notes, and snippets.

View abecode's full-sized avatar

Abe Kazemzadeh abecode

View GitHub Profile
# needs zoo for "rollapply"
library(zoo)
# needs e1071 for Hamming window
library('e1071')
# load data
th <- read.csv2('app_status_report_hourly.csv', header=F, sep=',', col.names=c('time','count'))
# normalize the data by the maximum
@abecode
abecode / gist:e7f0c9ab4e284d3fc9b7
Last active August 29, 2015 14:24
deep dreams
#!/usr/bin/env python
# imports and basic notebook setup
from cStringIO import StringIO
import numpy as np
import scipy.ndimage as nd
import PIL.Image
import sys
from IPython.display import clear_output, Image, display
from google.protobuf import text_format
Our yachts are toy boats, the glint on a lovely brief bubble of time. A boat's importance as an escape from reality, as a change of pace, as a theme for reflection and as an art form gives it worth or value.
--William Garden
# Read in data
timeSeriesElectionData <- read.table("twitterElectionTimeline_tsvWithHeader.txt",header=TRUE)
# Attach columns of data as variables in R environment
attach(timeSeriesElectionData)
# open a pdf file for writing
pdf(file="electionTimeline.pdf",height=4,width=12)
# plot the sum of tweets about obama and romney, as a line, with no x-axis ticks, bla bla...
# install and load additional packages
install.packages("zoo")
install.packages("chron")
library(zoo)
library(chron)
# read in data
dt <- read.delim("movieReports/20130109_to_20120113.tsv",header=TRUE,sep="\t",comment.char="",quote="",na.strings="",fileEncoding="UTF-8")
# convert the tweet column from a factor (default) to a character string
@abecode
abecode / envi2png_eg.py
Last active April 21, 2016 00:54
reading ENVI from header (hdr) and openflight (flt) files
import matplotlib.pyplot as plt
import scipy.misc
import spectral.io.envi as envi
# in ftp.djamshidpour.com/SanFrancisco/d20160226T2055
img = envi.open('FBI_TET1_20160226T205533_20160226T205613_L1B_C_EL-02984_LWIR.hdr',
'FBI_TET1_20160226T205533_20160226T205613_L1B_C_EL-02984_LWIR.flt')
#show images in viewer
# plt.imshow(img.asarray().squeeze()) # color