Skip to content

Instantly share code, notes, and snippets.

@HungYuHei
HungYuHei / css3-gradient
Created July 19, 2011 14:29
css3渐变
background: -moz-linear-gradient(center bottom, #b1b1b1 0%, #d3d3d3 99%, white 99%);
background: -o-linear-gradient(center bottom, #b1b1b1 0%, #d3d3d3 99%, white 99%);
background: -webkit-gradient(linear,left bottom,left top,color-stop(0, #b1b1b1),color-stop(0.99, #d3d3d3),color-stop(0.99, white));
@HungYuHei
HungYuHei / gist:1094286
Created July 20, 2011 03:42
fedora15修改显示器刷新率
当前用户的显示器刷新率设置在当前用户目录下.config文件夹下的monitors.xml里。
vi ~/.config/monitors.xml
<rate>60</rate>
默认是60,修改成85后,保存退出monitors.xml
(function($) {
$.fn.clippy = function(text, bgcolor) {
if (!bgcolor) {
var node = $(this);
while (node.css('background-color') == 'transparent' && node.length) {
node = node.parent();
}
if (!node.length) {
bgcolor = '#ffffff';
} else {
@HungYuHei
HungYuHei / sed
Created July 23, 2011 03:27
linux replace string command
sed -i "s/\.white-box/\.box-d4d4d4/g" `grep '\.white-box' -rl .`
@HungYuHei
HungYuHei / ie-hack
Created July 27, 2011 15:24
ie hack
selector{
property:value; /* all browser */
property:value\9; /* all IE */
padding:8px\0; /* ie8-9 */
*padding:5px; /* ie6-7 */
+property:value; /* IE7 */
_property:value; /* IE6 */
}
<!--[if !IE]>NOT IE<![endif]-->
@HungYuHei
HungYuHei / rails-template.rb
Created July 28, 2011 14:25 — forked from xslim/rails-template.rb
Rails 3 App Template with JQuery, Mongoid, Compass, HAML & Barista
# rails new NAME -OJ -m https://gist.github.com/raw/903515/rails-template.rb
remove_file 'README'
remove_file 'public/index.html'
remove_file 'public/images/rails.png'
prepend_file 'config/boot.rb' do <<-RB
begin
require 'yaml'
YAML::ENGINE.yamler = 'syck'
@HungYuHei
HungYuHei / rails-back-page
Created July 31, 2011 07:42
rails返回上一页
request.env['HTTP_REFERER']
request.referer
<%= link_to_function "返回上一页", "history.go(-1)" %>
<%= link_to "Back", :back %>
redirect_to :back
@HungYuHei
HungYuHei / gist:1145997
Created August 15, 2011 10:11
把一个元素放在屏幕的中心位置
jQuery.fn.center = function () {
this.css('position','absolute');
this.css('top', ( $(window).height() - this.height() ) / +$(window).scrollTop() + 'px');
this.css('left', ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + 'px');
return this;
}
//这样来使用上面的函数:
$(element).center();
@HungYuHei
HungYuHei / gist:1156874
Created August 19, 2011 14:06
Fedora 15 rvm ruby-1.8.7
cd ~/.rvm/src/ruby-1.8.7-p334/ext/dl
rm callback.func
touch callback.func
ruby mkcallback.rb >> callback.func
rm cbtable.func
touch cbtable.func
ruby mkcbtable.rb >> cbtable.func
@HungYuHei
HungYuHei / gist:1183126
Created August 31, 2011 09:03
干掉ssh同一用户多个登录脚本
#!/usr/local/bin/php
<?php
kickearlyuser();
function kickearlyuser() {
$usernames = array();
$pids = array();
$um = new shell();
$res = $um->ps('sshd:');
foreach ($res as $row) {