Skip to content

Instantly share code, notes, and snippets.

View viko16's full-sized avatar
🎯
Focusing

viko16 viko16

🎯
Focusing
View GitHub Profile
@viko16
viko16 / timespan.php
Created January 14, 2015 02:07
最高级别的时间差(年、月、日、时、分、秒) #php
/**
* Timespan
*
* 返回最高级别的时间差(年、月、日、时、分、秒)
*
* @access public
* @param integer a number of seconds
* @param integer Unix timestamp
* @return integer
*/
@viko16
viko16 / install.sh
Created February 12, 2015 03:09
composer 安装 laravel 4.2
# 安装laravel 4.2.11 版本
composer create-project "laravel/laravel:4.2.11" project_name --prefer-dist
# 以下这句则安装最新版,目前是5.0
composer create-project laravel/laravel project_name --prefer-dist
@viko16
viko16 / base.css
Created May 19, 2015 16:22
去除移动端点击时产生的边框 #css
a, button, input{
-webkit-tap-highlight-color:rgba(255,0,0,0);
}
/*
1.去除android a/button/input标签被点击时产生的边框
2.去除ios a标签被点击时产生的半透明灰色背景
*/
@viko16
viko16 / lt-ie8.html
Last active August 29, 2015 14:23
屏蔽 IE6 7 #html
<!--[if lt IE 8]>
<style type="text/css">html{overflow:hidden}body{height:100%;overflow:auto}#upgradeyoubrowser{position:fixed;height:100%;width:100%;top:0;left:0;bottom:0;right:0;z-index:9999;background:#fff;padding:30px}#upgradeyoubrowser h3{padding:30px}#upgradeyoubrowser a{color:#08c;text-decoration:underline}</style>
<div id="upgradeyoubrowser">
<h1>是时候升级你的浏览器了</h1>
<h2>你正在使用过期的 Internet Explorer,请升级或更换后再访问。</h2>
<h3>建议你下载安装,以便更好地访问我们的网站 : )</h3>
<ul>
<li><a href="http://windows.microsoft.com/zh-cn/windows/upgrade-your-browser" target="_blank">Microsoft Internet Explorer 9</a></li>
@viko16
viko16 / font.css
Last active October 9, 2015 12:42
让 Mac 下 Chrome 字体变清晰
body {
font-family: "Helvetica Neue",Helvetica,"Hiragino Sans GB","STHeitiSC-Light","Microsoft YaHei","微软雅黑",Arial,sans-serif;
-webkit-font-smoothing: antialiased;
}
/*
参考:http://www.qianduan.net/mac-the-next-pages-of-chinese-fonts-optimized.html
*/
@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 / iniClass.cs
Last active December 20, 2015 21:49
C# ini编辑类
class INIClass
{
public string inipath;
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
/// <summary>
@viko16
viko16 / HideTablePages.cs
Created August 10, 2013 12:51
tablecontrol 隐藏部分tabpage,按键后显示 #winform
TabPage[] tp=new TabPage[4];
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 1; i < tabControl1.TabPages.Count; i++)
{
tp[i] = tabControl1.TabPages[i];
}
for (int i = 1; i < tp.Length; i++)
{
tabControl1.TabPages.Remove(tp[i]);
@viko16
viko16 / CheckIsIp.cs
Last active December 20, 2015 21:49
巧妙验证是否ip
using System.Net;
try
{
IPAddress ipTest = IPAddress.Parse(txtBox1.Text);//string转化为ip地址
}
catch (Exception)
{
toolTip1.Show("ip有误", txtBox1, 2000); //2000是提示显示的时间,单位毫秒
}
@viko16
viko16 / CheckEmpty.cs
Created August 11, 2013 06:19
检查各个控件是否有空值 #winform
/// <summary>
/// 检查各个控件是否有空值
/// </summary>
/// <returns>无空值返回true</returns>
private Boolean CheckEmpty()
{
foreach (Control cur in this.Controls)
{
//if (cur is TextBox && cur.Text == "") /*两种方式皆可,下面的更好*/
if(cur is TextBox && string.IsNullOrEmpty(cur))