Skip to content

Instantly share code, notes, and snippets.

@kingease
kingease / gist:2c9a2e385b815e7bb98c2d7021235327
Created March 20, 2024 06:33
使用令牌的方式访问仓库
git clone https://oauth2:KNgus-zGhsiKkw@gitlab.my.net/mygroup/myproject.git
@kingease
kingease / gist:6715a2719f3ae7a92424350395a1f01b
Last active January 14, 2019 08:13
leetcode - lengthOfLongestSubstring
class Solution:
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
testcase: "jbpnbwwd", "abcabcbb", "bbbbbb"
"""
cout, ret, temp = 0, '', []
for c in s:
if c not in temp:
@kingease
kingease / ctc_decoder.py
Created February 6, 2018 07:36 — forked from awni/ctc_decoder.py
Example CTC Decoder in Python
"""
Author: Awni Hannun
This is an example CTC decoder written in Python. The code is
intended to be a simple example and is not designed to be
especially efficient.
The algorithm is a prefix beam search for a model trained
with the CTC loss function.
# Example for my blog post at:
# http://danijar.com/introduction-to-recurrent-networks-in-tensorflow/
import functools
import sets
import tensorflow as tf
def lazy_property(function):
attribute = '_' + function.__name__
@kingease
kingease / min-char-rnn.py
Created April 3, 2017 16:34 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@kingease
kingease / README.rst
Created April 1, 2017 08:30 — forked from tonyseek/README.rst
Build Python binding of C++ library with cffi (PyPy/Py3K compatible)

Run with Python:

pip-2.7 install cffi
PYTHON=python2.7 sh go.sh

Run with PyPy:

pip-pypy install cffi
PYTHON=pypy sh go.sh
@kingease
kingease / cffi_to_dict.py
Created April 1, 2017 08:30 — forked from inactivist/cffi_to_dict.py
Convert CFFI cdata structure to Python dict.
"""
Convert a CFFI cdata structure to Python dict.
Based on http://stackoverflow.com/q/20444546/1309774 with conversion of
char[] to Python str.
Usage example:
>>> from cffi import FFI
>>> ffi = FFI()
@kingease
kingease / python-char-rnn.py
Created March 9, 2017 15:16 — forked from adriansarno/python-char-rnn.py
Char RNN in python
"""
Character RNN in python
Code adaptation from Andrej Karpathy's Vanilla RNN blog post.
Prepared by Adrian Sarno (mr.sarno2@gmail.com)
"""
import numpy as np
from IPython.display import Latex
from random import uniform
@kingease
kingease / index.js
Last active October 10, 2018 11:47
use jquery and createRange() to select some word in editable control
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var $ = require('jquery');
var $main = $('#main');
$main.html('hello <s>world</s>');
$main.focus();
var nodes = $main.contents();
@kingease
kingease / index.js
Last active August 29, 2015 14:26
first try select some words in contentEditable control
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var editor = document.getElementById('main');
editor.focus();
console.dir(editor);
var startNode = editor.childNodes[0];
console.dir(startNode);
var endNode = editor.childNodes[1].firstChild;
var range = document.createRange();