Navigation Menu

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
var girl_said = 'Girl: 不爱理你'
, programmer_s_prattle = 'Programmer: 我喜欢... 你';
console.log(girl_said);
girl_said = girl_said.replace(/(?:with\_love)?(不|理)/g, function(ignore) {
// said in heart
console.log(programmer_s_prattle);
return ignore = '';
})
@sofish
sofish / ciao.js
Created October 27, 2014 13:54
ciao.js
$.fn.ciao = function() {
console.log('没事爱瞎bb');
return this;
};
// 这样执行
$().ciao().ciao().ciao();
@sofish
sofish / nav.js
Created October 29, 2014 11:37
nav for uedetail
document.querySelector && window.addEventListener('keyup', function (e) {
var url = e.which === 39 ? document.querySelector('a[rel=prev]').href :
e.which === 37 ? document.querySelector('a[rel=next]').href : '';
if (url) window.location = url;
});
@sofish
sofish / error.js
Created November 1, 2014 09:05
Error
{"status":"error","error":{"msg":"\u6b64\u997f\u5355\u5df2\u6295\u8bc9","code":23}}
// 这语法挺正常的
[].indexOf(0); // #1
// 这命名相比上面就醉了
[] instanceof Array; //#2
// 和一面一样的语法,又醉了
typeof []; //#3
// 坑也多
@sofish
sofish / lucky.js
Last active August 29, 2015 14:12
CSS Conf 投资
var range = function(num) {
return Array(num).fill(1).reduce(function(ret, item, i) {
return ret.concat(i + 1);
}, []);
};
var select = function(num) {
var ID = '___list';
var list = window[ID] || localStorage.getItem(ID);
@sofish
sofish / ciaojs-tab.js
Last active August 29, 2015 14:13
教 Ciao 写 JS:Tab
<html>
<style>
.triggers .active {color:#f30;}
.targets div {display:none;}
.targets .active {display:block;}
</style>
<div class="triggers">
<a href="#tab1" class="active">tab1</a>
@sofish
sofish / base.css
Created August 4, 2010 01:05
CSS Reset and base Func for your web project
@charset "utf-8";
/*
@名称: base
@功能: 重设浏览器默认样式
@例子: null
*/
/* 防止用户自定义背景颜色对网页的影响 */
html{
@sofish
sofish / jQuery.ajax.html
Created August 4, 2010 18:48
Request Del.icio.us Item Using jQuery.AJAX
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Request Del.icio.us Item Using jQuery.AJAX</title>
<style type="text/css">
body{width:600px;margin:30px auto;font:13px georgia;}
ul{margin-left:1.3em;;padding:0;line-height:1.8;color:#aaa;}
ul a{color:#07f;}
<script src="http://www.flickr.com/badge_code_v2.gne?count=1&amp;display=latest&amp;size=m&amp;layout=x&amp;source=all_tag&amp;tag=love" type="text/javascript"></script>