Skip to content

Instantly share code, notes, and snippets.

View a-y-khan's full-sized avatar

Ayla Khan a-y-khan

  • Salt Lake City, UT, USA
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@a-y-khan
a-y-khan / test_ijson_parser.py
Created January 21, 2019 00:54
Naive parsing and output of JSON attributes to CSV.
import csv
import ijson
def test_ijson(filename):
record = {'records.item.author': None,
'records.item.author_flair_text': None,
'records.item.body': None}
parser = ijson.parse(open(filename, 'r'))
@a-y-khan
a-y-khan / graphene_hello_world.py
Last active March 4, 2019 05:00
Graphene Hello World
# https://gist.github.com/a-y-khan/69189c26df2dcbc8a252b02af897977d
# Super-simple example from Graphene tutorial
import graphene
from gql import gql, Client
class Query(graphene.ObjectType):
hello = graphene.String(argument=graphene.String(default_value='world'))
@a-y-khan
a-y-khan / test_mlflow.py
Last active December 16, 2019 02:24
Simple, contrived example to trigger MLFlowLogger pickle bug
from argparse import Namespace
import itertools
import os
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data as data
import pytorch_lightning as pl
@a-y-khan
a-y-khan / edit_distance_benchmarks.ipynb
Created January 30, 2020 07:29
Edit distance benchmarks
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@a-y-khan
a-y-khan / sudoku4.pl
Last active March 11, 2020 06:57
Sudoku solution from Seven Languages in Seven Weeks, SWI-Prolog version
%% https://www.swi-prolog.org/man/clpfd.html
:- use_module(library(clpfd)).
%% ---
%% Excerpted from "Seven Languages in Seven Weeks",
%% published by The Pragmatic Bookshelf.
%% Copyrights apply to this code. It may not be used to create training material,
%% courses, books, articles, and the like. Contact us if you are in doubt.
%% We make no guarantees that this code is fit for any purpose.
%% Visit http://www.pragmaticprogrammer.com/titles/btlang for more book information.
import json
def parse_line(file_object):
while True:
line = file_object.readline()
if not line:
break
yield json.loads(line)
with open('test.txt', 'r') as file_reader: