Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@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 / 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;
@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 / 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.

operator infix => { associativity left }
func => <K : Hashable, V>(key: K, value: V) -> (K, V) {
return (key, value)
}
let pairs: (String, Int)[] = [
"e" => 10,
"t" => 7,
"i" => 2
]
//
// RBResizer.swift
// Locker
//
// Created by Hampton Catlin on 6/20/14.
// Copyright (c) 2014 rarebit. All rights reserved.
//
import UIKit

Flask-SQLAlchemy Caching

The following gist is an extract of the article Flask-SQLAlchemy Caching. It allows automated simple cache query and invalidation of cache relations through event among other features.

Usage

retrieve one object

# pulling one User object

user = User.query.get(1)