Skip to content

Instantly share code, notes, and snippets.

View sofish's full-sized avatar
🚀
still hiring creatives

小鱼 sofish

🚀
still hiring creatives
View GitHub Profile
select: function () {
var val = this.$menu.find('.active').attr('data-value')
this.$element.val(val)
this.$element.change();
// 考拉:添加这行
this.$element.trigger('selected');
return this.hide()
}
@sofish
sofish / increase.php
Created March 14, 2012 03:06
连字符串也可以++/--
<?php
function a() {
static $b = 'abc'; // 中文就不行了,写“你妹”会打印出来2个"你妹"
echo $b . PHP_EOL;
$b++;
}
a();
a();
@sofish
sofish / Goods.md
Created March 5, 2012 14:13
卖一些东西,只为和你聊聊
@sofish
sofish / thumb.php
Created March 4, 2012 16:18
appinn
<div class="thumbnail">
<a href="<?php the_permalink(); ?>">
<?php
$soContent = $post->post_content;
$soImages = '~<img [^\>]*\ />~';
preg_match_all($soImages, $soContent, $thePics );
$allPics = count($thePics[0]);
if($allPics > 0 ){
$img_url = $thePics[0][0];
preg_match('~img3~', $img_url, $isImg3);
@sofish
sofish / img.onload.js
Created February 7, 2012 10:05
image onload
var img = new Image();
img.onload = function(){
alert('loaded, and u\'re a true image');
}
// 这个将不会 alert 出来
// img.src="http://aliceui.com";
// 因为是真正的图片,onload 的时候会 alert 出来
@sofish
sofish / hash.js
Created January 4, 2012 08:11
理解的 hash
var obj = {
1:'person1',
2:'person2',
5:'person3',
9:'person4',
12:'person5',
9:'person6'
},
tmpArray = [];
@sofish
sofish / ie6-muti-class.html
Created January 3, 2012 09:05
IE6 多重 class 失效
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>ie6 muti-class</title>
<style>
.momoko2k.hello{color:#f30;}
.momoko2k{color:#ddd}
.hello{color:#080;}
</style>
@sofish
sofish / no-new.js
Created January 2, 2012 04:44
在 js 实例化的时候去 new
function Call(name){
if(!(this instanceof Call)) return new Call(name);
this.name = name;
this.hello = function(){
alert('hello, ' + this.name);
}
}
var hi = Call('sofish'); // 有没有 new 都无所谓
@sofish
sofish / html5.js
Created December 29, 2011 02:55
html5 JS
<!--[if lt IE 9]>
<script type="text/javascript">
// html5shiv MIT @rem remysharp.com/html5-enabling-script
// iepp v1.6.2 MIT @jon_neal iecss.com/print-protector
/*@cc_on(function(a,b){function r(a){var b=-1;while(++b<f)a.createElement(e[b])}if(!(!window.attachEvent||!b.createStyleSheet||!function(){var a=document.createElement("div");a.innerHTML="<elem></elem>";return a.childNodes.length!==1}())){a.iepp=a.iepp||{};var c=a.iepp,d=c.html5elements||"abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",e=d.split("|"),f=e.length,g=new RegExp("(^|\\s)("+d+")","gi"),h=new RegExp("<(/*)("+d+")","gi"),i=/^\s*[\{\}]\s*$/,j=new RegExp("(^|[^\\n]*?\\s)("+d+")([^\\n]*)({[\\n\\w\\W]*?})","gi"),k=b.createDocumentFragment(),l=b.documentElement,m=l.firstChild,n=b.createElement("body"),o=b.createElement("style"),p=/print|all/,q;c.getCSS=function(a,b){if(a+""===undefined)return"";var d=-1,e=a.length,f,g=[];while(++d<e){f=a[d];if(f.di
@sofish
sofish / gist:1518670
Created December 25, 2011 03:08
ant 文件目录
.
├── 1px-round-corner-min.css
├── custom-file-min.css
├── drop-shadow-min.css
├── equal-height-layout-min.css
├── float-center-min.css
├── force-wrap-min.css
├── ime-disabled-min.css
├── position-fixed-min.css
├── remove-outline-min.css