Skip to content

Instantly share code, notes, and snippets.

@easonhan007
easonhan007 / tuoshui.rb
Created August 7, 2013 13:07
将天涯易读的帖子中的内容抓出来并打印
#encoding: utf-8
# 文件名 tuoshui.rb
# 将天涯易读的帖子中的内容抓出来并打印
# 使用方法:
# ruby tuoshui.rb [天涯易读帖子id] > result.txt
# 如果没有在运行脚本时指定帖子id的话,默认id为40489
require 'watir-webdriver'
def build_url(id)
sprintf('http://www.tianyayidu.cc/article-a-%d-%%d.html', id)
@easonhan007
easonhan007 / encode_img.rb
Created May 25, 2013 14:28
encode a jpg image file to base64 string and display it in an html file
require 'base64'
binary = File.open(File.join('.', 'img.jpg'), 'rb') do |io|
io.read
end
encoded = Base64.encode64(binary)
printf('<img src="data:image/jpeg;base64,%s"></img>', encoded)
# ruby encode_img.rb > img.html
@easonhan007
easonhan007 / basic_css_selector.htm
Created May 12, 2013 09:14
最基本的css选择器
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>basic css selector</title>
<style>
p {color: blue}
</style>
</head>
<body>
<p>昔人已乘黄鹤去,此地空余黄鹤楼,黄鹤一去不复返,白云千载空悠悠。</p>
@easonhan007
easonhan007 / display.htm
Created May 12, 2013 08:53
js控制显示和隐藏
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>显示和隐藏</title>
<script type="text/javascript">
function show(){
document.getElementById('show').style.display = "block"
}
</script>
</head>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>inline style</title>
</head>
<body>
<p style="color:red" >昔人已乘黄鹤去,此地空余黄鹤楼,黄鹤一去不复返,白云千载空悠悠。</p>
<p style ="color:blue">晴川历历汉阳树,芳草萋萋鹦鹉洲。日暮乡关何处是,烟波江上使人愁。</p>
</body>
</html>
@easonhan007
easonhan007 / iframe.htm
Created May 12, 2013 07:28
内嵌框架
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>iframe</title>
</head>
<body>
<h3>内嵌框架</h3>
<iframe src="http://www.baidu.com/" width="800" height="600"></iframe>
</body>
</html>
@easonhan007
easonhan007 / table_with_head.htm
Created May 12, 2013 03:55
有表头的表格
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>有表头的表格</title>
</head>
<body>
<h3>有的表格-3行3列</h3>
<table border >
<thead>
<th>姓名</th>
@easonhan007
easonhan007 / table.htm
Created May 12, 2013 03:43
最简单的表格
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>最简单的表格</title>
</head>
<body>
<h3>简单的表格-3行3列</h3>
<table>
<tr>
<td>cell1</td>
@easonhan007
easonhan007 / basic_tag.html
Created May 12, 2013 02:14
最基本的html标签
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>基本的html标签</title>
</head>
<body>
<h2>标题</h2>
<p>段落</p>
<a href="#">链接</a>
<a href="javascript:;">链接</a>
@easonhan007
easonhan007 / basic.html
Last active December 17, 2015 05:59
最简单的html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>我的第一个html文档</title>
</head>
<body>
<p>你好,html</p>
</body>
</html>