Skip to content

Instantly share code, notes, and snippets.

View mashihua's full-sized avatar
🏠
Working from home

Shihua Ma mashihua

🏠
Working from home
View GitHub Profile
@mashihua
mashihua / setbit_performance
Created December 4, 2014 14:00
different performance
/*
Different performance for https://github.com/ceejbot/xx-bloom/blob/master/lib/bloom.js
Output (2.4 GHz Intel Core i7):
setbit cost: 24304ms
fastSetbit cost: 1ms
*/
var assert = require('assert')
function setbit(bit){
# Usage:
1. Confirm you install node at /usr/bin folder
2. Confirm you download shooter to /usr/bin folder
3. Open Automator application
4. In this application create a new service
5. Then you need to select movie files for "Service receives selected" and choose Finder.app for the second option. Then drag the Run AppleScript into the window on the right.
6. Pass Shoot Subtitles.workflow code into the AppleScript window
7. Save to "Shoot Subtitles" as it's name
8. Selected movie file in the Finder, you can right-click, go to Services, and select "Shoot Subtitles".
9. Enjoy it.
function prompt_char {
val='❯'
if [ $UID -eq 0 ]; then echo "#"; else echo "\033[38;5;265m${val}\033[0m\033[38;5;267m${val}\033[0m\033[38;5;80m${val}"; fi
}
function time_reminder {
knock_time=18
sleep_time=22
cond=$(date +"%H")
if [ $cond -ge $sleep_time ]; then
#!/bin/bash
for i in `netstat -an | grep -i ':80 '| grep 'EST' | awk '{print $5}' | cut -d : -f 1 | sort | uniq -c | awk '{if($1 > 5) {print $2}}'`
do
echo $i >> /tmp/blockip
/sbin/iptables -A INPUT -p tcp -j DROP -s $i
done
@mashihua
mashihua / google_beijing.coffee
Created June 16, 2014 06:02
Google valid server
spawn = require('child_process').spawn
tls = require 'tls'
###
Google Beijing:
203.208.32.0 – 203.208.63.255
###
ips = []
for ip3 in [32...64]
var thunkify = require('thunkify')
module.exports = function(model){
var methods = ['save',
'create',
'find',
'findById',
'remove',
'aggregate',
'count',
@mashihua
mashihua / qzone_images_download
Last active August 29, 2015 13:58
download qzone images
#!/usr/bin/env coffee
http = require 'http'
url = require 'url'
fs = require 'fs'
{spawn} = require 'child_process'
JS = """
//For qzone:
var doc, imgs, img, i, val, s, len;
bsearch = (key, values, comp)->
max = values.length
min = 0
comp = comp or (a, b)-> a - b
while true
if min > max
return -1
mid = max + min >> 1
cmp = comp key, values[mid]
if cmp is 0
{
"port":9001,
"config":{
"repo": "mashihua/Hphoto"
},
"branchs":["master"]
}