Skip to content

Instantly share code, notes, and snippets.

View viko16's full-sized avatar
🎯
Focusing

viko16 viko16

🎯
Focusing
View GitHub Profile
@viko16
viko16 / addjQuery.js
Last active January 4, 2016 03:59
在没有jQuery的环境下引入jQuery支持。 #javascript
//引入jquery
var j = document.createElement('script');
j.setAttribute('src', 'http://cdn.bootcss.com/jquery/2.1.1/jquery.min.js');
document.body.appendChild(j);
@viko16
viko16 / dialog.html
Last active January 4, 2016 06:39
一个很精致、简洁的弹出框样式 #html
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
body{
font: normal 13px Roboto,arial,sans-serif;
}
.dialog{
position: fixed;
@viko16
viko16 / git.md
Created January 25, 2014 17:06 — forked from suziewong/git.md

github的多人协作

  1. github上你可以用别人的现成的代码 直接 git clone 即可了

  2. 然后你也想改代码或者贡献代码咋办?

Fork

@viko16
viko16 / getServerDate.js
Last active October 23, 2015 02:37
ajax获取服务器时间 #javascript
var something = "http://www.baidu.com"; //任意同域资源,size越小越好
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", something, false);
xmlhttp.send();
console.log("服务器时间:" + new Date(xmlhttp.getResponseHeader("date"))); //自己解析响应头,不一定是"date"的
console.log("本机的时间:" + new Date());
@viko16
viko16 / post-commit.bat
Created April 29, 2014 01:21
服务端的 svn hook 配置 #bat
:: 服务端的 svn hook 配置,放置在服务端svn相应项目的 /hook 目录下
"C:\Program Files\VisualSVN Server\bin\svn.exe" update C:\Zend\Apache2\htdocs\ --quiet --non-interactive --username aaa --password bbb
:: 参数说明
:: C:\Program Files\VisualSVN Server\bin\svn.exe 安装的svn位置
:: C:\Zend\Apache2\htdocs\ 需要项目自动部署的位置(需要提前svn checkout)
:: --username aaa 就填有读写权限的svn帐号
:: --password bbb 上面帐号对应的密码..(废话
@viko16
viko16 / hehevideo.js
Created May 7, 2014 18:49
替换新电影网播放器(临时
//插入播放器的css
var c = document.createElement('link');
c.setAttribute('href', 'http://172.16.144.62/video-js/video-js.css');
document.head.appendChild(c);
//插入播放器的js(为什么不用jquery的插入呢?因为jquery有防xss的限制...)
var j = document.createElement('script');
j.setAttribute('src', 'http://172.16.144.62/video-js/video.js');
document.head.appendChild(j);
//提取真实地址
@viko16
viko16 / rand_select.php
Last active August 29, 2015 14:01
正确的mysql随机查找语句 #sql #php
// 千万不要这样做:
$r = mysql_query("SELECT username FROM user ORDER BY RAND() LIMIT 1");
// 这要会更好:
$r = mysql_query("SELECT count(*) FROM user");
$d = mysql_fetch_row($r);
$rand = mt_rand(0,$d[0] - 1);
$r = mysql_query("SELECT username FROM user LIMIT $rand, 1");
@viko16
viko16 / weixin.js
Created June 6, 2014 06:34
微信判断 #javascript
// 判断微信浏览器
function is_weixin() {
var ua = navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == "micromessenger") {
return true;
} else {
return false;
}
}
@viko16
viko16 / insertScript.js
Created June 10, 2014 08:27
方便在chrome插件中插入js代码 #javascript
function insertScript(path) {
var script = document.createElement('script')
script.src = chrome.extension.getURL(path)
document.body.appendChild(script)
}
// insert patch sdk
insertScript('patch.js')
@viko16
viko16 / nginx_rewrite.sh
Created July 16, 2014 14:40
nginx 禁止ip访问 只允许域名访问 #shell
#将ip访问重定向到域名
server{
listen 80 default_server;
server_name _;
rewrite ^ http://ca.sise.com.cn$request_uri?;
}