Skip to content

Instantly share code, notes, and snippets.

View mckelvin's full-sized avatar

GitHubLeakedPAN, GitHubLeakedMyautsai mckelvin

View GitHub Profile
@mckelvin
mckelvin / sonic_freq.py
Created October 12, 2012 10:54
音符模拟发生
#!/usr/bin/python
# coding: UTF-8
import time
import numpy as np
from numpy.fft import fft, ifft
from numpy.random import random_sample
from alsaaudio import PCM, PCM_NONBLOCK, PCM_FORMAT_FLOAT_LE
C_freq = np.float128(440)
magic = 2 ** (1/12.)
@mckelvin
mckelvin / example1.c
Created October 19, 2012 08:32
an example to compute emd
# include <stdio.h>
# include <math.h>
# include "emd.h"
/* 欧几里得距离 */
float dist(feature_t *F1, feature_t *F2) {
int dX = F1->X - F2->X;
int dY = F1->Y - F2->Y;
int dZ = F1->Z - F2->Z;
return sqrt(dXdX + dY*dY + dZ*dZ);
library(lpSolve)
# 欧几里得距离
euclid_dist <- function(f1, f2) {
return(sqrt(sum((f1 - f2)^2)))
}
# 计算EMD
emd <- function(dist, w1, w2) {
# 准备lp.transport()参数
#coding:utf-8
import numpy as np
import rpy2.robjects as robjects
# 从R中导入lp.transport()
robjects.r['library']('lpSolve')
transport = robjects.r['lp.transport']
def euclid_dist(feature1, feature2):
"""计算欧氏距离"""
@mckelvin
mckelvin / google_beijing.hosts
Created October 23, 2012 08:57
alive hosts in [203.208.44.1, 203.208.49.254]
# *.google.com 笛卡尔集
203.208.45.193
203.208.45.195
203.208.45.196
203.208.45.200
203.208.45.192
203.208.45.201
203.208.45.202
203.208.45.197
203.208.45.203
203.208.46.143 rimeime.googlecode.com
#google plus game
203.208.46.143 newsfeed-dot-latest-dot-rovio-ad-engine.appspot.com
203.208.46.143 project-slingshot-gp.appspot.com
203.208.46.143 r2303.latest.project-slingshot-hr.appspot.com
203.208.46.143 r3115-dot-latest-dot-project-slingshot-gp.appspot.com
203.208.46.143 r3138-dot-latest-dot-project-slingshot-gp.appspot.com
203.208.46.143 r3232-dot-latest-dot-project-slingshot-gp.appspot.com
203.208.46.143 r3269-dot-latest-dot-project-slingshot-gp.appspot.com
203.208.46.143 ct-google.crimecitygame.com
@mckelvin
mckelvin / TinyHTTPProxy.py
Created November 12, 2012 05:49 — forked from irachex/TinyHTTPProxy.py
Tiny HTTP Proxy. Usuage: python TinyHTTPProxy.py -p 11028
#!/usr/bin/python
__doc__ = """Tiny HTTP Proxy.
This module implements GET, HEAD, POST, PUT and DELETE methods
on BaseHTTPServer, and behaves as an HTTP proxy. The CONNECT
method is also implemented experimentally, but has not been
tested yet.
Any help will be greatly appreciated. SUZUKI Hisao
/**
* @class CheckerBoard
*
* the result is expected to be:
* # # # #
* # # #
* # # # #
* # # #
* # # # #
* # # #
[x,y,z]=meshgrid(linspace(-3,3,120));
f=(x.^2 + (5/2)*y.^2 + z.^2 - 1).^3 - (1/16)\*y.^2.\*z.^3 - x.^2.*z.^3;
[f1,v]=isosurface(x,y,z,f,0);
%newplot;
p=patch('Faces',f1,'Vertices',v,'CData',v(:,3),'facecolor','flat','EdgeColor','k');
isonormals(x,y,z,f,p);
view(3);
axis equal;
grid on;
set(p,'AmbientStrength',.6);
for a=0:112;
for b=0:60;
u=a/2;
w=b/2;
v=w/50-0.3;
X(a+1,b+1)=cos(u)+v\*cos(u/2)\*cos(u);
Y(a+1,b+1)=sin(u)+v\*cos(u/2)\*sin(u);
Z(a+1,b+1)=v*sin(u/2);
T(a+1,b+1)=u;
end