Skip to content

Instantly share code, notes, and snippets.

View masdude's full-sized avatar

masdude

  • China
View GitHub Profile
@vladocar
vladocar / DrawShape.js
Created October 23, 2011 22:33
Draw Shape in Photoshop with JavaScript
/* Code by Mike Hale http://www.ps-scripts.com/bb/viewtopic.php?f=14&t=1802&start=15
with small modification by Vladimir Carrer
*/
function DrawShape() {
var doc = app.activeDocument;
var y = arguments.length;
var i = 0;
@saga
saga / gist:1381374
Created November 21, 2011 01:40
Python实现QQ机器人
目前网上有不少的实现QQ机器人的方法,都不太稳定甚至都已经失效了,而且我们还要冒着QQ号被盗用的风险。其实我们可以自己实现一个QQ自动应答的机器人,思路非常简单:通过模拟登录3G版QQ,来实现相关的操作:
一、首先我们得看看3GQQ的相关协议
为此,我们需要一个支持WAP的浏览器,可以使用Firefox的wmlbrowser插件,打开FF后,访问地址:https://addons.mozilla.org/zh-CN/firefox/search/?q=wmlbrowser&cat=all&x=17&y=11
二、进入3GQQ的进行协议分析
3GQQ的地址是:http://pt.3g.qq.com/s?aid=nLogin3gqq 用安装了wmlbrowser插件的FF打开页面后,启用firebug,即可监视提交的数据。
三、源代码
@marcelcaraciolo
marcelcaraciolo / tf_idf_final.py
Created January 13, 2012 03:38
tf-idf example
#-*- coding: utf-8 -*-
import re
import nltk
from nltk.tokenize import RegexpTokenizer
from nltk import bigrams, trigrams
import math
stopwords = nltk.corpus.stopwords.words('portuguese')
@dexteryy
dexteryy / chinamap.js
Created March 6, 2012 08:03
Cross-browser Interactive map of China with Raphael.js
/**
* Cross-browser Interactive map of China with Raphael JavaScript Library $Rev$
* Created: dexter.yy
* Modified: $Author$ $LastChangedDate$
* note: 此处为源代码,提交svn时请发布压缩后的版本
*/
(function(){
var mapData = {
heilongjiang: { name: "黑龙江", path: "M432.7,36.8l-4.1-1c-1.2,1.3-2.5,2-4.2,2h-0.3c-1.5,0-2.8-0.5-3.8-1.3l-0.2-0.2v-3.7l-0.3-0.5L418,27l-0.6-3l-0.8-0.2c-2-0.8-3.3-2-3.9-3.8c-0.3-1.2-0.8-2.2-1.5-3.3l-1.3-1.7c-1.1-2.2-2.9-2.7-5.3-1.7c-2.2,1.2-4.3,1.2-6.2,0.4l-1.7-1.1l-1.8-2.2l-0.2-0.3l-0.6-1.7c-1.3-2.4-3.5-4.1-6.7-4.9l-3.8-0.4L373.1,0l-0.2,0.3c-2.1,1.7-4,3.8-5.3,6.7l3,1.1V8h0.2l3.8,0.8l0.3,2l-0.3,0.2l-0.5,0.6l-0.6,0.4l-0.1,0.5l0.8,1.5l1.6,2.4l0.1,1c0.5-1.8,1.7-2.9,3.4-3.4c0,0.8,0.3,1.3,1,1.8l1.3,1.3c0.5,0.2,0.4,0.7-0.6,1.5l-0.6,0.5l-0.3,0.9c-0.2,0.1-0.2,0.4-0.2,0.8v0.5l-0.5,1.6c-0.3,0.6-0.5,1.2-0.6,2.1l0.1,1.1l0.4,0.9l0.3,0.5l1.3,3.3l1,1.7l1.2,0.9l1.1,0.1l3.7-3l1.2-0.7l1.8-0.3l0.6,0.1l3.6,0.2l0.5-0.2l1.1-0.5l0.2-0.8c0.2-1,0.7-2,1.5-3l0.2-0.2c0.4-0.5,1-0.6,1.8-0.5c1.2-0.2,2,0.2,2.5,1c0.2,0.3,0.6,0.5,1,
@paolorossi
paolorossi / html5-video-streamer.js
Created March 7, 2012 13:21
Node.js HTML5 video streamer
/*
* Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js
*/
var http = require('http'),
fs = require('fs'),
util = require('util');
http.createServer(function (req, res) {
var path = 'video.mp4';
@hrldcpr
hrldcpr / tree.md
Last active January 24, 2026 21:18
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@luetkemj
luetkemj / wp-query-ref.php
Last active April 8, 2026 18:20
WP: Query $args
// This gist is now maintained on github at https://github.com/luetkemj/wp-query-ref
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.github.io
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/4.9.4/src/wp-includes/query.php
*/
if (typeof (AC) === "undefined") {
AC = {}
}
AC.ImageReplacer = Class.create({
_defaultOptions: {
listenToSwapView: true,
filenameRegex: /(.*)(\.[a-z]{3}($|#.*|\?.*))/i,
filenameInsert: "_☃x",
ignoreCheck: /(^http:\/\/movies\.apple\.com\/|\/105\/|\/global\/elements\/quicktime\/|_(([2-9]|[1-9][0-9]+)x|nohires)(\.[a-z]{3})($|#.*|\?.*))/i,
attribute: "data-hires",

Redis + LibUV prototype README

Special thanks to Dušan Majkic (dmajkic, https://github.com/dmajkic/redis/) for his project on GitHub that gave us the opportunity to quickly learn some on the intricacies of Redis code. His project also helped us to build our prototype quickly.

Get source repository

First clone the Redis sources from https://github.com/antirez/redis.

  • On your computer create a working folder and cd into it.
  • Clone antirez/redis repository:
@Chairo
Chairo / requests.py
Created March 27, 2012 12:56
requests mutil-threading
# -*- coding:utf-8 -*-
import requests
from time import sleep
from threading import Thread
UPDATE_INTERVAL = 0.01
class URLThread(Thread):
def __init__(self, url, timeout=10, allow_redirects=True):
super(URLThread, self).__init__()