Skip to content

Instantly share code, notes, and snippets.

@yetone
yetone / js-crypto-libraries.md
Last active July 17, 2017 23:56 — forked from jo/js-crypto-libraries.md
List of JavaScript Crypto libraries.

JavaScript Crypto Libraries

I start with a list and plan to create a comparison table.

WebCryptoAPI

http://www.w3.org/TR/WebCryptoAPI/

This specification describes a JavaScript API for performing basic cryptographic operations in web applications, such as hashing, signature generation and verification, and encryption and decryption. Additionally, it describes an API for applications to generate and/or manage the keying material necessary to perform these operations. Uses for this API range from user or service authentication, document or code signing, and the confidentiality and integrity of communications.

@yetone
yetone / watch.sh
Created November 15, 2015 09:29 — forked from mikesmullin/watch.sh
watch is a linux bash script to monitor file modification recursively and execute bash commands as changes occur
#!/usr/bin/env bash
# script: watch
# author: Mike Smullin <mike@smullindesign.com>
# license: GPLv3
# description:
# watches the given path for changes
# and executes a given command when changes occur
# usage:
# watch <path> <cmd...>
#
@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;
@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()

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 / 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'
@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 / 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 / README.md
Created April 26, 2017 13:34 — forked from xaviervia/README.md
Sketch 43 files JSON types
@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")