Skip to content

Instantly share code, notes, and snippets.

Avatar

Mike Shi mikeshi80

  • Shanghai Hyron Software Co Ltd.
  • Shanghai, China
View GitHub Profile
@justmiles
justmiles / mac.py
Last active Aug 19, 2020
OpenVPN post_auth MAC address check via JumpCloud
View mac.py
# OpenVPN Access Server MAC address checking post_auth script.
# Johan Draaisma
#
# This script can be used with LOCAL, PAM, LDAP, and RADIUS authentication.
# It adds an additional check when authentication is done through the VPN connection.
# It applies to all 3 connection profiles types (server-locked, user-locked, auto-login).
# Windows, Linux, and macOS will be reporting MAC addresses. However, Android and iOS
# devices will not, due to technical reasons. They will instead by reporting UUID. For
# simplicity and legacy reasons we will just call it MAC address from here on in, but
# it can be in theory any unique hardware-based string that the client reports to us.
@duhaime
duhaime / measure_img_similarity.py
Last active Dec 20, 2021
Compare image similarity in Python using Structural Similarity, Pixel Comparisons, Wasserstein Distance (Earth Mover's Distance), and SIFT
View measure_img_similarity.py
import warnings
from skimage.measure import compare_ssim
from skimage.transform import resize
from scipy.stats import wasserstein_distance
from scipy.misc import imsave
from scipy.ndimage import imread
import numpy as np
import cv2
##
@dvlden
dvlden / ffmpeg.md
Last active Jun 13, 2022
Convert video files to MP4 through FFMPEG
View ffmpeg.md

This is my personal list of functions that I wrote for converting mov files to mp4!

Command Flags

Flag Options Description
-codec:a libfaac, libfdk_aac, libvorbis Audio Codec
-quality best, good, realtime Video Quality
-b:a 128k, 192k, 256k, 320k Audio Bitrate
-codec:v mpeg4, libx264, libvpx-vp9 Video Codec
@daicham
daicham / .gitlab-ci.yml
Last active Apr 5, 2022
A sample of .gitlab-ci.yml for a gradle project
View .gitlab-ci.yml
image: java:8-jdk
stages:
- build
- test
- deploy
before_script:
# - echo `pwd` # debug
# - echo "$CI_BUILD_NAME, $CI_BUILD_REF_NAME $CI_BUILD_STAGE" # debug
View PyQt widget overlay.py
# !/usr/bin/env python
# -*- coding:utf-8 -*-
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class overlay(QWidget):
def __init__(self, parent=None):
super(overlay, self).__init__(parent)
@nim65s
nim65s / gist:5e9902cd67f094ce65b0
Created Jan 5, 2015
distance from point to line segment…
View gist:5e9902cd67f094ce65b0
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
A simper python http server can handle mime type properly
View Server.py
# -*- 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 Apr 26, 2022
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.
View ..build-protbuf-2.5.0.md

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 Oct 27, 2012
shell script get subtitle from shooter.cn
View fetchsub.sh
#!/bin/sh
# Author: RA <ravageralpha@gmail.com>
USAGE(){
echo "Usage:$(basename $0) [eng] files..."
}
[ $# -eq 0 ] && USAGE && exit 0
ERROR(){