Skip to content

Instantly share code, notes, and snippets.

View mikeshi80's full-sized avatar

Mike Shi mikeshi80

  • Shanghai Hyron Software Co Ltd.
  • Shanghai, China
View GitHub Profile
@epcim
epcim / ovpn_easyrsa_pki.md
Last active March 28, 2024 07:00
openvpn easy-rsa certs (+revoke)
@nim65s
nim65s / gist:5e9902cd67f094ce65b0
Created January 5, 2015 12:57
distance from point to line segment…
from numpy import arccos, array, dot, pi
from numpy.linalg import det, norm
def distance(A, B, P):
""" segment line AB, point P, where each one is an array([x, y]) """
if all(A == P) or all(B == P):
return 0
if arccos(dot((P - A) / norm(P - A), (B - A) / norm(B - A))) > pi / 2:
return norm(P - A)
if arccos(dot((P - B) / norm(P - B), (A - B) / norm(A - B))) > pi / 2:
@HaiyangXu
HaiyangXu / Server.py
Created May 18, 2014 14:00
A simper python http server can handle mime type properly
# -*- coding: utf-8 -*-
#test on python 3.4 ,python of lower version has different module organization.
import http.server
from http.server import HTTPServer, BaseHTTPRequestHandler
import socketserver
PORT = 8080
Handler = http.server.SimpleHTTPRequestHandler
@BennettSmith
BennettSmith / ..build-protbuf-2.5.0.md
Last active October 15, 2022 18:41
Script used to build Google Protobuf 2.5.0 for use with Xcode 5 / iOS 7. Builds all supported architectures and produces a universal binary static library.

Google Protobuf 2.5.0 - Mac OS X and iOS Support

The script in this gist will help you buid the Google Protobuf library for use with Mac OS X and iOS. Other methods (such as homebrew or direct compilation) have issues that prevent their use. The libraries built by this script are universal and support all iOS device architectures including the simluator.

Get the Script

The easiest way to use this script is to simply clone the gist onto your

@ravageralpha
ravageralpha / fetchsub.sh
Created October 27, 2012 16:53
shell script get subtitle from shooter.cn
#!/bin/sh
# Author: RA <ravageralpha@gmail.com>
USAGE(){
echo "Usage:$(basename $0) [eng] files..."
}
[ $# -eq 0 ] && USAGE && exit 0
ERROR(){
@sgruhier
sgruhier / gist:1086231
Created July 16, 2011 10:14
override jquery UI widget method
// If you dont need to call original method
$.widget("ui.addresspicker", $.extend({}, $.ui.addresspicker.prototype, {
_updatePosition: function(){
// Do what you want to
}
}));
// If you need to call original method
var _updatePosition = $.ui.addresspicker.prototype._updatePosition;
$.widget("ui.addresspicker", $.extend({}, $.ui.addresspicker.prototype, {