This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Firefox & Webkit 基于 CSS 的圆角实现 */ | |
/* form:http://hugege.com/2008/11/09/css3-firefox-chrome-safari/ */ | |
.box { | |
/* 对chrome、Safari这两个webkit内核的浏览器来说,是用-webkit-border-radius来实现的 */ | |
-webkit-border-top-left-radius:5px 10px; | |
-webkit-border-top-right-radius:5px 10px; | |
-webkit-border-bottom-right-radius:5px 10px; | |
-webkit-border-bottom-left-radius:5px 10px; | |
/* 著名皮肤制作人utom总结了圆角属性不同浏览器下的运用 */ | |
-moz-border-radius: 5px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Linux Vim 配置 | |
"设置缩进 | |
set sw=2 | |
set ts=2 | |
" history文件中需要记录的行数 | |
set history=100 | |
" 带有如下符号的单词不要被换行分割 | |
set iskeyword+=_,$,@,%,#,- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- MySQL 创建超级用户 创建用户,并有localhost下所有数据库的超级权限 | |
mysql> grant all on *.* to monster@localhost identified by "123456"; | |
mysql> flush privileges; | |
- 删除用户 | |
mysql> use mysql; | |
mysql> delete from user where user = 'monster'; | |
- 创建 Repl 的用户 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ruby on Rails truncate_html HTML截断并保持HTML标签不出错 | |
# HTML截断并保持HTML标签不出错 | |
# 可以放入 application_helper.rb 里面 | |
# 前台调用 truncate_html(html_text,:length => 1000) | |
def truncate_html(html, options={}) | |
# Does not behave identical to current Rails truncate method i.e. you must pass options as a hash not just values | |
# Sample usage: <%= html_truncate(category.description, :length => 120, :omission => "(continued...)" ) -%>... | |
previous_tag = "" | |
text, result = [], [] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 禁止在iframe里面打开窗口,自动跳出iframe | |
// 常用于浮动窗口(iframe方式的)验证登陆后跳转到登陆页面,这个时候登陆页面还在iframe里面,通过此方法就可以自动判断并跳出iframe | |
// 跳出iframe | |
if (top.location !== self.location) { | |
top.location.href = location.href | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 限制必须在iframe里面打开页面 | |
// 此方法用户浮动iframe窗口的页面做限制,只有通过iframe才可以打开页面 | |
// 禁止在iframe外打开 | |
if (top.location == self.location) { | |
location.href = "/"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ruby 正则匹配查找替换例子 | |
body = "这里是内容<img src='uploads/a.jpg' />asdgasdgasdg<img src=\"uploads/b.jpg\" alt=\"\">这里是内容是哪的客观加拉塞克的构建" | |
regex = Regex.new("<(img.+?src\\=[\"|']{0,1})(.+?)>",[Regexp::EXTENDED,Regexp::IGNORECASE]) | |
# 用 String.scan 搜索匹配字符串中的多个 img 标签 | |
body.scan(regex).each do |m| | |
puts "matched: #{m.to_s}" | |
# m[0] 是正则里面的第一个()匹配项 | |
puts m[0] | |
puts m[1] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* CSS 文字左右对齐 */ | |
.summary { | |
width:500px; | |
text-align:justify; | |
text-justify:inter-ideograph /* for IE */ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rails 扩展 Paperclip 加入hash目录参数:hashed_path | |
# 扩展 Paperclip 加入hash目录参数 :hashed_path | |
# 建立 config/initializers/paperclip_extensions.rb | |
Paperclip::Attachment.interpolations[:hashed_path] = lambda do |attachment, style| | |
hash = Digest::MD5.hexdigest(attachment.instance.id.to_s) | |
hash_path = '' | |
3.times { hash_path += '/' + hash.slice!(0..2) } | |
hash_path[1..12] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ubuntu grab 引导 Leopard | |
# 1.手动将 Leopard 根目录的 boot 文件复制到 /tmp 目录,然后 | |
$ sudo mv /tmp/boot /boot/grab/boot | |
# 2.修改 grab menu 文件 | |
$ sudo vim /boot/grab/menu.lst | |
# 3.在 menu.lst 里面加入下面的代码并保存: | |
title Mac OSX Leopard |