Skip to content

Instantly share code, notes, and snippets.

View mckelvin's full-sized avatar

GitHubLeakedPAN, GitHubLeakedMyautsai mckelvin

View GitHub Profile
@mckelvin
mckelvin / marsyas_example.cpp
Created August 7, 2012 09:03
two examples of `marsyas `
#include <string>
#include "marsyas/MarSystemManager.h"
#include "marsyas/SoundFileSource.h"
#include "marsyas/SoundFileSink.h"
#include "marsyas/Series.h"
using namespace std;
using namespace Marsyas;
void
@mckelvin
mckelvin / sshfs_usage.md
Created August 9, 2012 04:01
usage of `sshfs`

refer

## init
$ sudo mkdir /mount_point_absolute_path
$ sudo chown local_user /mount_point_absolute_path

## before
$ sshfs remote@remote_hostname:remote_absolute_path /mount_point_absolute_path
@mckelvin
mckelvin / local.conf
Created August 12, 2012 01:40
/home/kelvin/.config/font-manager/local.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="pattern">
<test name="family" qual="any">
<string>AR PL ShanHeiSun Uni</string>
<string>AR PL New Sung</string>
</test>
<test compare="more_eq" name="pixelsize" >
<double>12</double>
cfdisk (util-linux 2.21.2)
Disk Drive: /dev/sda
Size: 320072933376 bytes, 320.0 GB
Heads: 255 Sectors per Track: 63 Cylinders: 38913
Name Flags Part Type FS Type [Label] Size (MB)
------------------------------------------------------------------------------
sda1 Boot Primary ntfs [Win7] 45271.95
Pri/Log Free Space 0.04*
#!/usr/bin/python2
# -*- coding:UTF-8 -*-
# code related at: http://blog.mckelv.in/articles/1453.html
import sys
distance = lambda a,b : 0 if a==b else 1
def dtw(sa,sb):
'''
@mckelvin
mckelvin / simhash4chromaprint.py
Created August 31, 2012 02:18
SimHash for chromaprint
#!/usr/env python
# -*- coding: UTF-8 -*-
__author__ = 'Myautsai Pan'
import sys
import numpy as np
class SimHash(object):
'''Implements of SimHash for chromaprint'''
def __init__(self, chromaprint=[], bits=32):
self.hash_bits = 32
@mckelvin
mckelvin / random_hamming_dist.py
Created August 31, 2012 03:58
random_hamming_dist
#!/usr/bin/python
# -*- coding:UTF-8 -*-
import numpy as np
def main():
random_hamming_dist()
def random_hamming_dist():
def hamming_dist(a, b, bits=32):
x = a ^ b
@mckelvin
mckelvin / what_the_12306.js
Created September 18, 2012 03:50
a script to help book train ticket at 12306.cn
var what; what = setInterval(function(){window.frames['main'].sendQueryFunc()},10000);
var the;the = setInterval( function(){if(window.frames['main'].$('#gridbox').html().indexOf('有')!=-1){alert('hehe');clearInterval(what);clearInterval(the);}else{console.log('hehehou')}},5000);
@mckelvin
mckelvin / clickjacking_solution1.js
Created October 10, 2012 10:16
a solution for clickhacking
if (top.location !== self.location && document.referrer.search(/http:\/\/[^\/]+\.yourdomain\.com/i) !== 0) {
top.location = self.location;
}
// another to solve this problom is to add `X-Frame-Options` in http response header
// detail: https://blog.whitehatsec.com/x-frame-options/
@mckelvin
mckelvin / bs.py
Last active August 14, 2019 02:49
the RIGHT Binary Search
"""
binary search
"""
def binary_search(num_array, x):
l = 0
r = len(num_array)
while l < r:
mid = l + (r - l) / 2