Skip to content

Instantly share code, notes, and snippets.

@0xnurl
0xnurl / Dockerfile
Created March 14, 2018 13:27
Compile OpenFST Python Extension for Python 3
FROM ubuntu:16.04
# Use bash (Ubuntu default is dash)
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# Ubuntu packages
RUN apt-get update && apt-get install -y ssh gcc=4:5.3.1-1ubuntu1 g++=4:5.3.1-1ubuntu1 make vim zlib1g-dev libbz2-dev libssl-dev python-dev man libreadline-dev build-essential libreadline-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev python3 python3-dev
# Install Python 3.6 from source for optimizations
RUN cd /tmp && wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz && tar xzvf Python-3.6.0.tgz && cd Python-3.6.0 && ./configure && make && make install && cd /tmp && wget https://bootstrap.pypa.io/get-pip.py && python3 get-pip.py
@0xnurl
0xnurl / openfst_python_on_macos.md
Last active October 23, 2021 17:35
Installing OpenFST Native Python Extension on MacOS

Installing OpenFst Native Python Extension on MacOS

Starting from version 1.5, OpenFst has offered a native Python module, making the use of external wrappers like PyFst unnecessary. This has been greatly helpful since PyFst doesn't support Python 3.

1. Install OpenFst

@jarsen
jarsen / tricks.swift
Last active January 16, 2016 14:17
Swift Tricks
// also see http://oleb.net/blog/2014/07/swift-strings/
// Mark: Strings
// if you want to stringByReplacingOccurrencesOfString without using a nil range, you need to convert to NSString first
var str = "some junk"
let tmpString: NSString = str
str = tmpString.stringByReplacingOccurrencesOfString(" ", withString: "+", options: nil, range: NSMakeRange(1, 6))
// find the length of a swift string