Skip to content

Instantly share code, notes, and snippets.

View foru17's full-sized avatar
🎯
Focusing

Luo Lei foru17

🎯
Focusing
View GitHub Profile
@foru17
foru17 / AnimatedToTop.html
Created June 5, 2014 14:03
原生JS返回顶部动画
<div it="gotop"> </div>
<script>
backTop = function (btnId){
var btn = document.getElementById(btnId);
var d = document.documentElement;
var b = document.body;
window.onscroll = btnDisplay;
btn.onclick = function (){
btn.style.display = "none";
window.onscroll = null;
@foru17
foru17 / phpbase1.php
Created June 5, 2014 08:36
php 的基础 if else 兼容语法
<?php if ($username == 'sally'): ?>
<h3>Hi Sally</h3>
<?php elseif ($username == 'joe'): ?>
<h3>Hi Joe</h3>
<?php else: ?>
<html>
<head>
<title>...</title>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
</head>
</html>
<a href="signin.php" rel="nofollow">sign in</a>
@foru17
foru17 / WPressset.php
Created May 7, 2014 13:09
Wordrpess中自定义参数和处理空值
<?php
$guideWord=get_post_meta($post->ID, "guide_word_value", $single = true);
$buttonUrl=get_post_meta($post->ID, "custom_button_url_value", $single = true);
?>
<?php if (!empty ($guideWord)) {echo $guideWord ;} else {echo "If you like it, please rate us" ;}
?>
@foru17
foru17 / bindaclick.js
Created April 29, 2014 02:47
统计绑定页面a链接的一个兼容ajax的方法
$(document).on('click','a',function(e){
var _this = $(e.target);
if(_this.attr('href') != undefined && $(_this).attr('href')!='javascript:void(0);'){
try{
window.external.MyInvoke();
}
catch(e){
}
}
})
@foru17
foru17 / getImgOriginalWidth.js
Created April 16, 2014 04:08
获得图片真实地址的方法
function checkFirstImg(){
$('<img/>').attr('src',$(imgChecked).attr('src')).load(function(){
firstImg_real_width=this.width;
firstImg_real_height=this.height;
console.log('宽度'+firstImg_real_width);
})
}
" 基础
syntax on
set ai
set history=100
set hlsearch " 高亮搜索结果
filetype plugin on
set number "显示行数
set cursorline
set foldenable
set foldmethod=syntax
@foru17
foru17 / mkgithttp.sh
Created April 11, 2014 10:50
创建git HTTP协议仓库
cd /var/www/htdocs/
$ git clone --bare /path/to/git_project gitproject.git
$ cd gitproject.git
$ mv hooks/post-update.sample hooks/post-update
$ chmod a+x hooks/post-update
$ git update-server-info #最后还要执行一下才行
@foru17
foru17 / wordwrap.css
Last active August 29, 2015 13:58
固定宽度过长文件省略样式
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 100px;//需要设置一个宽度
//多行文字,最后一行省略号
overflow:hidden;
text-overflow:ellipsis;
display: –webkit-box;
-webkit-line-clamp:2; //在第几行加省略号
@foru17
foru17 / listen-keyboard.js
Created April 3, 2014 15:54
js监听键盘回车实例
document.onkeydown = function(e) {
// 兼容FF和IE和Opera
var theEvent = e || window.event;
var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
var activeElementId = document.activeElement.id;//当前处于焦点的元素的id
if (code == 13 && activeElementId == "search_text") {
search();//要触发的方法
return false;
}
return true;