Skip to content

Instantly share code, notes, and snippets.

@davish
davish / FindCenter.py
Created March 4, 2012 20:52
Find the center of a 2D polygon or line with the coordinates of it's vertices
verts = 0
def getInput():
""" Gets the number of vertices from the user """
global verts
print "How many vertices?"
verts = input()
listInputs(verts)
def listInputs(vertices):
""" Finds out the x and y coords of the vertices together """
@davish
davish / seismograph.ino
Created September 30, 2012 02:09
Just some code for a seismograhp
/*
seismograph
records intensity and direction of earthquake
seismograph created 22 Sep 2012
by Davis Haupt
License: https://raw.github.com/dbh937/files/master/license
*/
const int threshold = 1; // minimum reading of the sensors that generates a note
const int interval = 250; // Time between checking the sensors, 1/4 a second
@davish
davish / bookscraper.py
Created January 6, 2013 00:53
Python program to scrape data from a hypertext e-book (e.g. Eloquent JavaScript) into a previously created subdirectory book/ of the current working directory. The one dependency is BeautifulSoup4. Import the module and call the scrape() function with the url, id of the div containing the table of contents, and the css class of the div containin…
# Copyright (c) Davis Haupt
# Licenced under the MIT License
from bs4 import BeautifulSoup
import urllib
def getContent(url, content_div):
soup = BeautifulSoup(urllib.urlopen(url))
return (soup.find("div", content_div), soup.title.string)
using sources: [{'url': 'https://pypi.org/simple', 'verify_ssl': True, 'name': 'pypi'}]
Using pip: -i https://pypi.org/simple
ROUND 1
Current constraints:
coveralls (from -r /var/folders/ls/1044ldlx53586vsljpbl5pj40000gn/T/pipenv-_fwe0gio-requirements/pipenv-f5r0h2tf-constraints.txt (line 2))
unittest-xml-reporting (from -r /var/folders/ls/1044ldlx53586vsljpbl5pj40000gn/T/pipenv-_fwe0gio-requirements/pipenv-f5r0h2tf-constraints.txt (line 3))
Finding the best candidates:
found candidate coveralls==1.7.0 (constraint was <any>)
using sources: [{'url': 'https://pypi.org/simple', 'verify_ssl': True, 'name': 'pypi'}]
Using pip: -i https://pypi.org/simple
ROUND 1
Current constraints:
coveralls (from -r /var/folders/ls/1044ldlx53586vsljpbl5pj40000gn/T/pipenv-_fwe0gio-requirements/pipenv-f5r0h2tf-constraints.txt (line 2))
unittest-xml-reporting (from -r /var/folders/ls/1044ldlx53586vsljpbl5pj40000gn/T/pipenv-_fwe0gio-requirements/pipenv-f5r0h2tf-constraints.txt (line 3))
Finding the best candidates:
found candidate coveralls==1.7.0 (constraint was <any>)
module.exports = async (params) => {
const {app} = params;
let file = app.workspace.getMostRecentLeaf()?.view?.file;
if (!file) {
return;
}
let frontmatter = app.metadataCache.getFileCache(file)?.frontmatter;
let repo = frontmatter["gh-repo"]
if (!repo) {
return;