Skip to content

Instantly share code, notes, and snippets.

View niklio's full-sized avatar

Nik Liolios niklio

  • Instagram
  • New York
View GitHub Profile
import wikipedia, sys
def AStar(start, goal):
closedset = []
openset = [trypage(link) for link in start.links]
navigated = {}
g_score = lambda start: 0
f_score = lambda start: g_score(start) + heuristic_cost(start, goal)
CREATE TABLE `space_ship` (
`name` varchar(128) NOT NULL,
`seq_num` bigint(20) NOT NULL,
`country` varchar(128) NOT NULL,
`captain` varchar(128),
`flight` timestamp,
PRIMARY KEY (seq_num),
UNIQUE KEY (captain, flight),
UNIQUE KEY (name, seq_num)
);
import csv
import pymysql.cursors
connection = pymysql.connect(host='localhost',
user='root',
password='wpbvre999',
db='cs490',
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor)
@niklio
niklio / findsat.py
Last active December 1, 2015 23:03
import csv
class Tagged(object):
def __init__(self, data, tags):
assert len(data[0]) == len(tags)
self.data = data
self.tags = tags
(fn '(zeros n) '(if n '(cons 0 (zeros (- n 1))) '('())))
(fn '(cantor-2 depth)
'(if depth
'((\ '(x) '(join x (zeros (len x)) x))(cantor-2 (- depth 1)))
'('(1))))
@niklio
niklio / around.nlogo
Created May 17, 2016 03:26
Netlogo explorations #1
/*
* ============
* Alphabetizer
* ============
*
* File: AlphaTesting.cpp
* ----------------------
* This file contains the AlphaTesting class to unit test each function in
* Alphabetizer
*
template <typename T>
void SortAlg<T>::insertionSort(typename vector<T>::iterator s,
typename vector<T>::iterator e) {
typename vector<T>::iterator i, j;
for (i = s + 1; i < e; i++) for (j = i; j > s && *(j - 1) > *j; j--) iter_swap(j, j - 1);
}
@niklio
niklio / wer.py
Created February 7, 2017 22:26
Word error rate script
from __future__ import division
import os
import numpy
import argparse
def wer(r, h):
d = numpy.zeros((len(r)+1)*(len(h)+1), dtype=numpy.uint8)
d = d.reshape((len(r)+1, len(h)+1))
for i in xrange(len(r)+1):
@niklio
niklio / serializers.py
Last active March 19, 2017 00:11
DRF Dynamic Serializer
class DynamicFieldsModelSerializer(serializers.ModelSerializer):
"""
Django rest framework dynamic serializer based on
http://www.django-rest-framework.org/api-guide/serializers/#dynamically-modifying-fields.
Gets the lists 'fields' and 'exclude' directly from the query parameters so it expects
the url to look something like:
https://api.example.com/resource/?fields=id&fields=name&exclude=id
"""
def __init__(self, *args, **kwargs):