Skip to content

Instantly share code, notes, and snippets.

@aisin
aisin / transparent.css
Created May 13, 2016 16:02
页面背景设置为透明网格样式
/*
* 页面背景设置为透明网格样式
*/
body {
background-color: #fff;
background-image:
linear-gradient(45deg, #d6d6d6 25%, transparent 25%, transparent 75%, #d6d6d6 75%, #d6d6d6),
linear-gradient(45deg, #d6d6d6 25%, transparent 25%, transparent 75%, #d6d6d6 75%, #d6d6d6);
background-size: 16px 16px;
@aisin
aisin / classof.js
Last active May 19, 2016 02:02
返回任意对象的类
// 该函数可以返回传递给它的任意对象的类
function classof(o) {
if( o === "null" ) return "Null";
if( o === "undefined") return "Undefined";
Object.prototype.toString.call(o).slice(8,-1);
}
//或者,将 Object.prototype 替换为 {} 也是可以的
@aisin
aisin / btype.js
Last active December 16, 2015 01:55
Check Browser Type
var chromeType = navigator.userAgent.toLowerCase();
var bType = '';
function getBrowserType() {
if ("ActiveXObject" in window) {
bType = 'ie';
} else if (chromeType.indexOf('firefox') > -1) {
bType = "firefox";
} else if (chromeType.indexOf('opera') > -1 || chromeType.indexOf('opr') > -1) {
bType = "opera";
} else if (chromeType.indexOf('safari') > -1 && chromeType.indexOf('chrome') == -1) {
@aisin
aisin / a.js
Created July 15, 2015 10:45
点击页面随机飞出积分特效
jQuery(document).ready(function($) {
$("html,body").click(function(e){
var n=Math.round(Math.random()*100);//随机数
var $i=$("<b/>").text("+"+n);//添加到页面的元素
var x=e.pageX, y=e.pageY;//鼠标点击的位置
$i.css({
"z-index":99999,
@aisin
aisin / wechat.js
Created June 4, 2015 09:31
判断手机端浏览器是否为微信内置浏览器
window.onload = function(){
var ua = window.navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i) == 'micromessenger'){
return true;
}else{
return false;
}
}
@aisin
aisin / earth.js
Created February 10, 2015 08:20
The Earth
eval(z='p="<"+"pre>"/* ,.oq#+ ,._, */;for(y in n="zw24l6k\
4e3t4jnt4qj24xh2 x/* =<,m#F^ A W###q. */42kty24wrt413n243n\
9h243pdxt41csb yz/* #K q##H######Am */43iyb6k43pk7243nm\
r24".split(4)){/* dP cpq#q##########b, */for(a in t=pars\
eInt(n[y],36)+/* p##@###YG=[#######y */(e=x=r=[]))for\
(r=!r,i=0;t[a/* d#qg `*PWo##q#######D */]>i;i+=.05)wi\
th(Math)x-= /* aem1k.com Q###KWR#### W[ */.05,0>cos(o=\
new Date/1e3/* .Q#########Md#.###OP A@ , */+x/PI)&&(e[~\
~(32*sin(o)*/* , (W#####Xx######.P^ T % */sin(.5+y/7))\
+60] =-~ r);/* #y `^TqW####P###BP */for(x=0;122>\
@aisin
aisin / note.php
Created October 31, 2014 01:26
PHP 字符串转数组
<?php
//explode用法:
$var = '10, 24, 29, 32, 56';
$ary = explode(",", $var);
print_r ( $ary ); // Array ( [0] => 10 [1] => 24 [2] => 29 [3] => 32 [4] => 56 )
@aisin
aisin / functions.php
Created September 17, 2014 05:30
WordPress 获取文章内容里的首张图片和第一段,如果无图只显示第一段。
<?php
function get_con(){
global $post;
$content = get_the_content();
//获取内容的第一段
$str = wpautop( $content );
$str = substr( $str, 0, strpos( $str, '</p>' ) + 4 );
@aisin
aisin / header.php
Created August 20, 2014 03:46
WordPress 判断是否首页
<?php
/*
*
* 通常使用 is_home() 函数即可判断首页,但是有时候在首页不起作用
*
*/
if( is_home() || is_front_page() ) {
@aisin
aisin / gist:719c296c8ab8dfde1f29
Created July 16, 2014 11:44
jQuery判断指定元素是否存在和删除数组中指定元素
/***********************************
*
* 判断指定元素是否存在
*
* *********************************/
var arr = ['a','b','c','d','e','f']
var str = 'b';
console.log( $.inArray(str , arr) );
//结果: