Skip to content

Instantly share code, notes, and snippets.

View bedekelly's full-sized avatar

Bede Kelly bedekelly

View GitHub Profile
@bedekelly
bedekelly / dynamodb-csv.py
Last active July 16, 2020 16:52
Import a CSV file into a DynamoDB table
import os
import ast
import sys
import csv
import boto3
AWS_ACCESS_KEY = "<YOUR ACCESS KEY HERE>"
AWS_SECRET_KEY = "<YOUR SECRET KEY HERE>"
@bedekelly
bedekelly / poly.cpp
Created May 17, 2017 19:43
help pls
#include <iostream>
#include <functional>
// Polymorphic linked list node:
template<typename T>
struct Linked {
T data;
Linked<T> *next;
};
@bedekelly
bedekelly / templates.c
Last active March 29, 2017 13:32
"Templates" in C
#include "assert.h"
#include "stdio.h"
#include "stdarg.h"
#include "stdlib.h"
#include "string.h"
// Templatized struct type:
#define DEFINE_ARRAY_TEMPLATE(T) \
struct T##Array { \

Keybase proof

I hereby claim:

  • I am bedekelly on github.
  • I am bede (https://keybase.io/bede) on keybase.
  • I have a public key whose fingerprint is C613 5670 C21C 315D B85E 4788 792C FEC4 88C3 19BA

To claim this, I am signing this object:

@bedekelly
bedekelly / nlp-full.py
Created December 3, 2016 23:44
Full NLP code
import os
import nltk
TEST_DATA_DIRECTORY = "test_data"
NP_GRAMMAR = """
NP: {<DT|PP\$>?<JJ>*<NN>} # chunk determiner/possessive, adjectives and noun
{<NNP>+} # chunk sequences of proper nouns
{<NN>+}
"""
@bedekelly
bedekelly / nlp.py
Created December 3, 2016 23:36
NLP
NP_GRAMMAR = """
NP: {<DT|PP\$>?<JJ>*<NN>} # chunk determiner/possessive, adjectives and noun
{<NNP>+} # chunk sequences of proper nouns
"""
@bedekelly
bedekelly / birthday.py
Last active November 23, 2016 01:07
Calculate Martin's Birthday!
from decimal import Decimal, getcontext
def n_times(n, f, s):
"""Apply a function `f`, `n` times, starting with `s`."""
while n > 0:
s = f(s)
n -= 1
return s
@bedekelly
bedekelly / huffman.hs
Created October 23, 2016 14:34
Implementation of Huffman Coding in Haskell. N.B. this sends the frequency table, not the tree itself.
module Huffman where
import Data.List
import Data.Char
-- Extract the value from a Maybe type.
fromJust :: Maybe t -> t
fromJust (Just x) = x
fromJust Nothing = error "Can't retrive value from Nothing!"
@bedekelly
bedekelly / sproogle.go
Created October 22, 2016 17:46
A slightly-adapted version of Rob Pike's search engine example
// Write a mocked search engine using goroutines. A la Rob Pike.
package main
import ("fmt"; "time"; "math/rand")
type Result string
/**
* Mock a remote web service, which takes a random amount of time to respond to
* a search query. It should respond with the *type* of query it's given, as
@bedekelly
bedekelly / dash_server.py
Created September 24, 2016 00:21
Extremely basic server to count number of POST requests.
#!/usr/bin/env python3
import json
import redis
from flask import Flask, request, jsonify
app = Flask(__name__)
r = redis.StrictRedis(host="localhost", port=6379, db=0)