Skip to content

Instantly share code, notes, and snippets.

View brianlan's full-sized avatar

Rambo Lan brianlan

  • Meituan
  • Shanghai
View GitHub Profile
@astrojuanlu
astrojuanlu / bezier_curves.py
Last active September 25, 2023 13:09
Interactive Bézier curves with Python using just matplotlib.
import matplotlib
matplotlib.use('webagg')
import numpy as np
from scipy.special import binom
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import matplotlib
matplotlib.use('webagg')
import numpy as np
from scipy.special import binom
import matplotlib.pyplot as plt
@gumblex
gumblex / PathFitter.py
Created April 4, 2015 12:01
Path fitter in Python - An Algorithm for Automatically Fitting Digitized Curves
"""
Ported from Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
http://paperjs.org/
Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey
http://scratchdisk.com/ & http://jonathanpuckey.com/
Distributed under the MIT license. See LICENSE file for details.
All rights reserved.
@yrevar
yrevar / imagenet1000_clsidx_to_labels.txt
Last active July 21, 2024 08:16
text: imagenet 1000 class idx to human readable labels (Fox, E., & Guestrin, C. (n.d.). Coursera Machine Learning Specialization.)
{0: 'tench, Tinca tinca',
1: 'goldfish, Carassius auratus',
2: 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias',
3: 'tiger shark, Galeocerdo cuvieri',
4: 'hammerhead, hammerhead shark',
5: 'electric ray, crampfish, numbfish, torpedo',
6: 'stingray',
7: 'cock',
8: 'hen',
9: 'ostrich, Struthio camelus',
@danijar
danijar / blog_tensorflow_variable_sequence_labelling.py
Last active May 15, 2022 14:28
TensorFlow Variable-Length Sequence Labelling
# Working example for my blog post at:
# http://danijar.com/variable-sequence-lengths-in-tensorflow/
import functools
import sets
import tensorflow as tf
from tensorflow.models.rnn import rnn_cell
from tensorflow.models.rnn import rnn
def lazy_property(function):
@brianlan
brianlan / phoneme_error_rate_calculation.py
Created June 11, 2017 06:13
This script calculates Phoneme Error Rate using package leven (edit distance algorithm). Users can also choose whether to merge phonemes (refer to the paper Speaker-independent phone recognition using hidden Markov models) during calculation.
from collections import namedtuple
import leven # install through pip first
import numpy as np
SparseTensor = namedtuple('SparseTensor', 'indices vals shape')
PHN_MAPPING = {'iy': 'iy', 'ix': 'ix', 'ih': 'ix', 'eh': 'eh', 'ae': 'ae', 'ax': 'ax', 'ah': 'ax',
'ax-h': 'ax', 'uw': 'uw', 'ux': 'uw', 'uh': 'uh', 'ao': 'ao', 'aa': 'ao', 'ey': 'ey',
@alairock
alairock / exceptions.py
Last active May 13, 2024 18:07
Python Async Retry Decorator.
class TooManyTriesException(BaseException):
pass
@IgniparousTempest
IgniparousTempest / Ubuntu_16.06_PCL_1.8.0_install.sh
Last active June 24, 2024 08:08
Install PCL 1.8.0 on Ubuntu 16.04
# Clone latest PCL
sudo apt-get update
sudo apt-get install git
cd ~/Documents
git clone https://github.com/PointCloudLibrary/pcl.git pcl-trunk
ln -s pcl-trunk pcl
cd pcl
# Install prerequisites
@dentechy
dentechy / WSL-ssh-server.md
Last active July 14, 2024 03:54
A step by step tutorial on how to automatically start ssh server on boot on the Windows Subsystem for Linux

How to automatically start ssh server on boot on Windows Subsystem for Linux

Microsoft partnered with Canonical to create Bash on Ubuntu on Windows, running through a technology called the Windows Subsystem for Linux. Below are instructions on how to set up the ssh server to run automatically at boot.

  1. Edit the /etc/ssh/sshd_config file by running the command sudo vi /etc/ssh/sshd_config and do the following
    1. Change Port to 2222 (or any other port above 1000)
    2. Change PasswordAuthentication to yes. This can be changed back to no if ssh keys are setup.
  2. Restart the ssh server:
    • sudo service ssh --full-restart
  3. With this setup, the ssh server must be turned on every time you run Bash on Ubuntu on Windows, as by default it is off. Use this command to turn it on:
@yrevar
yrevar / imagenet1000_clsid_to_labels.txt
Created January 21, 2019 07:47
text: imagenet 1000 class id to human readable labels. (Sergey Zagoruyko, Torch Tutorials GitHub Repository; Retrieved from: https://github.com/torch/tutorials/blob/master/7_imagenet_classification/synset_words.txt)
{n01440764: 'tench, Tinca tinca',
n01443537: 'goldfish, Carassius auratus',
n01484850: 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias',
n01491361: 'tiger shark, Galeocerdo cuvieri',
n01494475: 'hammerhead, hammerhead shark',
n01496331: 'electric ray, crampfish, numbfish, torpedo',
n01498041: 'stingray',
n01514668: 'cock',
n01514859: 'hen',
n01518878: 'ostrich, Struthio camelus',