Skip to content

Instantly share code, notes, and snippets.

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox = "0 0 2000 2000" width="1000" height="400">
<defs>
<clipPath id="myClip">
<rect id="myClipRect" x="0" y="0" width="2000" height="2000"/>
</clipPath>
</defs>
<rect x="0" y="0" width="2000" height="2000" fill="#bbb"/>
<rect id="rect" x="0" y="500" width="0" height="50" fill="red"/>
<rect id="rect2" x="0" y="600" width="0" height="50" fill="blue"/>
@jinwei233
jinwei233 / python_brownser.py
Created October 3, 2011 16:39
用python 模拟浏览器行为
import sys, time, os
from mechanize import Browser
LOGIN_URL = 'http://www.example.com/login'
USERNAME = 'DavidMertz'
PASSWORD = 'TheSpanishInquisition'
SEARCH_URL = 'http://www.example.com/search?'
FIXED_QUERY = 'food=spam&' 'utensil=spork&' 'date=the_future&'
VARIABLE_QUERY = ['actor=%s' % actor for actor in
('Graham Chapman',
@jinwei233
jinwei233 / beatifulsoup_eg.py
Created October 3, 2011 08:12
beautifulsoup 分析html文档
#eg 1
from BeautifulSoup import BeautifulSoup
import re
html_text = """
<h2>this is cool #12345678901</h2>
<h2>this is nothing</h2>
<h2>this is interesting #126666678901</h2>
<h2>this is blah #124445678901</h2>
@jinwei233
jinwei233 / nodejs_cli_autocomplete.js
Created October 2, 2011 07:18
命令行自动完成(二级),带询问
var rl = require('readline');
// 一级提示
var completionsCMD = ["help","deploy","compress","console"];
var completionsFILES = ["abc.js","bca.js","cba.js"];
var rli = rl.createInterface(process.stdin,process.stdout,function(line){
// excute when Tab pressed
// only process the last one
_line = line;//for restore
@jinwei233
jinwei233 / post_file_to_php.php
Created September 22, 2011 12:34
上传文件至PHP
var http = require('http');
var fs = require('fs');
function EncodeFieldPart(boundary,name,value) {
var return_part = "--" + boundary + "\r\n";
return_part += "Content-Disposition: form-data; name=\"" + name + "\"\r\n\r\n";
return_part += value + "\r\n";
return return_part;
}
@jinwei233
jinwei233 / http_info.php
Created September 22, 2011 12:21
获取HTTP头信息
<?php
/**
* Access the HTTP Request
*/
class http_request {
/** additional HTTP headers not prefixed with HTTP_ in $_SERVER superglobal */
var $add_headers = array('CONTENT_TYPE', 'CONTENT_LENGTH');
/**
@jinwei233
jinwei233 / svn_commit.js
Created September 20, 2011 14:16
svn gui 提交文件
/*
提交某个文件
*/
var spawn = require('child_process').spawn;
exe(["/c","TortoiseProc","/command:commit","/path:../att.cmd","/logmsg:update"]);
/*
0: success
@jinwei233
jinwei233 / mustache_demo.php
Created September 17, 2011 13:13
mustache php 模板解析
<?php
require_once("../../app/tpl-engine/mustache.php/Mustache.php");
///////////////////////////////////////////simple Hello world//////////////////////////////
$m = new Mustache;
echo $m->render('Hello {{planet}}', array('planet' => 'World!'));
// "Hello World!"
@jinwei233
jinwei233 / template——demo.php
Created September 17, 2011 12:40
PHP 模板 例子
<?php
require_once("../../app/tpl-engine/Haanga.php");
$str = "
Hi {{name}}! Welcome to Koubei.com
{# foreach #}
{% for n in numbers %}
<div>{{n}}</div>
{% endfor %}
@jinwei233
jinwei233 / check_java_installed.js
Created September 16, 2011 13:10
检验JAVA是否安装
/*
判断JAVA是否安装
*/
var spawn = require('child_process').spawn;
exe(["/c","python","a"]);
/*
0: success