Skip to content

Instantly share code, notes, and snippets.

@andrewpatt24
andrewpatt24 / partitionscale.R
Last active August 29, 2015 14:03
Applying scale across a vector with a partition in the data
pscale<-function(scale.var,part.var) {
if (length(scale.var) != length(part.var)) {warning("scale.var and part.var not the same length")}
counter<-1:length(scale.var)
levels<-unique(part.var)
temp.data<-data.frame(scale.var,part.var,counter)
new.data<-temp.data[temp.data$part.var==levels[1],]
@andrewpatt24
andrewpatt24 / Beautifulsoup_opensourcefood.py
Last active August 29, 2015 14:03
Using BeautfulSoup (Python) to pull out recipe tags for a future visualisation project
#import urllib urlparse
import urllib
import requests
import csv
from bs4 import BeautifulSoup
from datetime import datetime
startTime = datetime.now()
#Initialise the csv
@andrewpatt24
andrewpatt24 / gist:147986e30a47f1fbd104
Created June 27, 2014 11:25
Battleships from Code Academy Python course
from random import randint
board = []
for x in range(5):
board.append(["O"] * 5)
def print_board(board):
for row in board:
print " ".join(row)