Skip to content

Instantly share code, notes, and snippets.

View yupbank's full-sized avatar
🐝
beeee

Peng Yu yupbank

🐝
beeee
View GitHub Profile
@yupbank
yupbank / index.html
Created April 20, 2022 17:33
Rotating Spinner SVG Icon Animated with CSS / Sass
<html>
<head>
<title>Rotating Spinner Icon</title>
</head>
<body>
<svg id="loading-spinner" xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48">
<g fill="none">
import tensorflow as tf
from copy import deepcopy
def copy_tensor_to_graph(tensor, to_graph, cached_tensors, scope=''):
if scope != '':
new_name = scope + '/' + tensor.name
else:
new_name = tensor.name
import numpy as np
import time
def timeit(func):
def _(*args, **kwargs):
start = time.time()
res = func(*args, **kwargs)
end = time.time() - start
print('Func: %s, runtime: %.6f' % (func.__name__, end))
@yupbank
yupbank / factorial.py
Created February 23, 2018 01:05
savedModel in tensorflow doing factorial
import tensorflow as tf
import os
tf.app.flags.DEFINE_string('output_dir', '/tmp/factorial_output',
"""Directory where to export inference model.""")
tf.app.flags.DEFINE_integer('model_version', 1,
"""Version number of the model.""")
FLAGS = tf.app.flags.FLAGS
@yupbank
yupbank / number_hack.py
Created July 8, 2012 01:44 — forked from Jach/number_hack.py
Overrides the Python integer five to be equal to four with ctypes magic
import sys
import ctypes
pyint_p = ctypes.POINTER(ctypes.c_byte*sys.getsizeof(5))
five = ctypes.cast(id(5), pyint_p)
print(2 + 2 == 5) # False
five.contents[five.contents[:].index(5)] = 4
print(2 + 2 == 5) # True (must be sufficiently large values of 2 there...)
@yupbank
yupbank / wawammseg.py
Created June 30, 2012 09:22 — forked from onlytiancai/wawammseg.py
写了一个简单的支持中文的正向最大匹配的机械分词,其它不用解释了,就几十行代码
# -*- coding:utf-8 -*-
'写了一个简单的支持中文的正向最大匹配的机械分词,其它不用解释了,就几十行代码'
'搜狗词库下载地址:http://vdisk.weibo.com/s/7RlE5'
import string
__dict = {}
def load_dict(dict_file='words.dic'):
'加载词库,把词库加载成一个key为首字符,value为相关词的列表的字典'