Instantly share code, notes, and snippets.

View squads_new2.json
[{"Position":"GK","Name":"Essam El-Hadary","Country":"Egypt","Group":"A","Links":"NA"},{"Position":"GK","Name":"Sherif Ekramy","Country":"Egypt","Group":"A","Links":"NA"},{"Position":"GK","Name":"Mohamed El-Shenawy","Country":"Egypt","Group":"A","Links":"NA"},{"Position":"DF","Name":"Ali Gabr","Country":"Egypt","Group":"A","Links":"NA"},{"Position":"DF","Name":"Ahmed Elmohamady","Country":"Egypt","Group":"A","Links":"https:\/\/www.dropbox.com\/s\/dq90h2nm1qy21j5\/4_Ahmed%20Elmohamady.mp3?dl=0"},{"Position":"DF","Name":"Ahmed Hegazi","Country":"Egypt","Group":"A","Links":"NA"},{"Position":"DF","Name":"Ahmed Fathy","Country":"Egypt","Group":"A","Links":"NA"},{"Position":"DF","Name":"Ayman Ashraf","Country":"Egypt","Group":"A","Links":"NA"},{"Position":"DF","Name":"Mohamed Abdel-Shafy","Country":"Egypt","Group":"A","Links":"NA"},{"Position":"DF","Name":"Mahmoud Hamdy","Country":"Egypt","Group":"A","Links":"NA"},{"Position":"DF","Name":"Saad Samir","Country":"Egypt","Group":"A","Links":"NA"},{"Position":"MF","Nam
View bourbaki.R
library(ggplot2)
library(ggforce)
circles <- data.frame(x0 = 0, y0 = 0, r = 5)
# Use coord_fixed to ensure true circularity
ggplot() +
geom_circle(aes(x0=x0, y0=y0, r=r), data=circles) +
coord_fixed() +
annotate("text", x = 5, y = 4.5, label = "Nicolas Bourbaki") +
View letter_enumeration.py
import string
[ letter: (i+1) % 10 for i, letter in enumerate(string.ascii_lowercase) ]
View download_pdfs.py
import requests
from bs4 import BeautifulSoup as bs
def download_file(url):
res = requests.get(url)
soup = bs(res.text)
pdfs = [(link.get('href').split('/')[-1], url+link.get('href')[1:])
for link in soup.findAll('a') if 'notes' in link.get('href')]
#Where the magic happens.
View nyc_train_stations.csv
Train Stations Subway transfers Connections Station Label
1 Van Cortlandt Park–242nd Street None None 1
1 238th Street None None 2
1 231st Street None None 3
1 Marble Hill–225th Street None None 4
1 215th Street None None 5
1 207th Street None None 6
1 Dyckman Street None None 7
1 191st Street None None 8
1 181st Street None None 9
View colored_equations.Rmd
title output header-includes
Colored Formulas
html_document
\usepackage{textcolor}
\usepackage{xcolor}
knitr::opts_chunk$set(echo = TRUE)
View eulers_num_approximation.py
#https://www.reddit.com/r/math/comments/79jdy1/pick_a_uniformly_random_number_in_01_and_repeat/
import random
import numpy as np
def get_to_one():
track = 0
count = 0
while track < 1:
track+=random.random()
count+=1
View gist:2f8bd10a1e4d47447d3cd2540aa28436
Verifying my Blockstack ID is secured with the address 17b9hyyeoVTZCwgmGQ7bYB3bZCo6NYqFdZ https://explorer.blockstack.org/address/17b9hyyeoVTZCwgmGQ7bYB3bZCo6NYqFdZ
View download-kaggle-data.py
import requests
# The direct link to the Kaggle data set
data_url = 'http://www.kaggle.com/c/digit-recognizer/download/train.csv'
# The local path where the data set is saved.
local_filename = "train.csv"
# Kaggle Username and Password
kaggle_info = {'UserName': "my_username", 'Password': "my_password"}
View pdf_two_cols_2_one_col.R
library(pdftools)
library(tesseract)
library(magick)
pdf_name <- "file_name.pdf" #Insert file name
pdf <- pdf_text(pdf_name)
num_pages = length(pdf)
#Function takes in a page, converts to an image, then splits it into halves and returns them
read_pdf_pages <- function(name_pdf, page_num, height, width){