Skip to content

Instantly share code, notes, and snippets.

View pscollins's full-sized avatar

Patrick Collins pscollins

View GitHub Profile
@pscollins
pscollins / gist:8459832
Created January 16, 2014 17:49
ML scanning
import requests
from bs4 import BeautifulSoup
BASE_URL = "http://en.wiktionary.org/wiki/{}#Danish"
WORDS = ['foo', 'bar', 'baz']
def main():
ans = []
for word in WORDS:
soup = BeautifulSoup(requests.get(BASE_URL.format(word)).text)
@pscollins
pscollins / gist:8469193
Last active January 3, 2016 13:19
let's try again
import requests
from bs4 import BeautifulSoup
BASE_URL = "http://ordnet.dk/ddo/ordbog?query={}"
def main(path_to_file):
ans = []
words = [line.split(" ")[0] for line in open(path_to_file)]
for word in words:
@pscollins
pscollins / gist:8469565
Created January 17, 2014 07:09
multithreaded
import requests
from bs4 import BeautifulSoup
from concurrent import futures
BASE_URL = "http://ordnet.dk/ddo/ordbog?query={}"
def get_ipa(word):
soup = BeautifulSoup(requests.get(BASE_URL.format(word)).text)
try:
return soup.select(".lydskrift")[0].contents[1]
(* In util.pml: *)
structure PArrayPair = struct
type ('a, 'b) t = ('a * 'b) parray
fun fromPairPArray (xs : ('a * 'b) parray) : ('a, 'b) t =
xs
...
end
datatype ('a, 'b) t2
= E2
| Nd2 of 'a * ('a, 'b) t3 * ('a, 'b) t3
and ('a, 'b) t3
= E3
| Nd3 of 'b * ('a, 'b) t2 * ('a, 'b) t2 * ('a, 'b) t2
(* Collect all the items from a t2/t3 tree into a
import java.util.Scanner;
import java.util.ArrayList;
class StarMatrix {
ArrayList<ArrayList<Boolean>> stars;
public StarMatrix (Scanner inputScanner) {
stars = new ArrayList<ArrayList<Boolean>>();
String currentLine;
while (inputScanner.hasNext()) {
Scanner currentLine = Scanner(inputScanner.nextLine());
while(currentLine.hasNextInt()){
Integer current = currentLine.nextInt();
}
}
signature WRAPPABLE = sig
datatype node' = A
end
structure CReturnTyToWrap = struct
datatype node' = A
end
functor WrapStruct(S : WRAPPABLE) = struct
public class HDF5CompoundDSBridgeFactory {
private HDF5CompoundType type;
private IHDF5CompoundWriter writer;
private long startSize;
private int chunkSize;
public HDF5CompoundType getType() {
return type;
}
@Before
public void setUp() throws Exception {
File file = new File(TEST_PATH);
IHDF5Writer writer = HDF5Writer.getDefaultWriter(file);
HDF5CompoundDSBridgeFactory intBuilder = new HDF5CompoundDSBridgeFactory(writer);
intBuilder.setChunkSize(5);
intBuilder.setStartSize(10);
intBuilder.setTypeFromInferred(Integer.class);
intBridge = intBuilder.build(TEST_DS);