Skip to content

Instantly share code, notes, and snippets.

@simecek
simecek / Image+as+Numpy+Array.ipynb
Last active May 15, 2017 16:55
Example of Reading Image Into Numpy Array
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@simecek
simecek / ZIP+example.ipynb
Last active August 4, 2017 13:17
Fetch zipped file without temporary extracting it to disk:
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@simecek
simecek / example.r
Created August 18, 2017 11:04
Classification of jpg files into several one letter subfolders
# example of usage
setwd("c:/Users/simecekp/Downloads/")
fls <- dir(patter=".*jpg")
jpg_sort(fls,c("a", "s"))
@simecek
simecek / followers_wc.ipynb
Created August 18, 2017 14:00
Generate wordcloud of followers' descriptions
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@simecek
simecek / gist:1587954
Created January 10, 2012 08:57
Gmail Analysis
function SearchEmail() {
var mySheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var EmailName = Browser.inputBox("Search", "Type from:email@address.cz", Browser.Buttons.OK_CANCEL);
var maxthreads = 250;
var searchedThreads= GmailApp.search("from:(<" + EmailName + ">)", 0, maxthreads);
var regExp = new RegExp(".*<" + EmailName + ">$");
var counter = 1;
for(var i in searchedThreads){
var messages = searchedThreads[i].getMessages();
@simecek
simecek / netiquette.r
Created October 25, 2011 15:12
Email Netiquette
count.google.hits <- function(query) {
# call Google Search and extract the number of hits
url <- paste('http://www.google.com/search?q=', query, sep="")
tmp <- readLines(url, warn=FALSE)
writeLines(tmp, "c:\\temp\\pokus.html")
pattern <- ".*<div id=resultStats>[A-Za-z ]*([0-9 ,]*) results<nobr> \\([0-9.]* seconds\\).*"
count.line <- grep(pattern,tmp)[1]
hits <- sub(pattern, "\\1", tmp[[count.line]])
@simecek
simecek / plotting.R
Created January 10, 2012 09:02
Make the plot of data mined by Google Apps Script
data <- read.csv("http://docs.google.com/spreadsheet/pub?hl=en_US&hl=en_US&key=0AnhE_6FIbbVWdFNxeS1ESWtvSUk5WE5KcnBwVWVqckE&output=csv", header=FALSE, skip=1, as.is=TRUE)
sent <- data.frame(Time=strptime(data[,1], "%H:%M:%S"))
library(ggplot2)
theme_update(panel.background = theme_rect(fill = "grey90", colour = "black"))
xstart <- strptime("01:00:00", "%H:%M:%S")
xend <- strptime("23:00:00", "%H:%M:%S")
ggplot(sent, aes(Time)) + geom_density(fill="grey50", adjust=0.5) + xlim(xstart, xend)
@simecek
simecek / facebook_friendship2.r
Created January 18, 2012 11:33
Facebook Friendship Graph Continued
require(pixmap)
# download small profile picture of each friend
dir.create("photos")
for (i in 1:length(friends.id))
download.file(paste("http://graph.facebook.com", friends.id[i], "picture", sep="/"),
destfile=paste("photos/",friends.id[i],".jpg",sep=""))
system('for i in `ls photos/*.jpg`; do j=${i%.*}; convert $j.jpg $j.pnm; done', wait=TRUE)
# customized node plotting function
@simecek
simecek / Rolling_mean_pandas.ipynb
Created March 16, 2018 06:11
Rolling mean example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@simecek
simecek / facebook_mining.r
Created January 18, 2012 18:26
Facebook Mining
# go to 'https://developers.facebook.com/tools/explorer' to get your access token
access_token <- "******************* INPUT YOUR ACCESS TOKEN ******************************"
require(RCurl)
require(rjson)
# Facebook json function copied from original (Romain Francois) post
facebook <- function( path = "me", access_token, options){
if( !missing(options) ){
options <- sprintf( "?%s", paste( names(options), "=", unlist(options), collapse = "&", sep = "" ) )