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
@sofish
sofish / shift.js
Created August 5, 2013 13:34
顺延执行: 顺延函数:如果上一个动作完成,则当前动作替换上一个 (如自动完成插件的远程获取)
// 顺延函数:如果上一个动作完成,则当前动作替换上一个
function shift(fn, time) {
time = time || 50;
var queue = this._shift_fn, current;
queue ? queue.concat([fn, time]) : (queue = [[fn, time]]);
current = queue.pop();
clearTimeout(this._shift_timeout);
this._shift_timeout = setTimeout(function() {
@sofish
sofish / di.js
Created August 4, 2013 11:25
利用 argument 来做依赖注入,一个简单的例子
var obj = {
hello: function() {
console.log('sofish');
},
world: function(){
console.log('lin');
}
};
var fn = function(hello, ooxx, world){
@sofish
sofish / mu_actions.html
Created July 19, 2013 02:59
multiple actions
<!Doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>multiple actions</title>
</head>
<body>
<h4>open the console and click the buttons:</h4>
@sofish
sofish / font.conf
Created June 24, 2013 03:04
set origin to allow origin domain
SetEnvIf Origin "^(.*\.baixing\.com)$" ORIGIN_SUB_DOMAIN=$1
<FilesMatch "\.(ttf|otf|eot|woff)">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "%{ORIGIN_SUB_DOMAIN}e" env=ORIGIN_SUB_DOMAIN
</IfModule>
</FilesMatch>
@sofish
sofish / prospectors.md
Last active December 15, 2015 22:59
Dribbble Invitation Giveaway

@小猴子kl

喜欢平面,没有特别多的阴影,没有那么拟物化,用新鲜的颜色反映各种变化……

img

@趙旻

控件主打冷灰色,突出科技感

@sofish
sofish / store.php
Created December 21, 2012 09:28
stacktrace store
<?php
$url = new Url();
$page = $url->post('page');
if(!$page) return;
class ErrorTrace extends MongoData {
// MongoData 中没有,区别 http://stackoverflow.com/a/7958954
@sofish
sofish / nocomment.js
Created December 18, 2012 14:48
using js to remove js comment
var nocomment = function(str) {
var div = document.createElement('div')
, inline = /([^\\])\/\/[^\n]*(\n?)/g
, reg = /\/[^\/]*\/g?m?i?[^\*]?/g
, commentLikeReg = /\/\\\/\*[^\/]*\*\//g
, string = new RegExp('(\'[^\']*\')|("[^"]*")','g')
, identifier = 'SOFISH_S_METHOD_TO_REMOVE_JS_COMMENTS_'
, matches = []
, counter = 0
, strReplace;
@sofish
sofish / x.html
Created December 6, 2012 16:17
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>css</title>
<style>
a{display:table-cell;background:green;vertical-align:bottom;padding-left:10px;padding-bottom:5px;height:130px;width:250px;}
a:hover{-moz-transition:all ease-in 1s;-webkit-transition:all ease-in 1s;transition:all ease-in 1s;background:#8fc;font-size:40px;}
</style>
</head>
@sofish
sofish / allowTransparency.html
Created November 5, 2012 10:21
allowTransparency
<!doctype html>
<html>
<body style="position:relative;">
<div style="position:absolute;height:100px;width:800px;background:#ddd;z-index:10;">ddddd</div>
<div style="position:absolute;z-index:9">
<embed allowTransparency="true" src="http://player.youku.com/player.php/Type/Folder/Fid/18518455/Ob/1/sid/XNDcxMDg3ODcy/v.swf" quality="high" width="480" height="400" align="middle" allowScriptAccess="always" allowFullScreen="true" mode="transparent" type="application/x-shockwave-flash"></embed>
</div>
@sofish
sofish / js.js
Created November 1, 2012 08:58
write a code snippet to print itself
// JS:
(function(){console.log('(' + arguments.callee.toString() + ')()')})();
// JS, recursion
~function (){
typeof i !== 'number' && (i = 0);
return (i++ < 3) &&
(fn = '~' + arguments.callee.toString() + '()') &&
(console.log(fn), eval(fn));