Skip to content

Instantly share code, notes, and snippets.

@yetone
yetone / waifu2x.py
Created June 26, 2017 03:08 — forked from Tydus/waifu2x.py
waifu2x in 15 lines of Python by @marcan42
import json, sys, numpy as np
from scipy import misc, signal
from PIL import Image
infile, outfile, modelpath = sys.argv[1:]
model = json.load(open(modelpath))
im = Image.open(infile).convert("YCbCr")
im = misc.fromimage(im.resize((2*im.size[0], 2*im.size[1]), resample=Image.NEAREST)).astype("float32")
planes = [np.pad(im[:,:,0], len(model), "edge") / 255.0]
for step in model:
o_planes = [sum([signal.convolve2d(ip, np.float32(kernel), "valid")
@yetone
yetone / README.md
Created April 26, 2017 13:34 — forked from xaviervia/README.md
Sketch 43 files JSON types
@yetone
yetone / python-monkey-patch-built-ins.py
Created April 10, 2017 07:39 — forked from mahmoudimus/python-monkey-patch-built-ins.py
pythonic monkey patching built-in types
# found this from Armin R. on Twitter, what a beautiful gem ;)
import ctypes
from types import DictProxyType, MethodType
# figure out side of _Py_ssize_t
if hasattr(ctypes.pythonapi, 'Py_InitModule4_64'):
_Py_ssize_t = ctypes.c_int64
else:
_Py_ssize_t = ctypes.c_int
@yetone
yetone / init_db_env.py
Created December 21, 2016 03:21 — forked from zhasm/init_db_env.py
fix 'can not find libmysqlclient.so.18' error of python mysql
def init_db_env():
import sys, os
os.environ["PYTHON_EGG_CACHE"] = "/tmp"
os.environ['PYTHONPATH']= '/home/rex/local/lib/python2.6/site-packages'
os.environ["LD_LIBRARY_PATH"] = '/home/rex/local/lib:/usr/lib/'
sys.path.append('/home/rex/local/lib/python2.6/site-packages')
sys.path.append('/home/rex/local/lib')
sys.path.append('/usr/lib/')
from ctypes import cdll
cdll.LoadLibrary("/usr/lib/libmysqlclient.so.18")
@yetone
yetone / verifyReceipt.py
Created December 15, 2016 02:29 — forked from cbguder/verifyReceipt.py
Verify in-app purchase receipts
#!/usr/bin/env python
import sys
import json
import base64
import urllib2
liveURL = 'https://buy.itunes.apple.com/verifyReceipt'
sandboxURL = 'https://sandbox.itunes.apple.com/verifyReceipt'

Virtual DOM and diffing algorithm

There was a [great article][1] about how react implements it's virtual DOM. There are some really interesting ideas in there but they are deeply buried in the implementation of the React framework.

However, it's possible to implement just the virtual DOM and diff algorithm on it's own as a set of independent modules.

@yetone
yetone / asdf.md
Created April 26, 2016 06:58
水电费水电费

我仅仅是测试

from abc import ABCMeta, abstractmethod


class A(object):
  __metaclass__ = ABCMeta

 @abstractmethod
@yetone
yetone / mlnotifications.py
Created April 15, 2016 04:38 — forked from baliw/mlnotifications.py
Mountain Lion Notification Center via Python
import Foundation
import objc
import AppKit
import sys
NSUserNotification = objc.lookUpClass('NSUserNotification')
NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter')
def notify(title, subtitle, info_text, delay=0, sound=False, userInfo={}):
notification = NSUserNotification.alloc().init()
@yetone
yetone / formatTime.js
Created January 19, 2016 08:01 — forked from viko16/formatTime.js
人性化时间处理 #javascript
/**
* 格式化时间戳为人性化的时间
* @param {String} publishTime 时间戳
* @return {String} 人性化时间
*/
function formatTime(publishTime) {
var d_minutes, d_hours, d_days;
var timeNow = parseInt(new Date().getTime() / 1000, 10);
var d;
Error in user YAML: (<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 1
---
# Python 简介
@su27 and @menghan
---

What is Python?

Python: 优雅而健壮的编程语言

  • 高级

  • 易学易读易维护