Skip to content

Instantly share code, notes, and snippets.

Avatar

Avy Faingezicht avyfain

View GitHub Profile
View mitocw.py
import re
from collections import defaultdict
from pprint import pprint
import requests
from bs4 import BeautifulSoup
departments = [
"https://ocw.mit.edu/courses/architecture",
View photo_template.html
<img srcset="{{ site.image_path }}{{page.bucket}}/{{img.sizes[0]}}.xs.{{img.sizes[1]}} 600w,
{{ site.image_path }}{{page.bucket}}/{{img.sizes[0]}}.s.{{img.sizes[1]}} 800w,
{{ site.image_path }}{{page.bucket}}/{{img.sizes[0]}}.{{img.sizes[1]}} 1280w,
{{ site.image_path }}{{page.bucket}}/{{img.sizes[0]}}.m.{{img.sizes[1]}} 2000w,
{{ site.image_path }}{{page.bucket}}/{{img.sizes[0]}}.l.{{img.sizes[1]}} 3000w"
sizes="(max-width: 800px) 600px,
(max-width: 1064px) 800px,
(max-width: 1700px) 1280px,
(max-width: 3000px) 2000px,
3000px"
@avyfain
avyfain / ff.py
Last active Jan 5, 2020 — forked from elaineo/ff.py
Follow Friday
View ff.py
import json
import os
import time
from collections import Counter
# pip install TwitterAPI
from TwitterAPI import TwitterAPI
# Edit ff.py for your account. Go to https://apps.twitter.com/ to get your API keys.
# Don't forget to fill in your screen name (or someone else's).
View geo_viz.r
rm(list=ls())
library(ggplot2)
library(ggmap)
library(plotKML)
cityMap <- qmap(location = 'san francisco', extent = 'device', zoom=12, source="google", maptype="terrain")
cityMap
kinds <- c('transport', 'walking', 'cycling')
colors <- c('#FF7400', '#1240AB', '#FFD300')
View uc_salaries.r
library(XML)
library(ggplot2)
df <- readHTMLTable("http://projects.dailycal.org/paychecker")[[1]]
colnames(df)[4] <- "Salary"
df$Salary <- as.numeric(gsub('[$,]', '', df$Salary))
p <- ggplot(df, aes(x=Department, y=Salary)) + coord_flip()
p + geom_boxplot(aes(color=Rank,
x=reorder(Department, Salary, FUN=max))) +
@avyfain
avyfain / grok.py
Created Jun 15, 2017
A quick demo based on A. Jesse Jiryu Davis' PyCon 2017 "Grok the Gil" talk (https://www.youtube.com/watch?v=7SSYhuk5hmc)
View grok.py
import threading
n = 0
def foo():
global n
n += 1
@avyfain
avyfain / means.py
Last active Dec 25, 2016
Calculating averages efficiently, using Python
View means.py
# Timing script to compare various ways to compute the mean of list of ints
# Short explanation, and results of the experiment can be found here:
# www.faingezicht.com/articles/2016/12/25/means/
import random
import timeit
import statistics
import numpy as np
random.seed(1)
@avyfain
avyfain / econtalk.py
Created Oct 28, 2016
Scrape econtalk episodes, and speed them up!
View econtalk.py
import os
import re
import shlex
import requests
import subprocess
from multiprocessing import Pool
from bs4 import BeautifulSoup
reg = re.compile("http:\/\/files.*.mp3")
View artists.txt
Radiohead
LCD Soundsystem
Lionel Richie
Lana Del Rey
J. Cole
Duran Duran
Zedd
Ryan Adams
Major Lazer
Air
You can’t perform that action at this time.