Skip to content

Instantly share code, notes, and snippets.

@barca
barca / test_against_stored.py
Created May 1, 2020 23:29
I assume you use python3.7
import urllib.request
with urllib.request.urlopen('http://python.org/') as response:
html = response.read()
with open("stored.html", "r+") as file:
if not (str(file.read()) == str(html)):
print("THIS IS WHERE YOU ALERT")
file.seek(0) #sets file pointer to beginning
file.truncate() #empties the file
file.write(str(html))
@barca
barca / benchmark.js
Last active January 8, 2016 10:25
test the performance of let and var
// basic performance test of let and var in node v5.2.0
"use strict"
var n = Date.now();
var count = 0;
for(var i = 0; i < 10000000000; i++){
count += i;
}
console.log(Date.now() - n);
//run 1:35443