Skip to content

Instantly share code, notes, and snippets.

View skylander86's full-sized avatar
🎯
Focusing

Yanchuan Sim skylander86

🎯
Focusing
View GitHub Profile
@skylander86
skylander86 / FileSystemUtils.scala
Last active October 28, 2016 09:13
Scala module for I/O on different filesystems
package nlp.salience.fsutils
/**
* @author yc <https://github.com/skylander86/>
* @version 0.1
*
* This package contains code for transparently reading and writing files to/from supported filesystems.
* This is useful as a drop in replacement that understands filesystem differences.
* Right now, it only supports local file, S3 (either using Hadoop or Amazon AWS SDK) and Hadoop filesystem.
*
* Example usage:
@skylander86
skylander86 / bootstrap.html
Last active March 23, 2016 00:30
Basic quick start bootstrap template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Starter Template for Bootstrap</title>
@skylander86
skylander86 / freebase_instances.C
Created March 25, 2016 22:32
Efficient C code for extracting instances from freebase GZip dump
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define FALSE 0
#define TRUE 1
#define BUFSIZE 1024
int main(void) {
setvbuf(stdin, (char *) NULL, _IOFBF, 0); /* better performance if we buffer stdin */
@skylander86
skylander86 / fleiss kappa.py
Created April 7, 2016 02:08
Compute Fleiss' kappa using numpy.
def fleiss_kappa(M):
"""
See `Fleiss' Kappa <https://en.wikipedia.org/wiki/Fleiss%27_kappa>`_.
:param M: a matrix of shape (:attr:`N`, :attr:`k`) where `N` is the number of subjects and `k` is the number of categories into which assignments are made. `M[i, j]` represent the number of raters who assigned the `i`th subject to the `j`th category.
:type M: numpy matrix
"""
N, k = M.shape # N is # of items, k is # of categories
n_annotators = float(np.sum(M[0, :])) # # of annotators
@skylander86
skylander86 / lambda-ses-forwarder.py
Created January 4, 2017 18:10
Python port of arithmetric/aws-lambda-ses-forwarder. An AWS Lambda function for forwarding incoming emails through SES.
"""
This code is a Python 2.7 port of [aws-lambda-ses-forwarder](https://github.com/arithmetric/aws-lambda-ses-forwarder). Follow instructions there for setting up SES and AWS Lambda.
"""
from email import message_from_file
import json
import logging
import os
import re
@skylander86
skylander86 / certbot-route53.py
Created March 29, 2017 14:47
Get SSL certificates using Certbot and complete challenge automatically using Route 53. A pure Python solution.
#!/usr/bin/env python
from argparse import ArgumentParser
import logging
import os
import sys
import subprocess
import time
import boto3
@skylander86
skylander86 / cclr_calculator.js
Created October 17, 2017 02:03
Creatinine Clearance Calculator Javascript Logic
// set up our units of conversions, could be shared between multiple calculators
var units = {
"age": {"yr": 1, "mth": 12.0},
"weight": {"kg": 1, "lb": 2.20462},
"creatinine": {"gm/L": 0.01, "gm/dL": 0.001, "mg%": 1, "mg/dL": 1, "mg/mL": 0.01},
"output": {"mL/min": 1, "L/hr": 0.06}
};
// get the inputs specific to this calculator (irl, this would come from the form fields)
var inputs = {
@skylander86
skylander86 / GitCryptCheatsheet.md
Last active March 5, 2019 16:49
Cheatsheet for using git-crypt

Notes on using git-crypt

This file has been moved to Gitlab.

@skylander86
skylander86 / keybase.md
Created June 11, 2018 17:46
Keybase Proof

Keybase proof

I hereby claim:

  • I am skylander86 on github.
  • I am skylander (https://keybase.io/skylander) on keybase.
  • I have a public key ASAIqjDt-DzF3IxVW0ni54X5YLuCoK9o6VQ2RyqQjs7-ywo

To claim this, I am signing this object:

@skylander86
skylander86 / date_regexes.py
Created December 25, 2018 05:52
Regular expressions for capturing dates
DATE_REGEXES = [
re.compile(r'\b(?P<year>199\d|200\d|201\d)[\-\u2010\u2014\u2013\.\_\/\s]{1,2}(?P<month>1|2|3|4|5|6|7|8|9|01|02|03|04|05|06|07|08|09|10|11|12)[\-\u2010\u2014\u2013\.\_\/\s]{1,2}(?P<day>1|2|3|4|5|6|7|8|9|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)\b'), # 2017-09-28
re.compile(r'\b(?P<day>1|2|3|4|5|6|7|8|9|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)[\-\u2010\u2014\u2013\.\_\/\s]{1,2}(?P<month>1|2|3|4|5|6|7|8|9|01|02|03|04|05|06|07|08|09|10|11|12)[\-\u2010\u2014\u2013\.\_\/\s]{1,2}(?P<year>199\d|200\d|201\d)\b'), # 28-9-2017
re.compile(r'\b(?P<month>1|2|3|4|5|6|7|8|9|01|02|03|04|05|06|07|08|09|10|11|12)[\-\u2010\u2014\u2013\.\_\/\s]{1,2}(?P<day>1|2|3|4|5|6|7|8|9|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)[\-\u2010\u2014\u2013\.\_\/\s]{1,2}(?P<year>199\d|200\d|201\d)\b'), # 9-28-2017
re.compile(r'\b(?P<year>199\d|200\d|201\d)[\-\u2