Skip to content

Instantly share code, notes, and snippets.

View lharries's full-sized avatar
🛳️
Shipping

Luke Harries lharries

🛳️
Shipping
View GitHub Profile
@lharries
lharries / pocket-highlights-to-clipboard.md
Last active April 1, 2020 10:58
Copy pocket highlights to your clipboard

Copy pocket highlights to your clipboard

Enter the following snippet into your chrome developer console

copy($x('.//span[@class="highlight"]').map(x => x.innerText).join("\n"))
@lharries
lharries / login.sh
Created August 13, 2018 12:47
Login to an aws ec2 using the ec2 instance id
ssh -i path/to/pem <ec2-instance-username>@`aws ec2 describe-instances --instance-ids <ec2-instance-id> --query 'Reservations[*].Instances[*].PublicIpAddress' --output=text`
@lharries
lharries / shutdown.sh
Created August 9, 2018 09:59
Shutdown all jupyter notebooks (using the port they are running on)
for i in {8000..8899}; do fuser -n tcp -k $i; done
@lharries
lharries / train_test.py
Created August 1, 2018 08:46
Divide folder of images into train and test
def split_train_test(categories, PATH, percent_test=0.2):
for category in categories:
print(len(os.listdir(PATH+category)))
files = os.listdir(PATH+category)
for file in files:
if np.random.rand(1) < percent_test:
shutil.copyfile(PATH + category +"/" + file, PATH + "test/" +category +"/" + file)
else:
shutil.copyfile(PATH + category +"/" + file, PATH + "train/"+ category +"/" + file)
@lharries
lharries / hacker-news-time-traveller.md
Last active March 3, 2018 20:32
Hacker news time traveller

Hacker news time traveller

Shows the top hacker news articles for a random time in history (excluding the current year)

Instructions

Copy and past the code below into your web browsers console

dateRange = 1