This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| // 打开chrome扩展选项tab | |
| var option_url = chrome.extension.getURL('options/index.html'); | |
| chrome.tabs.getAllInWindow(null,function(tabs){ | |
| var option_tab = tabs.filter(function(t) { return t.url === option_url }); | |
| if(option_tab.length){ | |
| // 已经打开,直接激活 | |
| chrome.tabs.update(option_tab[0].id,{selected:true}); | |
| }else{ | |
| chrome.tabs.create({url:option_url,selected:true}) | |
| } |
| <html> | |
| <head> | |
| <title>WebSocket Demo</title> | |
| </head> | |
| <style type="text/css"> | |
| textarea{width:400px;height:150px;display:block;overflow-y:scroll;} | |
| #output{width:600px;height:400px;background:whiteSmoke;padding:1em .5em;color:#000;border:none;} | |
| button{padding:.2em 1em;} | |
| </style> | |
| <link href="layout.css" rel="stylesheet" type="text/css" /> |
| var scripts = document.getElementsByTagName('script'); | |
| console.log('a.js',' >>> ',scripts[scripts.length -1].src); | |
| console.log(__filename); |
| <html> | |
| <head> | |
| <title>$.fn.emotion</title> | |
| <style type="text/css"> | |
| /* comment (笑) */ | |
| </style> | |
| </head> | |
| <body> |
| var $anim = $(document[$.browser.webkit ? 'body' : 'documentElement']); | |
| $btn.click(function() { | |
| $anim.animate({scrollTop: 0}); | |
| return false; | |
| }); |
| <html> | |
| <head> | |
| <title></title> | |
| </head> | |
| <body> | |
| <script> | |
| /* | |
| jQuery.proxy和Function.prototype.bind作用一模一样。 |
| $.validator.addMethod("phrange", function (value, element) { | |
| if( $(element).attr('placeholder') === value ){ | |
| return true; | |
| } | |
| return $.validator.methods.range.apply(this,arguments); | |
| }, ""); | |
| $.validator.addMethod("qq", function (value, element) { | |
| if( $(element).attr('placeholder') === value ){ | |
| return true; |
| var getMaxZ = function(el) { | |
| return Math.max.apply(null, $(el||document.body).children().map(function(){ return $(this).css('zIndex')>>>0; }).get()) | |
| }; |
| // ==UserScript== | |
| // @name MantisEasyAssign | |
| // @author sean && ambar | |
| // @namespace https://gist.github.com/1141552 | |
| // @version 1.3.0 | |
| // @description 友好的select,更容易把Bug扔给别人,哈哈 | |
| // @include http://mantis.dos123.com/view.php?id=* | |
| // @include http://192.168.202.98/view.php?id=* | |
| // @include http://mantis.dos123.com/view_all_bug_page.php* | |
| // @include http://192.168.202.98/view_all_bug_page.php* |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer