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 / gist:9087869
Created February 19, 2014 08:05
模仿新浪微博插入话题 自动选中
<textarea id="target"></textarea>
<p><button id="btn">插入话题</button></p>
<script>
var $ = function(id){
return document.getElementById(id);
};
$("btn").onclick = function(){
var con = "请在这里输入自定义话题";
//转载文字
@foru17
foru17 / gist:9265105
Created February 28, 2014 04:11
Git服务器端接受权限设置
git config receive.denyCurrentBranch ignore
@foru17
foru17 / yNcheck.sh
Created March 26, 2014 10:05
SHELL脚本yN选择
while true; do
read -p "Do you wish to install this program?" yn
case $yn in
[Yy]* ) make install; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
echo "Do you wish to install this program?"
@foru17
foru17 / async.js
Created April 3, 2014 06:33
/**异步加载JS的方法*/
/**异步加载JS的方法*/
function loadJS(url,callback,el){
var isIE = !!window.ActiveXObject,
isIE6 = isIE && !window.XMLHttpRequest,
script = document.createElement("script"),
head = isIE6 ? document.documentElement : document.getElementsByTagName("head")[0];
script.type = "text/javascript";
script.async = true;
if(script.readyState){
script.onreadystatechange=function(){
@foru17
foru17 / gist:9949762
Created April 3, 2014 07:22
JavaScript处理网页 禁止右键、复制、按键等
/* 禁止右键 */
document.oncontextmenu = function () { // Use document as opposed to window for IE8 compatibility
return false;
};
/*js监听键盘*/
window.onkeydown=function(e){
console.log(e.keyCode);
return false;
@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;
@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 / 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 #最后还要执行一下才行
" 基础
syntax on
set ai
set history=100
set hlsearch " 高亮搜索结果
filetype plugin on
set number "显示行数
set cursorline
set foldenable
set foldmethod=syntax
@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);
})
}