├── node ├── data.txt ├── speak │ ├── views │ │ ├── error.ejs │ │ └── index.ejs │ ├── public │ │ └── stylesheets │ │ │ └── style.css │ ├── routes │ │ ├── users.js │ │ └── index.js │ ├── package.json │ ├── bin │ │ └── www │ └── app.js ├── mocha │ ├── coverage │ │ ├── lcov-report │ │ │ ├── sort-arrow-sprite.png │ │ │ └── prettify.css │ │ ├── lcov.info │ │ └── coverage.json │ ├── package.json │ ├── index.js │ └── test │ │ └── index.test.js ├── file-io.js ├── internet-io-2.js ├── hello-world.js ├── colors.coffee ├── 301.js ├── callback.js ├── colors.js └── internet-io.js ├── simple-blog ├── error.log ├── views │ ├── footer.ejs │ ├── error.ejs │ ├── tags.ejs │ ├── login.ejs │ ├── 404.ejs │ ├── paging.ejs │ ├── links.ejs │ ├── reg.ejs │ ├── upload.ejs │ ├── post.ejs │ ├── archive.ejs │ ├── tag.ejs │ ├── search.ejs │ ├── article.ejs │ ├── user.ejs │ ├── edit.ejs │ ├── index.ejs │ ├── comment.ejs │ └── header.ejs ├── js │ └── controller │ │ └── test.js ├── public │ ├── images │ │ ├── 128x128px.jpg │ │ └── 203_25530_9ab91d8c973735c.jpg │ └── stylesheets │ │ └── style.css ├── settings.js ├── coffee │ └── controller │ │ └── test.coffee ├── doc │ └── quote.md ├── routes │ └── users.js ├── models │ ├── db.js │ ├── comment.js │ └── user.js ├── CHANGELOG ├── package.json ├── bin │ └── www └── Gruntfile.js ├── tumblrlikeg ├── js │ └── app.js ├── .bowerrc ├── robots.txt ├── bower.json ├── package.json ├── humans.txt ├── Gruntfile.js ├── README.md └── scss │ └── app.scss ├── react ├── react-tutorial │ ├── requirements.txt │ ├── .gitignore │ ├── .editorconfig │ ├── app.json │ ├── LICENSE │ ├── package.json │ ├── comments.json │ ├── react-scotty.cabal │ ├── public │ │ └── css │ │ │ └── base.css │ ├── README.md │ ├── server.lua │ ├── server.py │ ├── server.rb │ ├── server.js │ ├── server.php │ └── Server.hs ├── react-0.13.3 │ └── examples │ │ ├── jquery-bootstrap │ │ ├── css │ │ │ └── example.css │ │ └── index.html │ │ ├── server-rendering │ │ ├── jsapp │ │ │ ├── src │ │ │ │ └── App.js │ │ │ └── package.json │ │ ├── reactserver │ │ │ ├── package.json │ │ │ └── server.js │ │ └── webapp │ │ │ └── index.php │ │ ├── basic-commonjs │ │ ├── README.md │ │ ├── package.json │ │ ├── index.js │ │ └── index.html │ │ ├── jquery-mobile │ │ ├── README.md │ │ └── index.html │ │ ├── README.md │ │ ├── basic-jsx-external │ │ ├── example.js │ │ └── index.html │ │ ├── basic-jsx-precompile │ │ ├── example.js │ │ ├── build │ │ │ └── example.js │ │ └── index.html │ │ ├── shared │ │ ├── thirdparty │ │ │ └── console-polyfill.js │ │ └── css │ │ │ └── base.css │ │ ├── transitions │ │ ├── transition.css │ │ └── index.html │ │ ├── quadratic │ │ ├── index.html │ │ └── example.js │ │ ├── basic-jsx-harmony │ │ └── index.html │ │ ├── basic-jsx │ │ └── index.html │ │ └── basic │ │ └── index.html ├── react-trader │ ├── www │ │ ├── js │ │ │ ├── feed-socketio.js │ │ │ └── feed-mock.js │ │ ├── index.html │ │ └── css │ │ │ └── styles.css │ ├── package.json │ ├── server.js │ └── feed.js ├── index.html ├── test2.html ├── test3.html ├── README.md ├── js │ └── app.js └── test.html ├── .gitignore ├── gettext ├── a.out ├── jian_gettext ├── jian_gettext.mo ├── locale │ └── zh_CN │ │ └── LC_MESSAGES │ │ └── jian_gettext.mo ├── test.c └── jian_gettext.po ├── ant-test ├── tiles │ ├── hexo_settings.html │ ├── list.html │ └── new.html ├── js │ ├── index.js │ ├── app.js │ └── my.js ├── css │ └── style.css └── index.html ├── jQuery ├── demo2.js ├── style.css ├── demo.js ├── demo3.js ├── ' ├── demo2.html ├── index.html └── demo3.html ├── xcf ├── resume-1.xcf └── baidu-bg1.xcf ├── learn-html5 ├── index.jpg ├── index.html ├── 2.html ├── 4.html ├── 5.html └── 3.html ├── js ├── assert.js └── setTimeout.js ├── css-layout ├── css3 │ ├── src │ │ ├── img │ │ │ ├── wg-1.jpg │ │ │ ├── 128x128px.jpg │ │ │ └── ishell.me.jpg │ │ └── otf │ │ │ └── Amaranth-BoldItalic.otf │ ├── base.html │ ├── 5-5.html │ ├── background-color.html │ ├── text-shadow.html │ ├── background-size.html │ ├── linear-gradient.html │ ├── font-face.html │ ├── circle.html │ ├── shadow.html │ ├── multiple_backgrounds.html │ ├── background-origin.html │ ├── background-clip.html │ └── learnlayout.com │ │ └── index.html ├── top-bar │ ├── imgs │ │ └── hexo.png │ ├── js │ │ └── script.js │ ├── css │ │ └── style.css_bak │ └── index.html ├── waterfall-flow │ ├── images │ │ ├── 1.png │ │ ├── 10.png │ │ ├── 11.png │ │ ├── 12.png │ │ ├── 13.png │ │ ├── 14.png │ │ ├── 15.jpg │ │ ├── 16.png │ │ ├── 17.png │ │ ├── 18.png │ │ ├── 19.png │ │ ├── 2.png │ │ ├── 20.png │ │ ├── 21.jpg │ │ ├── 22.png │ │ ├── 23.png │ │ ├── 24.png │ │ ├── 25.png │ │ ├── 26.png │ │ ├── 3.png │ │ ├── 4.png │ │ ├── 5.jpg │ │ ├── 6.png │ │ ├── 7.png │ │ ├── 8.png │ │ └── 9.png │ ├── colume-width.css │ └── index.html ├── demo.html ├── float │ ├── float-2.html │ ├── float.html │ ├── float-3.html │ └── float-4.html └── position │ └── position.html ├── cyclejs ├── README.md ├── 1.js ├── 1.html ├── 2.1.html ├── 2.html ├── 3.html ├── 4.html ├── 2.js ├── 2.1.js ├── 3.js └── 4.js ├── c ├── DefineMax.c └── BubbleSort.c ├── msgfmt └── gimp-plugin-bimp │ └── bimp-locale │ └── zh │ └── LC_MESSAGES │ └── gimp20-plugin-bimp.mo ├── async ├── package.json └── control-flow.js ├── py ├── md5.py ├── logbook-demo │ ├── file_handler.py │ ├── stdout_handler2.py │ ├── stdout_handler.py │ ├── file_stdout_handler.py │ ├── stdout_handler3.py │ ├── processors.py │ ├── 163_mail_handler.py │ └── qq_mail_handler.py ├── sort │ ├── quick_sort.py │ ├── insertion_sort.py │ ├── selection_sort.py │ ├── merge_sort.py │ └── bubble_sort.py ├── dragspeed_compare │ ├── use-base.py │ ├── use-gevent.py │ ├── urls.txt │ ├── use-multiprocessing.py │ └── use-asyncio.py ├── singleton │ └── Count.py ├── sqlite-demo │ ├── shipping_data.json │ └── sqlite3_demo.py ├── server-side-y2b-connect-speed-screenshot.py ├── pymongo-1 │ └── test.py ├── bs4-demo.py ├── v2ex_daily_mission.py ├── property-demo.py ├── v2ex.py ├── v2ex_daily_mission_gai.py └── pythonic.py ├── RxJS ├── 2.js ├── 1.html ├── 1.js └── 2.html ├── sh ├── simple-runing.sh └── JPG2jpg.sh ├── README.md ├── angularjs └── hello.html └── html └── index.html /node/data.txt: -------------------------------------------------------------------------------- 1 | haha 2 | -------------------------------------------------------------------------------- /simple-blog/error.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tumblrlikeg/js/app.js: -------------------------------------------------------------------------------- 1 | $(document).foundation(); -------------------------------------------------------------------------------- /react/react-tutorial/requirements.txt: -------------------------------------------------------------------------------- 1 | Flask==0.10.1 2 | -------------------------------------------------------------------------------- /simple-blog/views/footer.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /react/react-tutorial/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | node_modules 3 | .DS_Store 4 | -------------------------------------------------------------------------------- /tumblrlikeg/.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "bower_components" 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | */node_modules/ 2 | */*/node_modules/ 3 | */*/*/node_modules/ 4 | -------------------------------------------------------------------------------- /gettext/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/gettext/a.out -------------------------------------------------------------------------------- /ant-test/tiles/hexo_settings.html: -------------------------------------------------------------------------------- 1 |

Hexo设置

2 | 3 |
4 | -------------------------------------------------------------------------------- /jQuery/demo2.js: -------------------------------------------------------------------------------- 1 | $(function () { 2 | $('#box').css('color','red'); 3 | }); 4 | 5 | -------------------------------------------------------------------------------- /xcf/resume-1.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/xcf/resume-1.xcf -------------------------------------------------------------------------------- /xcf/baidu-bg1.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/xcf/baidu-bg1.xcf -------------------------------------------------------------------------------- /gettext/jian_gettext: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/gettext/jian_gettext -------------------------------------------------------------------------------- /jQuery/style.css: -------------------------------------------------------------------------------- 1 | #box { 2 | color:red; 3 | } 4 | 5 | #haha > p { 6 | color:green; 7 | } 8 | -------------------------------------------------------------------------------- /learn-html5/index.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/learn-html5/index.jpg -------------------------------------------------------------------------------- /react/react-0.13.3/examples/jquery-bootstrap/css/example.css: -------------------------------------------------------------------------------- 1 | .example { 2 | margin: 20px; 3 | } -------------------------------------------------------------------------------- /gettext/jian_gettext.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/gettext/jian_gettext.mo -------------------------------------------------------------------------------- /ant-test/tiles/list.html: -------------------------------------------------------------------------------- 1 |

文章列表

2 | 3 |
获取列表
4 |
5 | -------------------------------------------------------------------------------- /jQuery/demo.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | $('input').click(function() { 3 | alert("just for fun"); 4 | }); 5 | }); 6 | -------------------------------------------------------------------------------- /js/assert.js: -------------------------------------------------------------------------------- 1 | var a = "haha"; 2 | console.assert(a == "haha"); 3 | 4 | var b = 111; 5 | console.assert(b == 222); 6 | -------------------------------------------------------------------------------- /css-layout/css3/src/img/wg-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/css3/src/img/wg-1.jpg -------------------------------------------------------------------------------- /css-layout/top-bar/imgs/hexo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/top-bar/imgs/hexo.png -------------------------------------------------------------------------------- /node/speak/views/error.ejs: -------------------------------------------------------------------------------- 1 |

<%= message %>

2 |

<%= error.status %>

3 |
<%= error.stack %>
4 | -------------------------------------------------------------------------------- /simple-blog/js/controller/test.js: -------------------------------------------------------------------------------- 1 | exports.hello = function(req, res) { 2 | return res.send('hello world'); 3 | }; 4 | -------------------------------------------------------------------------------- /simple-blog/views/error.ejs: -------------------------------------------------------------------------------- 1 |

<%= message %>

2 |

<%= error.status %>

3 |
<%= error.stack %>
4 | -------------------------------------------------------------------------------- /css-layout/css3/src/img/128x128px.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/css3/src/img/128x128px.jpg -------------------------------------------------------------------------------- /css-layout/css3/src/img/ishell.me.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/css3/src/img/ishell.me.jpg -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/1.png -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/10.png -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/11.png -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/12.png -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/13.png -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/14.png -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/15.jpg -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/16.png -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/17.png -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/18.png -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/19.png -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/2.png -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/20.png -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/21.jpg -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/22.png -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/23.png -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/24.png -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/25.png -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/26.png -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/3.png -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/4.png -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/5.jpg -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/6.png -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/7.png -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/8.png -------------------------------------------------------------------------------- /css-layout/waterfall-flow/images/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/waterfall-flow/images/9.png -------------------------------------------------------------------------------- /simple-blog/public/images/128x128px.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/simple-blog/public/images/128x128px.jpg -------------------------------------------------------------------------------- /simple-blog/settings.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | cookieSecret: 'myblog', 3 | db: 'blog', 4 | host: 'localhost', 5 | port: 27017 6 | }; 7 | -------------------------------------------------------------------------------- /tumblrlikeg/robots.txt: -------------------------------------------------------------------------------- 1 | # www.robotstxt.org/ 2 | # www.google.com/support/webmasters/bin/answer.py?hl=en&answer=156449 3 | 4 | User-agent: * 5 | -------------------------------------------------------------------------------- /css-layout/css3/src/otf/Amaranth-BoldItalic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/css-layout/css3/src/otf/Amaranth-BoldItalic.otf -------------------------------------------------------------------------------- /cyclejs/README.md: -------------------------------------------------------------------------------- 1 | # Free视频学习Cycle.js的网站 2 | 3 | [egghead.io](https://egghead.io/lessons/rxjs-the-cycle-js-principle-separating-logic-from-effects) 4 | -------------------------------------------------------------------------------- /gettext/locale/zh_CN/LC_MESSAGES/jian_gettext.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/gettext/locale/zh_CN/LC_MESSAGES/jian_gettext.mo -------------------------------------------------------------------------------- /simple-blog/coffee/controller/test.coffee: -------------------------------------------------------------------------------- 1 | exports.hello = (req, res) -> 2 | #return res.jsonp {'hello':'world'} 3 | return res.send 'hello world' 4 | -------------------------------------------------------------------------------- /c/DefineMax.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAX(a, b) ((a)>(b)?(a):(b)) 3 | 4 | int main(void) { 5 | printf("%d\n", MAX(5, 6)); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /tumblrlikeg/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "foundation-libsass-template", 3 | "dependencies": { 4 | "foundation": "zurb/bower-foundation" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /node/mocha/coverage/lcov-report/sort-arrow-sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/node/mocha/coverage/lcov-report/sort-arrow-sprite.png -------------------------------------------------------------------------------- /simple-blog/public/images/203_25530_9ab91d8c973735c.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/simple-blog/public/images/203_25530_9ab91d8c973735c.jpg -------------------------------------------------------------------------------- /jQuery/demo3.js: -------------------------------------------------------------------------------- 1 | $(function () { 2 | $('#haha').on('mouseover mouseout', {name: 'lxd', age: '23'}, function (e) { 3 | alert('hello world' + e.data.name); 4 | }); 5 | }); 6 | -------------------------------------------------------------------------------- /node/speak/public/stylesheets/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding: 50px; 3 | font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; 4 | } 5 | 6 | a { 7 | color: #00B7FF; 8 | } 9 | -------------------------------------------------------------------------------- /simple-blog/doc/quote.md: -------------------------------------------------------------------------------- 1 | [《nswbmw/N-blog》](https://github.com/nswbmw/N-blog/wiki/_pages) 2 | [《Fedora安装mongodb》](http://zebozhuang.blog.163.com/blog/static/171479804201241211150839/) 3 | 4 | -------------------------------------------------------------------------------- /msgfmt/gimp-plugin-bimp/bimp-locale/zh/LC_MESSAGES/gimp20-plugin-bimp.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sincerefly/Learning/HEAD/msgfmt/gimp-plugin-bimp/bimp-locale/zh/LC_MESSAGES/gimp20-plugin-bimp.mo -------------------------------------------------------------------------------- /node/file-io.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | 3 | fs.readFile('data.txt', 'utf-8', function (err, data) { 4 | if (err) throw err; 5 | console.log('file read: '); 6 | console.log(data); 7 | }); 8 | -------------------------------------------------------------------------------- /simple-blog/views/tags.ejs: -------------------------------------------------------------------------------- 1 | <%- include header %> 2 | <% posts.forEach(function (tag, index) { %> 3 | <%= tag %> 4 | <% }) %> 5 | <%- include footer %> 6 | -------------------------------------------------------------------------------- /js/setTimeout.js: -------------------------------------------------------------------------------- 1 | var start = new Date; 2 | setTimeout(function () { 3 | var end = new Date; 4 | console.log('The time :', end - start, 'ms'); 5 | }, 500); 6 | while (new Date - start < 1000) {}; 7 | 8 | -------------------------------------------------------------------------------- /css-layout/css3/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /async/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "async-test", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node ./index.js" 7 | }, 8 | "dependencies": { 9 | "async": "~1.5.0" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cyclejs/1.js: -------------------------------------------------------------------------------- 1 | // Logic 2 | Rx.Observable.timer(0, 1000) 3 | .map( i => `seconds elapsed ${i}`) 4 | // Effects 5 | .subscribe(text => { 6 | const container = document.querySelector('#app'); 7 | container.textContent = text; 8 | }); 9 | -------------------------------------------------------------------------------- /node/internet-io-2.js: -------------------------------------------------------------------------------- 1 | var http = require('http'); 2 | 3 | http.get({host: 'www.baidu.com'}, function(res) { 4 | console.log('Get response: ' + res.statusCode); 5 | }).on('error', function(e) { 6 | console.log('Got error: ' + e.message); 7 | }); 8 | -------------------------------------------------------------------------------- /jQuery/': -------------------------------------------------------------------------------- 1 | /* 2 | $(function () { 3 | $("#box").css("color", "blue"); 4 | }); 5 | */ 6 | 7 | $(function () { 8 | //$("div").eq(1).css("color", "green"); 9 | $(".pox").eq(1).css("color", "blue"); 10 | alert($("#box").size()); 11 | }); 12 | -------------------------------------------------------------------------------- /simple-blog/views/login.ejs: -------------------------------------------------------------------------------- 1 | <%- include header %> 2 |
3 | 用户名:
4 | 密码:
5 | 6 |
7 | <%- include footer %> 8 | -------------------------------------------------------------------------------- /node/speak/routes/users.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var router = express.Router(); 3 | 4 | /* GET users listing. */ 5 | router.get('/', function(req, res, next) { 6 | res.send('respond with a resource'); 7 | }); 8 | 9 | module.exports = router; 10 | -------------------------------------------------------------------------------- /simple-blog/routes/users.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var router = express.Router(); 3 | 4 | /* GET users listing. */ 5 | router.get('/', function(req, res, next) { 6 | res.send('respond with a resource'); 7 | }); 8 | 9 | module.exports = router; 10 | -------------------------------------------------------------------------------- /node/hello-world.js: -------------------------------------------------------------------------------- 1 | var http = require('http'); 2 | 3 | http.createServer(function (req, res) { 4 | res.writeHead(200, {'Content-Type': 'text/plain'}); 5 | res.end('Hello World!'); 6 | }).listen(3000, '127.0.0.1'); 7 | console.log("Server runing at http://127.0.0.1:3000/"); 8 | -------------------------------------------------------------------------------- /css-layout/demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | float test 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /simple-blog/views/404.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Blog 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tumblrlikeg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "foundation-libsass-template", 3 | "version": "0.0.1", 4 | "devDependencies": { 5 | "node-sass": "~1.2.3", 6 | "grunt": "~0.4.5", 7 | "grunt-contrib-watch": "~0.6.1", 8 | "grunt-sass": "~0.17.0" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /node/colors.coffee: -------------------------------------------------------------------------------- 1 | colors = require 'colors' 2 | 3 | console.log 'colors'.rainbow 4 | 5 | colors.setTheme 6 | info: 'green' 7 | warn: 'yellow' 8 | error: 'red' 9 | 10 | console.log 'Error'.error 11 | console.log 'Warning'.warn 12 | console.log 'Info'.info 13 | 14 | 15 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/server-rendering/jsapp/src/App.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var React = require('react'); 4 | 5 | var App = React.createClass({ 6 | render: function() { 7 | return

Hello {this.props.name}!

; 8 | } 9 | }); 10 | 11 | module.exports = App; 12 | -------------------------------------------------------------------------------- /tumblrlikeg/humans.txt: -------------------------------------------------------------------------------- 1 | /* Foundation was made by ZURB, an interaction design and design strategy firm in Campbell, CA */ 2 | /* zurb.com */ 3 | /* humanstxt.org */ 4 | 5 | /* SITE */ 6 | Standards: HTML5, CSS3 7 | Components: jQuery, Orbit, Reveal 8 | Software: Coda, Textmate, Git 9 | -------------------------------------------------------------------------------- /simple-blog/models/db.js: -------------------------------------------------------------------------------- 1 | var settings = require('../settings'), 2 | Db = require('mongodb').Db, 3 | Connection = require('mongodb').Connection, 4 | Server = require('mongodb').Server; 5 | 6 | module.exports = new Db(settings.db, new Server(settings.host, settings.port), {safe: true}); 7 | -------------------------------------------------------------------------------- /node/301.js: -------------------------------------------------------------------------------- 1 | var http = require('http'); 2 | 3 | http.createServer(function (req, res) { 4 | res.writeHead(301, { 5 | 'Location': 'http://www.baidu.com' 6 | }); 7 | res.end('Hello World!'); 8 | }).listen(3000, '127.0.0.1'); 9 | console.log("Server runing at http://127.0.0.1:3000/"); 10 | -------------------------------------------------------------------------------- /node/speak/views/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= title %> 5 | 6 | 7 | 8 |

<%= title %>

9 |

Welcome to <%= title %>

10 | 11 | 12 | -------------------------------------------------------------------------------- /jQuery/demo2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | test jquery 5 | 6 | 7 | 8 | 9 |
a test
10 | 11 | 12 | -------------------------------------------------------------------------------- /py/md5.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | """ 3 | Use: 4 | input ./md5.py password 5 | ouput 5f4dcc3b5aa765d61d8327deb882cf99 6 | 7 | DateTime: 2015-03-06 23:08 8 | """ 9 | import sys 10 | import hashlib 11 | 12 | src = sys.argv[1] 13 | m2 = hashlib.md5() 14 | m2.update(src) 15 | print m2.hexdigest() 16 | -------------------------------------------------------------------------------- /RxJS/2.js: -------------------------------------------------------------------------------- 1 | console.clear(); 2 | 3 | var source = [1, 2, 3, 4, 5]; 4 | 5 | //var source = Rx.Observable.fromArray([0, 1, 2, 3, 4, 5]); 6 | 7 | //var source = Rx.Observable.interval(500).take(10); 8 | 9 | source.filter(x => x % 2 === 1) 10 | .map(x => x + '!') 11 | .forEach(x => console.log(x)); 12 | 13 | -------------------------------------------------------------------------------- /simple-blog/CHANGELOG: -------------------------------------------------------------------------------- 1 | [2015-03-03 21:48] 留言和分页的支持 2 | [2015-03-02 20:41] 用户界面和文章界面 && 编辑和删除 3 | [2015-03-01 11:18] 增加文件上传功能 4 | [2015-02-28 09:32] 完成Markdown支持 5 | [2015-02-27 22:27] 根据 [N-blog](https://github.com/nswbmw/N-blog/wiki/_pages)第一章完成博客的注册登陆发布文章等基本功能框架 6 | [2015-02-21 14:33] 创建simple-blog的Projects子目录,托管于Github 7 | -------------------------------------------------------------------------------- /simple-blog/views/paging.ejs: -------------------------------------------------------------------------------- 1 |
2 |
3 | <% if (!isFirstPage) { %> 4 | 上一页 5 | <% } %> 6 | 7 | <% if (!isLastPage) { %> 8 | 下一页 9 | <% } %> 10 |
11 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/basic-commonjs/README.md: -------------------------------------------------------------------------------- 1 | # Basic example of using React with Browserify 2 | 3 | Run `npm install` in the directory to install React from npm. Then run: 4 | 5 | ./node_modules/.bin/browserify --debug --transform reactify ./index.js > ./bundle.js 6 | 7 | to produce `bundle.js` with example code and React. 8 | -------------------------------------------------------------------------------- /node/callback.js: -------------------------------------------------------------------------------- 1 | function haveBreakfast(food, drink, callback) { 2 | console.log('Having backhast of ' + food + ', ' + drink); 3 | if(callback && typeof(callback) === "function") { 4 | callback(); 5 | } 6 | } 7 | 8 | haveBreakfast('toast', 'coffee', function() { 9 | console.log('Finish breakfast. Time to go to work'); 10 | }); 11 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/jquery-mobile/README.md: -------------------------------------------------------------------------------- 1 | jQuery Mobile React Example 2 | =========================== 3 | 4 | This example demonstrates how jQuery Mobile applications can be built with React. 5 | 6 | The source code is based on jQuery Mobile's [pages-multi-page example](https://github.com/jquery/jquery-mobile/tree/master/demos/pages-multi-page). 7 | -------------------------------------------------------------------------------- /simple-blog/views/links.ejs: -------------------------------------------------------------------------------- 1 | <%- include header %> 2 | 6 | <%- include footer %> 7 | -------------------------------------------------------------------------------- /RxJS/1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | JS Bin 7 | 8 | 9 | 10 | 11 | Find result in console 12 | 13 | 14 | -------------------------------------------------------------------------------- /RxJS/1.js: -------------------------------------------------------------------------------- 1 | console.clear(); 2 | 3 | var source = Rx.Observable.create(function (observer) { 4 | observer.onNext(42); 5 | observer.onCompleted(); 6 | }); 7 | 8 | var sub = source.subscribe(function(x) { 9 | console.log('next ' + x); 10 | }, function (err) { 11 | console.error(err); 12 | }, function () { 13 | console.info('done'); 14 | }); 15 | -------------------------------------------------------------------------------- /RxJS/2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | JS Bin 7 | 8 | 9 | 10 | 11 | Find result in console 12 | 13 | 14 | -------------------------------------------------------------------------------- /cyclejs/1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | JS Bin 9 | 10 | 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /cyclejs/2.1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | JS Bin 9 | 10 | 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /cyclejs/2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | JS Bin 9 | 10 | 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /cyclejs/3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | JS Bin 9 | 10 | 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /cyclejs/4.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | JS Bin 9 | 10 | 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /jQuery/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | test jquery 5 | 6 | 7 | 8 | 9 | 10 | 11 |
a test
12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /react/react-tutorial/.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_size = 4 8 | indent_style = space 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | 12 | [*.{js,rb,css,html}] 13 | indent_size = 2 14 | 15 | [*.go] 16 | indent_size = 8 17 | indent_style = tab 18 | -------------------------------------------------------------------------------- /py/logbook-demo/file_handler.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from logbook import Logger, FileHandler 4 | import logbook 5 | import sys 6 | 7 | handler = FileHandler('app.log') 8 | handler.push_application() 9 | log = Logger('test') 10 | 11 | def main(): 12 | log.info('something logging') 13 | 14 | if __name__ == '__main__': 15 | main() 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /py/logbook-demo/stdout_handler2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from logbook import Logger, StreamHandler 4 | import logbook 5 | import sys 6 | 7 | handler = StreamHandler(sys.stdout) 8 | handler.push_application() 9 | log = Logger('test') 10 | 11 | def main(): 12 | log.info('something logging') 13 | 14 | if __name__ == '__main__': 15 | main() 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /sh/simple-runing.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | BASEDIR='/server' 4 | 5 | while true; do 6 | 7 | PRO_NOW=`netstat -tunlp| grep "7000" | wc -l 2>/dev/null` 8 | 9 | if [ $PRO_NOW -eq 0 ]; then 10 | cd $BASEDIR 11 | node ./bin/www > /tmp/run_node.log 2>&1 & 12 | else 13 | echo "`date` 7000 is listening..." 14 | fi 15 | sleep 3 16 | 17 | done 18 | -------------------------------------------------------------------------------- /simple-blog/views/reg.ejs: -------------------------------------------------------------------------------- 1 | <%- include header %> 2 |
3 | 用户名:
4 | 密码:
5 | 确认密码:
6 | 邮箱:
7 | 8 |
9 | <%- include footer %> 10 | -------------------------------------------------------------------------------- /css-layout/css3/5-5.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | CSS制作立体导航 7 | 8 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/README.md: -------------------------------------------------------------------------------- 1 | # React Examples 2 | 3 | Here are some small React demos. Some use [JSX](https://facebook.github.io/react/docs/jsx-in-depth.html) and some include third-party library integration. 4 | 5 | For more fully-featured examples, check out [React TodoMVC](http://todomvc.com/examples/react/) and [React + Backbone TodoMVC](http://todomvc.com/examples/react-backbone/). 6 | -------------------------------------------------------------------------------- /css-layout/css3/background-color.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | background-color 6 | 7 | 15 | 16 | 17 |

透明的背景

18 | 19 | 20 | -------------------------------------------------------------------------------- /py/logbook-demo/stdout_handler.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from logbook import Logger, StreamHandler 4 | import logbook 5 | import sys 6 | 7 | handler = StreamHandler(sys.stdout) 8 | log = Logger('test') 9 | 10 | def main(): 11 | log.info('something logging') 12 | 13 | if __name__ == '__main__': 14 | with handler.applicationbound(): 15 | main() 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /cyclejs/2.js: -------------------------------------------------------------------------------- 1 | // Logic (functional) 2 | function main() { 3 | return Rx.Observable.timer(0, 1000) 4 | .map( i => `seconds elapsed ${i}`); 5 | } 6 | 7 | // Effects (imperative) 8 | function DOMEffect(text$) { 9 | text$.subscribe(text => { 10 | const container = document.querySelector('#app'); 11 | container.textContent = text; 12 | }); 13 | } 14 | 15 | DOMEffect(main()); 16 | 17 | 18 | -------------------------------------------------------------------------------- /css-layout/waterfall-flow/colume-width.css: -------------------------------------------------------------------------------- 1 | .container { 2 | width: 60%; 3 | margin: 10px auto; 4 | column-width: 240px; 5 | -webkit-column-width: 240px; 6 | column-gap: 10px; 7 | -webkit-column-gap: 10px; 8 | } 9 | 10 | .container div { 11 | text-align: center; 12 | border: 1px solid #ccc; 13 | margin: 10px 0; 14 | } 15 | .container div img { 16 | padding: 5px 0; 17 | width: 240px; 18 | } 19 | -------------------------------------------------------------------------------- /simple-blog/views/upload.ejs: -------------------------------------------------------------------------------- 1 | <%- include header %> 2 |
3 |
4 |
5 |
6 |
7 |
8 | 9 |
10 | <%- include footer %> 11 | -------------------------------------------------------------------------------- /css-layout/css3/text-shadow.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | text-shadow 7 | 16 | 17 | 18 |
IMOOC
19 | 20 | 21 | -------------------------------------------------------------------------------- /node/colors.js: -------------------------------------------------------------------------------- 1 | // Generated by CoffeeScript 1.6.3 2 | (function() { 3 | var colors; 4 | 5 | colors = require('colors'); 6 | 7 | console.log('colors'.rainbow); 8 | 9 | colors.setTheme({ 10 | info: 'green', 11 | warn: 'yellow', 12 | error: 'red' 13 | }); 14 | 15 | console.log('Error'.error); 16 | 17 | console.log('Warning'.warn); 18 | 19 | console.log('Info'.info); 20 | 21 | }).call(this); 22 | -------------------------------------------------------------------------------- /node/speak/routes/index.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var router = express.Router(); 3 | 4 | /* GET home page. */ 5 | var index = require('../controllers/index.js'); 6 | 7 | router.get('/getData', index.getData); 8 | router.get('/rm', index.rm); 9 | router.get('/active', index.active); 10 | router.post('/speak', index.speak); 11 | router.post('/update', index.update); 12 | 13 | 14 | module.exports = router; 15 | -------------------------------------------------------------------------------- /simple-blog/views/post.ejs: -------------------------------------------------------------------------------- 1 | <%- include header %> 2 |
3 | 标题:
4 |
5 | 正文:
6 |
7 | 8 | 标签:
9 |
10 |
11 | <%- include footer %> 12 | -------------------------------------------------------------------------------- /css-layout/css3/background-size.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 背景图片大小 7 | 16 | 17 | 18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /node/internet-io.js: -------------------------------------------------------------------------------- 1 | var http = require('http') 2 | urls = ['baidu.com', 'tmall.com', 'jd.com', 'taobao.com', 'z.cn']; 3 | 4 | function fetchPage(url) { 5 | var start = new Date(); 6 | http.get({host: url}, function(res) { 7 | console.log("Got response from: " + url); 8 | console.log("Request took: ", new Date() - start, 'ms'); 9 | }); 10 | } 11 | 12 | for(var i = 0; i < urls.length; i++) { 13 | fetchPage(urls[i]); 14 | } 15 | -------------------------------------------------------------------------------- /ant-test/tiles/new.html: -------------------------------------------------------------------------------- 1 |

新建文章

2 |

Title

3 | 4 |

Date

5 | 6 |

url

7 | 8 |

tags

9 | 10 |

content

11 | 12 |

Submit

13 | 14 | 发布 15 | 16 | 17 | -------------------------------------------------------------------------------- /react/react-trader/www/js/feed-socketio.js: -------------------------------------------------------------------------------- 1 | feed = (function () { 2 | 3 | var socket = io(); 4 | 5 | return { 6 | onChange: function(callback) { 7 | socket.on('stock', callback); 8 | }, 9 | watch: function(symbols) { 10 | socket.emit('join', symbols); 11 | }, 12 | unwatch: function(symbol) { 13 | socket.emit('leave', symbol); 14 | } 15 | }; 16 | 17 | }()); -------------------------------------------------------------------------------- /react/react-trader/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ReactTrader", 3 | "version": "1.0.0", 4 | "description": "Trader Desktop", 5 | "main": "server.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Christophe Coenraets (http://coenraets.org/)", 10 | "license": "MIT", 11 | "dependencies": { 12 | "express": "^4.12.3", 13 | "socket.io": "^1.3.5" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/basic-commonjs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-basic-commonjs-example", 3 | "description": "Basic example of using React with CommonJS", 4 | "main": "index.js", 5 | "devDependencies": { 6 | "browserify": "^6.3.3", 7 | "envify": "^3.2.0", 8 | "react": "^0.13.0", 9 | "reactify": "^0.17.1" 10 | }, 11 | "scripts": { 12 | "build": "browserify --debug --transform reactify index.js > bundle.js" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /css-layout/css3/linear-gradient.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 20 |

Hello world!

21 | 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Learning 2 | 3 | `简介` 4 | 本仓库主要用于存储一些实用脚本,或者是学习记录,最开始只是自己学习时的备份,后来觉得如果稍加整理,对他人也是有帮助的 5 | 6 | 所以在这里会有一些自己的练习或者是别人分享的例子(添加别的的例子是出于便于整理和添加注释的目的,详细介绍中会有出处) 7 | 8 | ###目录 9 | 10 | *列举一些主要文件及简介, 详细信息可以进入目录查看README.md* 11 | 12 | - `c` 13 | - `react` 14 | - `react-0.13.3` 官方打包程序及Demo 15 | - `react-trader` Node.js+Socket.io+React.js的综合例子 16 | - `react-tutorial` 实时显示评论的例子 17 | - `msgfmt` 18 | - `gimp-plugin-bimp` GIMP插件的本地化翻译 19 | 20 | *2015-09-21* 整理(未完成) 21 | 22 | -------------------------------------------------------------------------------- /learn-html5/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 13 | 14 | html5特性检测 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /node/speak/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "server", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "start": "node ./bin/www" 7 | }, 8 | "dependencies": { 9 | "body-parser": "~1.13.2", 10 | "cookie-parser": "~1.3.5", 11 | "debug": "~2.2.0", 12 | "ejs": "~2.3.3", 13 | "express": "^4.13.3", 14 | "mongodb": "^2.1.4", 15 | "morgan": "~1.6.1", 16 | "serve-favicon": "~2.3.0", 17 | "silly-datetime": "^0.1.2" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/server-rendering/reactserver/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-server", 3 | "version": "0.0.0", 4 | "description": "", 5 | "main": "server.js", 6 | "scripts": { 7 | "start": "cd ../jsapp && node ../reactserver/server.js", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "dependencies": { 11 | "envify": "^3.0.0", 12 | "react": "^0.13.0", 13 | "express": "^3.5.1", 14 | "node-jsx": "^0.12.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /simple-blog/views/archive.ejs: -------------------------------------------------------------------------------- 1 | <%- include header %> 2 |
12 | <%- include footer %> 13 | -------------------------------------------------------------------------------- /simple-blog/views/tag.ejs: -------------------------------------------------------------------------------- 1 | <%- include header %> 2 | 12 | <%- include footer %> 13 | -------------------------------------------------------------------------------- /angularjs/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | hello, angular 6 | 7 | 8 |
9 |

{{greeting.text}},Angular

10 |
11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /simple-blog/views/search.ejs: -------------------------------------------------------------------------------- 1 | <%- include header %> 2 | 12 | <%- include footer %> 13 | -------------------------------------------------------------------------------- /react/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | learn react.js 7 | 8 | 9 | 10 | 11 | 12 |
13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /py/logbook-demo/file_stdout_handler.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from logbook import Logger, StreamHandler, FileHandler 4 | import logbook 5 | import sys 6 | 7 | ''' 8 | 记录日志到文件和STDOUT 9 | ''' 10 | 11 | StreamHandler(sys.stdout, level='DEBUG').push_application() 12 | FileHandler('app.log', bubble=True, level='INFO').push_application() 13 | 14 | log = Logger('test') 15 | 16 | def main(): 17 | log.info('hello world') 18 | 19 | if __name__ == '__main__': 20 | main() 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/server-rendering/jsapp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-js-app", 3 | "version": "0.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "build": "browserify -t reactify -r react -r ./src/App > ../webapp/static/bundle.js", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "dependencies": { 11 | "envify": "^3.0.0", 12 | "react": "^0.13.0", 13 | "browserify": "^3.38.0", 14 | "reactify": "^1.0.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /react/react-tutorial/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "React Tutorial Server", 3 | "description": "Code from the React tutorial", 4 | "keywords": [ "react", "reactjs", "tutorial" ], 5 | "repository": "https://github.com/reactjs/react-tutorial", 6 | "logo": "https://facebook.github.io/react/img/logo.svg", 7 | "website": "http://facebook.github.io/react/docs/tutorial.html", 8 | "success_url": "/", 9 | "env" : { 10 | "BUILDPACK_URL": "https://github.com/heroku/heroku-buildpack-nodejs.git" 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /css-layout/css3/font-face.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Font-face 7 | 21 | 22 | 23 | 24 |
IMOOC
25 | 26 | 27 | -------------------------------------------------------------------------------- /node/mocha/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mocha-test", 3 | "version": "0.0.0", 4 | "description": "just for fun", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "./node_modules/.bin/istanbul cover _mocha" 8 | }, 9 | "author": "sincerefly", 10 | "license": "BSD", 11 | "dependencies": { 12 | "should": "~8.0.1" 13 | }, 14 | "devDependencies": { 15 | "mocha": "~2.3.4", 16 | "istanbul": "~0.4.1", 17 | "gulp": "~3.9.0", 18 | "gulp-mocha": "~2.2.0", 19 | "gulp-util": "~3.0.7" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /cyclejs/2.1.js: -------------------------------------------------------------------------------- 1 | // Logic (functional) 2 | function main() { 3 | return Rx.Observable.timer(0, 1000) 4 | .map( i => `seconds elapsed ${i}`); 5 | } 6 | 7 | // Effects (imperative) 8 | function DOMEffect(text$) { 9 | text$.subscribe(text => { 10 | const container = document.querySelector('#app'); 11 | container.textContent = text; 12 | }); 13 | } 14 | 15 | function consoleLogEffect(msg$) { 16 | msg$.subscribe(msg => console.log(msg)); 17 | } 18 | 19 | const sink = main(); 20 | DOMEffect(sink); 21 | consoleLogEffect(sink); 22 | 23 | 24 | -------------------------------------------------------------------------------- /css-layout/css3/circle.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | cicle 7 | 21 | 22 | 23 |
24 |
25 |
26 |
27 | 28 | 29 | -------------------------------------------------------------------------------- /css-layout/css3/shadow.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | shadow 6 | 7 | 19 | 20 | 21 | 22 |

外阴影

23 |
24 |

内阴影

25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /css-layout/css3/multiple_backgrounds.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 多重背景 7 | 17 | 18 | 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /gettext/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /*使用gettext通常使用类似下面的一个带函数的宏定义 6 | *你完全可以不用,直接使用 gettext(字符串) 7 | */ 8 | #define _(S) gettext(S) 9 | 10 | /*PACKAGE是本程序最终的名字(运行时输入的命令)*/ 11 | #define PACKAGE "jian_gettext" 12 | 13 | int main(int argc, char **argv) 14 | { 15 | /* 下面三个参数都是使用gettext时候需要使用的 16 | * setlocale 17 | * bindtextdomain 18 | * textdomain 19 | */ 20 | setlocale(LC_ALL,""); 21 | bindtextdomain(PACKAGE, "locale"); 22 | textdomain(PACKAGE); 23 | 24 | printf(_("Hello,GetText!\n")); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /css-layout/float/float-2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | float test 5 | 6 | 17 | 18 | 19 |
20 | 21 |
22 |
23 |
24 | 25 |
26 | 27 | -------------------------------------------------------------------------------- /py/logbook-demo/stdout_handler3.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from logbook import Logger, StreamHandler 4 | import logbook 5 | import sys 6 | import threading 7 | 8 | ''' 9 | 使用threadbound()只针对当前进程 10 | ''' 11 | 12 | handler = StreamHandler(sys.stdout) 13 | log = Logger('test') 14 | 15 | def worker(): 16 | log.info('something logging') 17 | 18 | if __name__ == '__main__': 19 | #with handler.applicationbound(): 20 | with handler.threadbound(): 21 | log.info('main thread') 22 | t = threading.Thread(target=worker) 23 | t.start() 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /py/sort/quick_sort.py: -------------------------------------------------------------------------------- 1 | #!/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import random 5 | import copy 6 | 7 | 8 | def quick(data): 9 | 10 | ''' 11 | 快速排序(quick sort) 12 | ''' 13 | 14 | if len(data) <= 1: 15 | return data 16 | else: 17 | pivot = data[0] 18 | return quick([x for x in data[1:] if x < pivot]) + \ 19 | [pivot] + \ 20 | quick([x for x in data[1:] if x >= pivot]) 21 | 22 | 23 | if __name__ == '__main__': 24 | 25 | data = random.sample(range(100), 6) 26 | 27 | print(data) 28 | print(quick(data)) 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /simple-blog/views/article.ejs: -------------------------------------------------------------------------------- 1 | <%- include header %> 2 |

3 | <% if (user && (user.name == post.name)) { %> 4 | 编辑 5 | 删除 6 | <% } %> 7 |

8 |

9 | 作者:<%= post.name %> | 10 | 日期:<%= post.time.minute %> 11 |

12 |

<%- post.post %>

13 |

阅读:<%= post.pv %> | 评论:<%= post.comments.length %>

14 | <%- include comment %> 15 | <%- include footer %> 16 | -------------------------------------------------------------------------------- /py/dragspeed_compare/use-base.py: -------------------------------------------------------------------------------- 1 | #!/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | from bs4 import BeautifulSoup 5 | import requests 6 | 7 | 8 | urls = [] 9 | with open('urls.txt', 'r') as f: 10 | for url in f: 11 | urls.append(url.strip()) 12 | 13 | 14 | def parser_title(page): 15 | 16 | soup = BeautifulSoup(page, 'lxml') 17 | a = soup.find('div', 'report-title') 18 | return a.text.strip() 19 | 20 | def print_title(url): 21 | 22 | page = requests.get(url).text 23 | title = parser_title(page) 24 | print('{}: {}'.format(url, title)) 25 | 26 | 27 | for url in urls: 28 | print_title(url) 29 | -------------------------------------------------------------------------------- /react/react-tutorial/LICENSE: -------------------------------------------------------------------------------- 1 | The examples provided by Facebook are for non-commercial testing and evaluation 2 | purposes only. Facebook reserves all rights not expressly granted. 3 | 4 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 5 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 6 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 7 | FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 8 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 9 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /simple-blog/views/user.ejs: -------------------------------------------------------------------------------- 1 | <%- include header %> 2 | <% posts.forEach(function (post, index) { %> 3 |

4 |

5 | <%= post.title %> 6 |

7 | 8 |

9 |

10 | 作者:<%= post.name %> | 11 | 日期:<%= post.time.minute %> 12 |

13 |

<%- post.post %>

14 |

阅读:<%= post.pv %> | 评论:<%= post.comments.length %>

15 | <% }) %> 16 | <%- include paging %> 17 | <%- include footer %> 18 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/basic-jsx-external/example.js: -------------------------------------------------------------------------------- 1 | var ExampleApplication = React.createClass({ 2 | render: function() { 3 | var elapsed = Math.round(this.props.elapsed / 100); 4 | var seconds = elapsed / 10 + (elapsed % 10 ? '' : '.0' ); 5 | var message = 6 | 'React has been successfully running for ' + seconds + ' seconds.'; 7 | 8 | return

{message}

; 9 | } 10 | }); 11 | 12 | var start = new Date().getTime(); 13 | 14 | setInterval(function() { 15 | React.render( 16 | , 17 | document.getElementById('container') 18 | ); 19 | }, 50); 20 | -------------------------------------------------------------------------------- /simple-blog/views/edit.ejs: -------------------------------------------------------------------------------- 1 | <%- include header %> 2 |
3 | 标题:
4 |
5 | 标签:
6 | 7 | 8 |
9 | 正文:
10 |
11 | 12 |
13 | <%- include footer %> 14 | -------------------------------------------------------------------------------- /node/mocha/index.js: -------------------------------------------------------------------------------- 1 | var fibonacci = function (n) { 2 | 3 | if (n === 0) { 4 | return 0; 5 | } 6 | if (n === 1) { 7 | return 1; 8 | } 9 | if (n < 0) { 10 | throw new Error("n should >= 0"); 11 | } 12 | if (n > 10) { 13 | throw new Error("n should <= 10"); 14 | } 15 | if (typeof n !== 'number') { 16 | throw new Error("n should be a number"); 17 | } 18 | return fibonacci(n-1) + fibonacci(n-2); 19 | } 20 | 21 | if (require.main === module) { 22 | var n = Number(process.argv[2]); 23 | console.log("fibonacci(" + n + ") is", fibonacci(n)); 24 | } 25 | 26 | exports.fibonacci = fibonacci; 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/basic-jsx-precompile/example.js: -------------------------------------------------------------------------------- 1 | var ExampleApplication = React.createClass({ 2 | render: function() { 3 | var elapsed = Math.round(this.props.elapsed / 100); 4 | var seconds = elapsed / 10 + (elapsed % 10 ? '' : '.0' ); 5 | var message = 6 | 'React has been successfully running for ' + seconds + ' seconds.'; 7 | 8 | return

{message}

; 9 | } 10 | }); 11 | 12 | var start = new Date().getTime(); 13 | 14 | setInterval(function() { 15 | React.render( 16 | , 17 | document.getElementById('container') 18 | ); 19 | }, 50); 20 | -------------------------------------------------------------------------------- /cyclejs/3.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | return { 3 | DOM: Rx.Observable.timer(0, 1000) 4 | .map(i => `Seconds elapsed ${i}`), 5 | Log: Rx.Observable.timer(0, 2000) 6 | .map(i => 2*i), 7 | }; 8 | } 9 | 10 | function DOMEffect(text$) { 11 | text$.subscribe(text => { 12 | const container = document.querySelector('#app'); 13 | container.textContent = text; 14 | }); 15 | } 16 | 17 | function consoleLogEffect(msg$) { 18 | msg$.subscribe(msg => console.log(msg)); 19 | } 20 | 21 | function run(mainFn) { 22 | const sinks = main(); 23 | DOMEffect(sinks.DOM); 24 | consoleLogEffect(sinks.Log); 25 | } 26 | 27 | run(main); 28 | 29 | -------------------------------------------------------------------------------- /node/mocha/coverage/lcov.info: -------------------------------------------------------------------------------- 1 | TN: 2 | SF:/home/sincerefly/Works/Projects/node/mocha/index.js 3 | FN:1,(anonymous_1) 4 | FNF:1 5 | FNH:1 6 | FNDA:182,(anonymous_1) 7 | DA:1,1 8 | DA:3,182 9 | DA:4,35 10 | DA:6,147 11 | DA:7,56 12 | DA:9,91 13 | DA:10,1 14 | DA:12,90 15 | DA:13,1 16 | DA:15,89 17 | DA:16,1 18 | DA:18,88 19 | DA:21,1 20 | DA:22,0 21 | DA:23,0 22 | DA:26,1 23 | LF:16 24 | LH:14 25 | BRDA:3,1,0,35 26 | BRDA:3,1,1,147 27 | BRDA:6,2,0,56 28 | BRDA:6,2,1,91 29 | BRDA:9,3,0,1 30 | BRDA:9,3,1,90 31 | BRDA:12,4,0,1 32 | BRDA:12,4,1,89 33 | BRDA:15,5,0,1 34 | BRDA:15,5,1,88 35 | BRDA:21,6,0,0 36 | BRDA:21,6,1,1 37 | BRF:12 38 | BRH:11 39 | end_of_record 40 | -------------------------------------------------------------------------------- /ant-test/js/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Datepicker, message } from 'antd'; 3 | 4 | var App = React.createClass({ 5 | getInitialState() { 6 | return { 7 | date: '' 8 | }; 9 | }, 10 | handleChange(value) { 11 | message.info('您选择的日期是: ' + value.toString()); 12 | this.setState({ 13 | date: value 14 | }); 15 | }, 16 | render() { 17 | return
18 | 19 |
当前日期:{this.state.date.toString()}
20 |
; 21 | } 22 | }); 23 | 24 | React.render(, document.body); 25 | -------------------------------------------------------------------------------- /py/logbook-demo/processors.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from logbook import Logger, StreamHandler, Processor 4 | import logbook 5 | import sys 6 | 7 | logbook.set_datetime_format('local') 8 | handler = StreamHandler(sys.stdout) 9 | handler.format_string = '[{record.time:%Y-%m-%d %H:%M:%S}] IP:{record.extra[ip]} {record.level_name}: {record.channel}: {record.message}' 10 | handler.formatter 11 | 12 | log = Logger('test') 13 | 14 | def inject_ip(record): 15 | record.extra['ip'] = '127.0.0.1' 16 | 17 | with handler.applicationbound(): 18 | with Processor(inject_ip).applicationbound(): 19 | log.error('something error') 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /node/mocha/coverage/lcov-report/prettify.css: -------------------------------------------------------------------------------- 1 | .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} 2 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/basic-commonjs/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var React = require('react'); 4 | 5 | var ExampleApplication = React.createClass({ 6 | render: function() { 7 | var elapsed = Math.round(this.props.elapsed / 100); 8 | var seconds = elapsed / 10 + (elapsed % 10 ? '' : '.0' ); 9 | var message = 10 | 'React has been successfully running for ' + seconds + ' seconds.'; 11 | 12 | return

{message}

; 13 | } 14 | }); 15 | 16 | var start = new Date().getTime(); 17 | 18 | setInterval(function() { 19 | React.render( 20 | , 21 | document.getElementById('container') 22 | ); 23 | }, 50); 24 | -------------------------------------------------------------------------------- /py/sort/insertion_sort.py: -------------------------------------------------------------------------------- 1 | #!/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import random 5 | import copy 6 | 7 | 8 | def insertion(data): 9 | 10 | ''' 11 | 插入排序(insertion sort) 12 | ''' 13 | 14 | N = len(data) 15 | if N==1: return data 16 | 17 | count = 0 18 | for i in range(1, N): 19 | for j in range(i, 0, -1): 20 | if data[j-1] > data[j]: 21 | count = count + 1 22 | data[j-1], data[j] = data[j], data[j-1] 23 | 24 | return (data, count) 25 | 26 | 27 | if __name__ == '__main__': 28 | 29 | data = random.sample(range(100), 6) 30 | 31 | print(data) 32 | print(insertion(data)) 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /jQuery/demo3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | test jquery 5 | 6 | 7 | 8 | 9 | 10 |
a test
11 |
12 |
2333
13 |
2333
14 |
2333
15 | 16 |
17 | 18 |
19 |

haha

20 |

haha

21 |

haha

22 |
23 |

haha2

24 |

haha2

25 |

haha2

26 |
27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /py/singleton/Count.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | class Count(object): 4 | def __init__(self): 5 | print "init count" 6 | self.a = 0 7 | def up(self): 8 | print "+1" 9 | self.a = self.a + 1 10 | def down(self): 11 | print "-1" 12 | self.a = self.a - 1 13 | 14 | sys.modules[__name__] = Count() 15 | 16 | 17 | ''' python使用模块实现单例模式 ''' 18 | 19 | # 使用方法如下: 20 | 21 | # [GCC 6.1.1 20160621 (Red Hat 6.1.1-3)] on linux2 22 | # Type "help", "copyright", "credits" or "license" for more information. 23 | # >>> import Count 24 | # init count 25 | # >>> Count.up() 26 | # +1 27 | # >>> Count.a 28 | # 1 29 | # >>> Count.up() 30 | # +1 31 | # >>> Count.a 32 | # 2 33 | # >>> 34 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/basic-jsx-precompile/build/example.js: -------------------------------------------------------------------------------- 1 | var ExampleApplication = React.createClass({displayName: "ExampleApplication", 2 | render: function() { 3 | var elapsed = Math.round(this.props.elapsed / 100); 4 | var seconds = elapsed / 10 + (elapsed % 10 ? '' : '.0' ); 5 | var message = 6 | 'React has been successfully running for ' + seconds + ' seconds.'; 7 | 8 | return React.createElement("p", null, message); 9 | } 10 | }); 11 | 12 | var start = new Date().getTime(); 13 | 14 | setInterval(function() { 15 | React.render( 16 | React.createElement(ExampleApplication, {elapsed: new Date().getTime() - start}), 17 | document.getElementById('container') 18 | ); 19 | }, 50); 20 | -------------------------------------------------------------------------------- /react/react-trader/www/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Trader Desktop 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /css-layout/css3/background-origin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 背景原点 7 | 28 | 29 | 30 |
31 | padding 32 | 123 33 |
content
34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /py/sort/selection_sort.py: -------------------------------------------------------------------------------- 1 | #!/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import random 5 | import copy 6 | 7 | 8 | def selection(data): 9 | 10 | ''' 11 | 选择排序(selection sort) 12 | ''' 13 | 14 | N = len(data) 15 | count = 0 16 | for i in range(N-1): 17 | min_index = i 18 | for j in range(i+1, N): 19 | if data[min_index] > data[j]: 20 | min_index = j 21 | if min_index != i: 22 | count = count + 1 23 | data[min_index], data[i] = data[i], data[min_index] 24 | 25 | return (data, count) 26 | 27 | 28 | if __name__ == '__main__': 29 | 30 | data = random.sample(range(100), 6) 31 | 32 | print(data) 33 | print(selection(data)) 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /css-layout/float/float.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | float test 5 | 6 | 22 | 23 | 24 |
float
25 |
time time time time time time time time time time
26 |
27 |
28 |
float
29 |
time time time time time time time time time time
30 | 31 | -------------------------------------------------------------------------------- /py/dragspeed_compare/use-gevent.py: -------------------------------------------------------------------------------- 1 | #!/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import gevent 5 | from gevent import monkey 6 | import random 7 | import requests 8 | from bs4 import BeautifulSoup 9 | monkey.patch_all() 10 | 11 | 12 | urls = [] 13 | with open('urls.txt', 'r') as f: 14 | for url in f: 15 | urls.append(url.strip()) 16 | 17 | 18 | def parser_title(page): 19 | 20 | soup = BeautifulSoup(page, 'lxml') 21 | a = soup.find('div', 'report-title') 22 | return a.text.strip() 23 | 24 | def print_title(url): 25 | 26 | page = requests.get(url).text 27 | title = parser_title(page) 28 | print('{}: {}'.format(url, title)) 29 | 30 | 31 | threads = [gevent.spawn(print_title, url) for url in urls] 32 | gevent.joinall(threads) 33 | 34 | -------------------------------------------------------------------------------- /py/dragspeed_compare/urls.txt: -------------------------------------------------------------------------------- 1 | http://data.eastmoney.com/report/20160919/APPH5Ql7JtQYASearchReport.html 2 | http://data.eastmoney.com/report/20160919/APPH5Ql7JtSkASearchReport.html 3 | http://data.eastmoney.com/report/20160919/APPH5Ql7JtUNASearchReport.html 4 | http://data.eastmoney.com/report/20160919/APPH5Ql7JtUKASearchReport.html 5 | http://data.eastmoney.com/report/20160919/APPH5Ql7Jv7aASearchReport.html 6 | http://data.eastmoney.com/report/20160919/APPH5Ql7JvZVASearchReport.html 7 | http://data.eastmoney.com/report/20160919/APPH5Ql7JucEASearchReport.html 8 | http://data.eastmoney.com/report/20160919/APPH5Ql7JubpASearchReport.html 9 | http://data.eastmoney.com/report/20160919/APPH5Ql7JvbJASearchReport.html 10 | http://data.eastmoney.com/report/20160918/APPH5QX84P1MASearchReport.html 11 | -------------------------------------------------------------------------------- /py/dragspeed_compare/use-multiprocessing.py: -------------------------------------------------------------------------------- 1 | #!/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | from multiprocessing import Pool 5 | from bs4 import BeautifulSoup 6 | import os, time 7 | import requests 8 | 9 | 10 | urls = [] 11 | with open('urls.txt', 'r') as f: 12 | for url in f: 13 | urls.append(url.strip()) 14 | 15 | 16 | def parser_title(page): 17 | 18 | soup = BeautifulSoup(page, 'lxml') 19 | a = soup.find('div', 'report-title') 20 | return a.text.strip() 21 | 22 | def print_title(url): 23 | 24 | page = requests.get(url).text 25 | title = parser_title(page) 26 | print('{}: {}'.format(url, title)) 27 | 28 | 29 | p = Pool(processes=4) 30 | for url in urls: 31 | p.apply_async(print_title, args=(url,)) 32 | p.close() 33 | p.join() 34 | -------------------------------------------------------------------------------- /cyclejs/4.js: -------------------------------------------------------------------------------- 1 | function main() { 2 | return { 3 | DOM: Rx.Observable.timer(0, 1000) 4 | .map(i => `Seconds elapsed ${i}`), 5 | Log: Rx.Observable.timer(0, 2000) 6 | .map(i => 2*i), 7 | }; 8 | } 9 | 10 | function DOMDriver(text$) { 11 | text$.subscribe(text => { 12 | const container = document.querySelector('#app'); 13 | container.textContent = text; 14 | }); 15 | } 16 | 17 | function consoleLogDriver(msg$) { 18 | msg$.subscribe(msg => console.log(msg)); 19 | } 20 | 21 | function run(mainFn, drivers) { 22 | const sinks = mainFn(); 23 | 24 | Object.keys(drivers).forEach(key => { 25 | drivers[key](sinks[key]); 26 | }); 27 | } 28 | 29 | const drivers = { 30 | DOM: DOMDriver, 31 | Log: consoleLogDriver, 32 | } 33 | 34 | run(main, drivers); 35 | -------------------------------------------------------------------------------- /css-layout/css3/background-clip.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 背景裁切 7 | 29 | 30 | 31 |
32 | padding 33 | 123 34 |
content
35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/shared/thirdparty/console-polyfill.js: -------------------------------------------------------------------------------- 1 | // Console-polyfill. MIT license. 2 | // https://github.com/paulmillr/console-polyfill 3 | // Make it safe to do console.log() always. 4 | (function(con) { 5 | 'use strict'; 6 | var prop, method; 7 | var empty = {}; 8 | var dummy = function() {}; 9 | var properties = 'memory'.split(','); 10 | var methods = ('assert,clear,count,debug,dir,dirxml,error,exception,group,' + 11 | 'groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,' + 12 | 'table,time,timeEnd,timeStamp,trace,warn').split(','); 13 | while (prop = properties.pop()) con[prop] = con[prop] || empty; 14 | while (method = methods.pop()) con[method] = con[method] || dummy; 15 | })(this.console = this.console || {}); // Using `this` for web workers. 16 | -------------------------------------------------------------------------------- /simple-blog/views/index.ejs: -------------------------------------------------------------------------------- 1 | <%- include header %> 2 | <% posts.forEach(function (post, index) { %> 3 |

4 |

5 | <%= post.title %> 6 |

7 | 8 |

9 | 作者:<%= post.name %> | 10 |

11 | 日期:<%= post.time.minute %> | 12 | 标签: 13 | <% post.tags.forEach(function (tag, index) { %> 14 | <% if (tag) { %> 15 | <%= tag %> 16 | <% } %> 17 | <% }) %> 18 |

19 |

<%- post.post %>

20 |

阅读:<%= post.pv %> | 评论:<%= post.comments.length %>

21 | <% }) %> 22 | <%- include paging %> 23 | <%- include footer %> 24 | -------------------------------------------------------------------------------- /tumblrlikeg/Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function(grunt) { 2 | grunt.initConfig({ 3 | pkg: grunt.file.readJSON('package.json'), 4 | 5 | sass: { 6 | options: { 7 | includePaths: ['bower_components/foundation/scss'] 8 | }, 9 | dist: { 10 | options: { 11 | outputStyle: 'compressed' 12 | }, 13 | files: { 14 | 'css/app.css': 'scss/app.scss' 15 | } 16 | } 17 | }, 18 | 19 | watch: { 20 | grunt: { files: ['Gruntfile.js'] }, 21 | 22 | sass: { 23 | files: 'scss/**/*.scss', 24 | tasks: ['sass'] 25 | } 26 | } 27 | }); 28 | 29 | grunt.loadNpmTasks('grunt-sass'); 30 | grunt.loadNpmTasks('grunt-contrib-watch'); 31 | 32 | grunt.registerTask('build', ['sass']); 33 | grunt.registerTask('default', ['build','watch']); 34 | } 35 | -------------------------------------------------------------------------------- /py/sqlite-demo/shipping_data.json: -------------------------------------------------------------------------------- 1 | [{"logistics_name": "ups", "order_id": "227735966", "robot_status": 6, "logistics_code": "1ZA652F40456834689", "order_status": "Track this order", "order_date": "2016-09-21"}, {"logistics_name": "ups", "order_id": "227677275", "robot_status": 6, "logistics_code": "1ZA652F40456807182", "order_status": "Track this order", "order_date": "2016-09-21"}, {"logistics_name": "ups", "order_id": "227677187", "robot_status": 6, "logistics_code": "1ZA0T8680225062634", "order_status": "Track this order", "order_date": "2016-09-21"}, {"logistics_name": "ups", "order_id": "227559294", "robot_status": 6, "logistics_code": "1ZA652F40456762935", "order_status": "Track this order", "order_date": "2016-09-20"},{"logistics_name": "ups", "order_id": "227557777", "robot_status": 6, "logistics_code": "1ZA652F40456763721", "order_status": "Track this order", "order_date": "2016-09-22"}] 2 | -------------------------------------------------------------------------------- /react/react-trader/www/css/styles.css: -------------------------------------------------------------------------------- 1 | table { 2 | border-collapse: collapse; 3 | } 4 | 5 | th:first-child { 6 | text-align: left; 7 | } 8 | 9 | th:not(:first-child), 10 | td:not(:first-child) { 11 | text-align: right; 12 | } 13 | 14 | th:last-child, 15 | td:last-child { 16 | text-align: center; 17 | } 18 | 19 | th, td { 20 | max-width: 74px; 21 | width: 74px; 22 | border: solid 1px #DDDDDD; 23 | padding: 5px; 24 | } 25 | 26 | th { 27 | font-weight: bolder; 28 | } 29 | 30 | .last-positive { 31 | background: green; 32 | color: #FFFFFF; 33 | } 34 | 35 | .last-negative { 36 | background: red; 37 | color: #FFFFFF; 38 | } 39 | 40 | .change-positive { 41 | color: green; 42 | } 43 | 44 | .change-negative { 45 | color: red; 46 | } 47 | 48 | .row { 49 | margin: 10px 0; 50 | } 51 | 52 | .container { 53 | width: 552px; 54 | } -------------------------------------------------------------------------------- /simple-blog/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "simple-blog", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "start": "node ./bin/www" 7 | }, 8 | "dependencies": { 9 | "body-parser": "~1.10.2", 10 | "connect-flash": "^0.1.1", 11 | "connect-mongo": "^0.7.0", 12 | "cookie-parser": "~1.3.3", 13 | "debug": "~2.1.1", 14 | "ejs": "~2.2.3", 15 | "express": "~4.11.1", 16 | "express-session": "^1.10.3", 17 | "markdown": "^0.5.0", 18 | "mongodb": "^1.4.31", 19 | "morgan": "~1.5.1", 20 | "multer": "^0.1.8", 21 | "serve-favicon": "~2.2.0" 22 | }, 23 | "devDependencies": { 24 | "grunt": "^0.4.5", 25 | "grunt-concurrent": "^1.0.0", 26 | "grunt-contrib-coffee": "^0.13.0", 27 | "grunt-contrib-jshint": "^0.11.0", 28 | "grunt-contrib-watch": "^0.6.1", 29 | "grunt-nodemon": "^0.4.0" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/server-rendering/reactserver/server.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var React = require('react'); 4 | var express = require('express'); 5 | var path = require('path'); 6 | 7 | // Transparently support JSX 8 | require('node-jsx').install(); 9 | 10 | var app = express(); 11 | 12 | // All the render server does is take a CommonJS module ID and some JSON props 13 | // in the querystring and return a static HTML representation of the component. 14 | // Note that this is a backend service hit by your actual web app. Even so, 15 | // you would probably put Varnish in front of this in production. 16 | app.get('/', function(req, res) { 17 | var component = require(path.resolve(req.query.module)); 18 | var props = JSON.parse(req.query.props || '{}'); 19 | 20 | res.send(React.renderToString(React.createElement(component, props))); 21 | }); 22 | 23 | app.listen(3000); 24 | -------------------------------------------------------------------------------- /tumblrlikeg/README.md: -------------------------------------------------------------------------------- 1 | # Foundation libsass template 2 | 3 | This is a template to start your own project that uses Grunt and libsass! 4 | 5 | ## Requirements 6 | 7 | You'll need to have the following items installed before continuing. 8 | 9 | * [Node.js](http://nodejs.org): Use the installer provided on the NodeJS website. 10 | * [Grunt](http://gruntjs.com/): Run `[sudo] npm install -g grunt-cli` 11 | * [Bower](http://bower.io): Run `[sudo] npm install -g bower` 12 | 13 | ## Quickstart 14 | 15 | ```bash 16 | git clone git@github.com:zurb/foundation-libsass-template.git 17 | npm install && bower install 18 | ``` 19 | 20 | While you're working on your project, run: 21 | 22 | `grunt` 23 | 24 | And you're set! 25 | 26 | ## Directory Structure 27 | 28 | * `scss/_settings.scss`: Foundation configuration settings go in here 29 | * `scss/app.scss`: Application styles go here 30 | -------------------------------------------------------------------------------- /react/react-tutorial/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-tutorial", 3 | "version": "0.0.0", 4 | "description": "Code from the React tutorial.", 5 | "main": "server.js", 6 | "dependencies": { 7 | "body-parser": "^1.4.3", 8 | "express": "^4.4.5" 9 | }, 10 | "devDependencies": {}, 11 | "scripts": { 12 | "test": "echo \"Error: no test specified\" && exit 1", 13 | "start": "node server.js" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "https://github.com/reactjs/react-tutorial.git" 18 | }, 19 | "keywords": [ 20 | "react", 21 | "tutorial", 22 | "comment", 23 | "example" 24 | ], 25 | "author": "petehunt", 26 | "bugs": { 27 | "url": "https://github.com/reactjs/react-tutorial/issues" 28 | }, 29 | "homepage": "https://github.com/reactjs/react-tutorial", 30 | "engines" : { 31 | "node" : "0.12.x" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /gettext/jian_gettext.po: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #: test.c:20 7 | #, fuzzy 8 | msgid "" 9 | msgstr "" 10 | "Project-Id-Version: PACKAGE VERSION\n" 11 | "Report-Msgid-Bugs-To: \n" 12 | "POT-Creation-Date: 2015-09-19 10:23+0800\n" 13 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 | "Last-Translator: FULL NAME \n" 15 | "Language-Team: LANGUAGE \n" 16 | "Language: \n" 17 | "MIME-Version: 1.0\n" 18 | "Content-Type: text/plain; charset=UTF-8\n" 19 | "Content-Transfer-Encoding: 8bit\n" 20 | 21 | #: test.c:11 22 | msgid "jian_gettext" 23 | msgstr "" 24 | 25 | #: test.c:21 26 | msgid "locale" 27 | msgstr "" 28 | 29 | #: test.c:24 30 | #, c-format 31 | msgid "Hello,GetText!\n" 32 | msgstr "你好,GetText!\n" 33 | -------------------------------------------------------------------------------- /learn-html5/2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 13 | 14 | html5 canvas 15 | 16 | 17 |
18 | 19 |
20 | 21 | 22 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /simple-blog/views/comment.ejs: -------------------------------------------------------------------------------- 1 |
2 | <% post.comments.forEach(function (comment, index) { %> 3 |
4 |

<%= comment.name %> 5 | 回复于 <%= comment.time %>

6 |

<%- comment.content %>

7 |
8 | <% }) %> 9 | 10 |
11 | <% if (user) { %> 12 | 姓名:
13 | 邮箱:
14 | 网址:
15 | <% } else { %> 16 | 姓名:
17 | 邮箱:
18 | 网址:
19 | <% } %> 20 |
21 | 22 |
23 | -------------------------------------------------------------------------------- /learn-html5/4.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 13 | 14 | html5 canvas 15 | 16 | 17 |
18 | 19 |
20 | 21 | 22 | 23 | 24 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/transitions/transition.css: -------------------------------------------------------------------------------- 1 | .example-enter, 2 | .example-leave { 3 | -webkit-transition: all .25s; 4 | transition: all .25s; 5 | } 6 | 7 | .example-enter, 8 | .example-leave.example-leave-active { 9 | opacity: 0.01; 10 | } 11 | 12 | .example-leave.example-leave-active { 13 | margin-left: -128px; 14 | } 15 | 16 | .example-enter { 17 | margin-left: 128px; 18 | } 19 | 20 | .example-enter.example-enter-active, 21 | .example-leave { 22 | margin-left: 0; 23 | opacity: 1; 24 | } 25 | 26 | .animateExample { 27 | display: block; 28 | height: 128px; 29 | position: relative; 30 | width: 384px; 31 | } 32 | 33 | .animateItem { 34 | color: white; 35 | font-size: 36px; 36 | font-weight: bold; 37 | height: 128px; 38 | line-height: 128px; 39 | position: absolute; 40 | text-align: center; 41 | -webkit-transition: all .25s; /* TODO: make this a move animation */ 42 | transition: all .25s; /* TODO: make this a move animation */ 43 | width: 128px; 44 | } 45 | -------------------------------------------------------------------------------- /css-layout/top-bar/js/script.js: -------------------------------------------------------------------------------- 1 | ;(function() { 2 | 3 | 'use strict'; 4 | 5 | var i, 6 | $popoverLinks = document.querySelectorAll('[data-popover]'), 7 | $popovers = document.querySelectorAll('.popover'); 8 | 9 | function init() { 10 | for (i = 0; i < $popoverLinks.length; i++) $popoverLinks[i].addEventListener('click', openPopover); 11 | document.addEventListener('click', closePopover); 12 | } 13 | 14 | function closePopover(e) { 15 | for (i = 0; i < $popovers.length; i++) $popovers[i].classList.remove('popover-open'); 16 | } 17 | 18 | function openPopover(e) { 19 | e.preventDefault(); 20 | if (document.querySelector(this.getAttribute('href')).classList.contains('popover-open')) { 21 | document.querySelector(this.getAttribute('href')).classList.remove('popover-open'); 22 | } 23 | else { 24 | closePopover(); 25 | document.querySelector(this.getAttribute('href')).classList.add('popover-open'); 26 | } 27 | e.stopImmediatePropagation(); 28 | } 29 | 30 | init(); 31 | 32 | }()); 33 | 34 | -------------------------------------------------------------------------------- /py/sort/merge_sort.py: -------------------------------------------------------------------------------- 1 | #!/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import random 5 | from collections import deque 6 | 7 | 8 | def merge(left, right): 9 | 10 | ''' 11 | 将两个有序队列合并为一个有序队列 12 | ''' 13 | 14 | merged, left, right = deque(), deque(left), deque(right) 15 | while left and right: 16 | merged.append(left.popleft() if left[0] <= right[0] else right.popleft()) 17 | merged.extend(right if right else left) 18 | #print(merged) 19 | 20 | return list(merged) 21 | 22 | 23 | def merge_sort(data): 24 | 25 | ''' 26 | 归并排序(merge sort) 27 | ''' 28 | 29 | if len(data) <= 1: 30 | return data 31 | 32 | middle = int(len(data) // 2) 33 | left = merge_sort(data[:middle]) 34 | right = merge_sort(data[middle:]) 35 | 36 | #print(left, right) 37 | return merge(left, right) 38 | 39 | 40 | if __name__ == '__main__': 41 | 42 | data = random.sample(range(100), 6) 43 | 44 | print(data) 45 | print(merge_sort(data)) 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /react/test2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Learn React! 5 | 6 | 7 | 37 | 38 | 39 |
40 | 41 | 42 | -------------------------------------------------------------------------------- /react/test3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Learn React! 5 | 6 | 7 | 37 | 38 | 39 |
40 | 41 | 42 | -------------------------------------------------------------------------------- /react/react-tutorial/comments.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "text": "Hey there!", 4 | "author": "Pete Hunt" 5 | }, 6 | { 7 | "text": "React is great!", 8 | "author": "Paul O\u2019Shannessy" 9 | }, 10 | { 11 | "text": "hello world!", 12 | "author": "David" 13 | }, 14 | { 15 | "text": "123", 16 | "author": "123" 17 | }, 18 | { 19 | "text": "aasdasd", 20 | "author": "qqqqqq" 21 | }, 22 | { 23 | "text": "1111", 24 | "author": "1111" 25 | }, 26 | { 27 | "text": "1111", 28 | "author": "123" 29 | }, 30 | { 31 | "text": "sdx", 32 | "author": "asadsdasd" 33 | }, 34 | { 35 | "text": "ssss", 36 | "author": "aaaa" 37 | }, 38 | { 39 | "text": "\u4ece\u6b64\u5927\u5927\u7b2c\u4e09 \u56db\u56db\u56db", 40 | "author": "aaa\u5728\u518d\u5728" 41 | }, 42 | { 43 | "text": "hello world!", 44 | "author": "gimp" 45 | } 46 | ] -------------------------------------------------------------------------------- /react/react-tutorial/react-scotty.cabal: -------------------------------------------------------------------------------- 1 | -- Initial react-scotty.cabal generated by cabal init. For further 2 | -- documentation, see http://haskell.org/cabal/users-guide/ 3 | 4 | name: react-scotty 5 | version: 0.1.0.0 6 | synopsis: React Haskell code with Scotty 7 | -- description: 8 | license: GPL-2 9 | license-file: LICENSE 10 | author: Sibi 11 | maintainer: sibi@psibi.in 12 | -- copyright: 13 | category: Web 14 | build-type: Simple 15 | -- extra-source-files: 16 | cabal-version: >=1.10 17 | 18 | executable react-scotty 19 | main-is: Server.hs 20 | -- other-modules: 21 | -- other-extensions: 22 | build-depends: base >=4.8 && <4.9, 23 | scotty, wai-extra, 24 | mtl, text, aeson, 25 | bytestring, 26 | wai-middleware-static 27 | -- hs-source-dirs: 28 | default-language: Haskell2010 29 | -------------------------------------------------------------------------------- /node/mocha/test/index.test.js: -------------------------------------------------------------------------------- 1 | // file: test/index.test.js 2 | var index = require("../index"); 3 | var should = require("should"); 4 | 5 | describe("test/index.test.js", function () { 6 | 7 | it("should equal 0 when n === 0", function () { 8 | index.fibonacci(0).should.equal(0); 9 | }) 10 | 11 | it("should equal 1 when n === 1", function () { 12 | index.fibonacci(1).should.equal(1); 13 | }) 14 | 15 | it("should equal 55 when n === 10", function () { 16 | index.fibonacci(10).should.equal(55); 17 | }); 18 | 19 | it("should throw when n > 10", function () { 20 | (function () { 21 | index.fibonacci(11); 22 | }).should.throw("n should <= 10"); 23 | }); 24 | 25 | it("should throw when n < 0", function () { 26 | (function () { 27 | index.fibonacci(-1); 28 | }).should.throw("n should >= 0"); 29 | }); 30 | 31 | it("should throw when n isnt Number", function () { 32 | (function () { 33 | index.fibonacci("hehe"); 34 | }).should.throw("n should be a number"); 35 | }); 36 | 37 | }); 38 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/jquery-bootstrap/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | jQuery Integration 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/jquery-mobile/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | jQuery Mobile React Example 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /css-layout/float/float-3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | float test 5 | 6 | 20 | 21 | 22 |
23 | 31 |
32 | 独坐幽篁里,弹琴复长啸。深林人不知,明月来相照。 33 |
34 |
35 | 这是一首描写和赞美深秋山林景色的小诗。 36 | 首句“远上寒山石径斜”,由下而上,写一条石头小路蜿蜒曲折地伸向充满秋意的山峦。“寒”字点明深秋季节;“远”字写出山路的绵长;“斜”字照应句首的“远”字,写出了高而缓的山势。由于坡度不大,故可乘车游山。 37 | 次句“白云生处有人家”,描写诗人山行时所看到的远处风光。一个“生”字,形象地表现了白云升腾、缭绕和飘浮种种动态,也说明山很高。“有人家”三字会使人联想到炊烟袅袅,鸡鸣犬吠,从而感到深山充满生气,没有一点儿死寂的恐怖。“有人家”三字还照应了上句中的“石径”,因为这“石径”便是山里居民的通道。 38 |
39 |
GG
40 |
41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /learn-html5/5.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 13 | 14 | html5 canvas 15 | 16 | 17 |
18 | index 19 | 20 |
21 | 22 | 23 | 24 | 25 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /simple-blog/views/header.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Blog 6 | 7 | 8 | 9 | 10 |
11 |

<%= title %>

12 |
13 | 14 | 29 | 30 |
31 | <% if (success) { %> 32 |
<%= success %>
33 | <% } %> 34 | <% if (error) { %> 35 |
<%= error %>
36 | <% } %> 37 | -------------------------------------------------------------------------------- /react/react-tutorial/public/css/base.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: #fff; 3 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 4 | font-size: 15px; 5 | line-height: 1.7; 6 | margin: 0; 7 | padding: 30px; 8 | } 9 | 10 | a { 11 | color: #4183c4; 12 | text-decoration: none; 13 | } 14 | 15 | a:hover { 16 | text-decoration: underline; 17 | } 18 | 19 | code { 20 | background-color: #f8f8f8; 21 | border: 1px solid #ddd; 22 | border-radius: 3px; 23 | font-family: "Bitstream Vera Sans Mono", Consolas, Courier, monospace; 24 | font-size: 12px; 25 | margin: 0 2px; 26 | padding: 0px 5px; 27 | } 28 | 29 | h1, h2, h3, h4 { 30 | font-weight: bold; 31 | margin: 0 0 15px; 32 | padding: 0; 33 | } 34 | 35 | h1 { 36 | border-bottom: 1px solid #ddd; 37 | font-size: 2.5em; 38 | font-weight: bold; 39 | margin: 0 0 15px; 40 | padding: 0; 41 | } 42 | 43 | h2 { 44 | border-bottom: 1px solid #eee; 45 | font-size: 2em; 46 | } 47 | 48 | h3 { 49 | font-size: 1.5em; 50 | } 51 | 52 | h4 { 53 | font-size: 1.2em; 54 | } 55 | 56 | p, ul { 57 | margin: 15px 0; 58 | } 59 | 60 | ul { 61 | padding-left: 30px; 62 | } 63 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/shared/css/base.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: #fff; 3 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;; 4 | font-size: 15px; 5 | line-height: 1.7; 6 | margin: 0; 7 | padding: 30px; 8 | } 9 | 10 | a { 11 | color: #4183c4; 12 | text-decoration: none; 13 | } 14 | 15 | a:hover { 16 | text-decoration: underline; 17 | } 18 | 19 | code { 20 | background-color: #f8f8f8; 21 | border: 1px solid #ddd; 22 | border-radius: 3px; 23 | font-family: "Bitstream Vera Sans Mono", Consolas, Courier, monospace; 24 | font-size: 12px; 25 | margin: 0 2px; 26 | padding: 0px 5px; 27 | } 28 | 29 | h1, h2, h3, h4 { 30 | font-weight: bold; 31 | margin: 0 0 15px; 32 | padding: 0; 33 | } 34 | 35 | h1 { 36 | border-bottom: 1px solid #ddd; 37 | font-size: 2.5em; 38 | font-weight: bold; 39 | margin: 0 0 15px; 40 | padding: 0; 41 | } 42 | 43 | h2 { 44 | border-bottom: 1px solid #eee; 45 | font-size: 2em; 46 | } 47 | 48 | h3 { 49 | font-size: 1.5em; 50 | } 51 | 52 | h4 { 53 | font-size: 1.2em; 54 | } 55 | 56 | p, ul { 57 | margin: 15px 0; 58 | } 59 | 60 | ul { 61 | padding-left: 30px; 62 | } 63 | -------------------------------------------------------------------------------- /c/BubbleSort.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void BubbleSort(int a[], int n) { 4 | int i, j, temp; 5 | int num = 0; 6 | for(i=0; i a[j+1]) 12 | { 13 | temp = a[j]; 14 | a[j] = a[j+1]; 15 | a[j+1] = temp; 16 | } 17 | } 18 | } 19 | printf("1, compare counts = %d\n", num); 20 | } 21 | 22 | void BubbleSort2(int array[], int len) { 23 | int exchange = len - 1; 24 | int num = 0; 25 | int i = 0; 26 | 27 | while(exchange) { 28 | int bound = exchange; 29 | exchange = 0; 30 | 31 | for(i=0; i array[i+1]) { 34 | int temp = array[i]; 35 | array[i] = array[i+1]; 36 | array[i+1] = temp; 37 | exchange = i; 38 | } 39 | } 40 | } 41 | printf("2, compare counts = %d\n", num); 42 | } 43 | 44 | int main(void) { 45 | int array1[10] = {4, 7, 2, 6, 1, 12, 0, 36, 21, 17}; 46 | int array2[10] = {4, 7, 2, 6, 1, 12, 0, 36, 21, 17}; 47 | 48 | BubbleSort(array1, 10); 49 | BubbleSort2(array2, 10); 50 | 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /css-layout/position/position.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | float test 5 | 6 | 22 | 23 | 24 |
25 | 33 |
34 | 独坐幽篁里,弹琴复长啸。深林人不知,明月来相照。 35 |
36 |
37 | 这是一首描写和赞美深秋山林景色的小诗。 38 | 首句“远上寒山石径斜”,由下而上,写一条石头小路蜿蜒曲折地伸向充满秋意的山峦。“寒”字点明深秋季节;“远”字写出山路的绵长;“斜”字照应句首的“远”字,写出了高而缓的山势。由于坡度不大,故可乘车游山。 39 | 次句“白云生处有人家”,描写诗人山行时所看到的远处风光。一个“生”字,形象地表现了白云升腾、缭绕和飘浮种种动态,也说明山很高。“有人家”三字会使人联想到炊烟袅袅,鸡鸣犬吠,从而感到深山充满生气,没有一点儿死寂的恐怖。“有人家”三字还照应了上句中的“石径”,因为这“石径”便是山里居民的通道。 40 |
41 |
GG
42 |
43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /react/README.md: -------------------------------------------------------------------------------- 1 | ###目录简介 2 | 3 | - react-0.13.3 官方网站下载的react包,包含一些例子和react库 4 | - react-tutorial 来自[reactjs.cn](http://reactjs.cn/react/docs/tutorial.html)的评论框例子 5 | - react-trader 一个使用Node.js+Socket.io+React.js的股市数据模拟展示例子来自[coenraets](http://coenraets.org/blog/2015/03/real-time-trader-desktop-with-react-node-js-and-socket-io/) 6 | 7 | 其余的一些小文件为学习中测试的例子 8 | 9 | ###运行方法及演示 10 | 11 | ####react-tutorial 12 | 13 | `说明` 14 | 目录中包含多个简单的“服务器”, 使用随便选择一个你使用过的后端即可。服务器中已经内置好了一些操作,所以不需要懂得后端,或者不必分散精力去编写后端代码,在评论区编写的内容会被提交到`comment.json`文件中,同样,`comment.json`中的内容发生变化,也会及时的反馈到界面 15 | 16 | 17 | ```python 18 | python server.py 19 | ``` 20 | 21 | 访问[http://127.0.0.1/](http://127.0.0.1/) 22 | 23 | 24 | ![http://ishell-imgs.b0.upaiyun.com/github/react-commend-1.gif](http://ishell-imgs.b0.upaiyun.com/github/react-commend-1.gif) 25 | 26 | 27 | ####react-trader 28 | 29 | `说明` 30 | 这是一个运用`Node.js`, `Socket.io`, `React.js`的综合例子,一个模拟股票参数的网页应用 31 | 32 | ``` 33 | npm install 34 | node server.js 35 | ``` 36 | 37 | 访问[http://127.0.0.1/](http://127.0.0.1/) 38 | 39 | ![http://ishell-imgs.b0.upaiyun.com/github/react-trader.gif](http://ishell-imgs.b0.upaiyun.com/github/react-trader.gif) 40 | 41 | -------------------------------------------------------------------------------- /simple-blog/models/comment.js: -------------------------------------------------------------------------------- 1 | var mongodb = require('./db'); 2 | 3 | function Comment(name, day, title, comment) { 4 | this.name = name; 5 | this.day = day; 6 | this.title = title; 7 | this.comment = comment; 8 | } 9 | 10 | module.exports = Comment; 11 | 12 | //存储一条留言信息 13 | Comment.prototype.save = function(callback) { 14 | var name = this.name, 15 | day = this.day, 16 | title = this.title, 17 | comment = this.comment; 18 | //打开数据库 19 | mongodb.open(function (err, db) { 20 | if (err) { 21 | return callback(err); 22 | } 23 | //读取 posts 集合 24 | db.collection('posts', function (err, collection) { 25 | if (err) { 26 | mongodb.close(); 27 | return callback(err); 28 | } 29 | //通过用户名、时间及标题查找文档,并把一条留言对象添加到该文档的 comments 数组里 30 | collection.update({ 31 | "name": name, 32 | "time.day": day, 33 | "title": title 34 | }, { 35 | $push: {"comments": comment} 36 | } , function (err) { 37 | mongodb.close(); 38 | if (err) { 39 | return callback(err); 40 | } 41 | callback(null); 42 | }); 43 | }); 44 | }); 45 | }; 46 | -------------------------------------------------------------------------------- /react/react-tutorial/README.md: -------------------------------------------------------------------------------- 1 | [![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy) 2 | 3 | # React Tutorial 4 | 5 | This is the React comment box example from [the React tutorial](http://facebook.github.io/react/docs/tutorial.html). 6 | 7 | ## To use 8 | 9 | There are several simple server implementations included. They all serve static files from `public/` and handle requests to `comments.json` to fetch or add data. Start a server with one of the following: 10 | 11 | ### Node 12 | 13 | ```sh 14 | npm install 15 | node server.js 16 | ``` 17 | 18 | ### Python 19 | 20 | ```sh 21 | pip install -r requirements.txt 22 | python server.py 23 | ``` 24 | 25 | ### Haskell 26 | 27 | ```sh 28 | cabal sandbox init 29 | cabal install --only-dependencies 30 | ghc Server.hs 31 | ./Server 32 | ``` 33 | 34 | ### Ruby 35 | ```sh 36 | ruby server.rb 37 | ``` 38 | 39 | ### PHP 40 | ```sh 41 | php server.php 42 | ``` 43 | 44 | ### Go 45 | ```sh 46 | go run server.go 47 | ``` 48 | 49 | ### Lua 50 | 51 | ```sh 52 | go get github.com/xyproto/algernon 53 | # or brew install algernon 54 | algernon server.lua 55 | ``` 56 | 57 | And visit . Try opening multiple tabs! 58 | -------------------------------------------------------------------------------- /css-layout/float/float-4.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | float test(inline-block) 5 | 6 | 33 | 34 | 35 |
36 |
37 |
38 |
39 |
40 |
hello, I'am after-box
41 | 42 |
43 |
44 |
45 |
46 |
47 |
hello, I'am after-box
48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /react/js/app.js: -------------------------------------------------------------------------------- 1 | var CheckLink = React.createClass({ 2 | render: function() { 3 | // 这样会把 CheckList 所有的 props 复制到 4 | return {'√ '}{this.props.children}; 5 | } 6 | }); 7 | 8 | var LikeButton = React.createClass({ 9 | getInitialState: function () { 10 | return {liked: false}; 11 | }, 12 | handleClick: function () { 13 | this.setState({liked: !this.state.liked}, function () { 14 | console.log("console-31031"); 15 | }); 16 | }, 17 | render: function () { 18 | var text = this.state.liked ? 'like': 'haven\'t like'; 19 | return ( 20 |

21 | You {text} this. Click to toggle 22 |

23 | ); 24 | } 25 | }); 26 | 27 | var HomePage = React.createClass({ 28 | render: function () { 29 | return ( 30 |
31 |
The time is: {this.props.date.toTimeString()}
32 | 33 | 34 | Click here! 35 | 36 |
37 | ); 38 | } 39 | }); 40 | 41 | 42 | setInterval(function () { 43 | React.render( 44 | , 45 | document.getElementById("content")); 46 | }, 500); 47 | -------------------------------------------------------------------------------- /py/logbook-demo/163_mail_handler.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from logbook import Logger, MailHandler 4 | import logbook 5 | import sys 6 | 7 | sender = 'Logger' 8 | recipients = ['123456@qq.com'] 9 | email_user = 'sender@163.com' 10 | email_pass = 'password' 11 | 12 | mail_handler = MailHandler(sender, recipients, 13 | server_addr='smtp.163.com', 14 | starttls=True, 15 | secure = False, 16 | credentials=(email_user, email_pass), 17 | format_string=u'''\ 18 | Subject: {record.level_name} on My Application 19 | 20 | Message type: {record.level_name} 21 | Location: {record.filename}:{record.lineno} 22 | Module: {record.module} 23 | Function: {record.func_name} 24 | Time: {record.time:%Y-%m-%d %H:%M:%S} 25 | Remote IP: {record.extra[ip]} 26 | Request: {record.extra[url]} [{record.extra[method]}] 27 | Message: {record.message} 28 | ''', 29 | bubble=True) 30 | 31 | log = Logger('test') 32 | 33 | def main(): 34 | log.info('something logging') 35 | 36 | if __name__ == '__main__': 37 | with mail_handler.threadbound(): 38 | main() 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /py/logbook-demo/qq_mail_handler.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from logbook import Logger, MailHandler 4 | import logbook 5 | import sys 6 | 7 | sender = 'Logger' 8 | recipients = ['123456@qq.com'] 9 | email_user = 'sender@qq.com' 10 | email_pass = 'adpamkzzsppgnasgac' 11 | 12 | mail_handler = MailHandler(sender, recipients, 13 | server_addr='smtp.qq.com', 14 | starttls=False, 15 | secure = True, 16 | credentials=(email_user, email_pass), 17 | format_string=u'''\ 18 | Subject: {record.level_name} on My Application 19 | 20 | Message type: {record.level_name} 21 | Location: {record.filename}:{record.lineno} 22 | Module: {record.module} 23 | Function: {record.func_name} 24 | Time: {record.time:%Y-%m-%d %H:%M:%S} 25 | Remote IP: {record.extra[ip]} 26 | Request: {record.extra[url]} [{record.extra[method]}] 27 | Message: {record.message} 28 | ''', 29 | bubble=True) 30 | 31 | log = Logger('test') 32 | 33 | def main(): 34 | log.info('something logging') 35 | 36 | if __name__ == '__main__': 37 | with mail_handler.threadbound(): 38 | main() 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /py/dragspeed_compare/use-asyncio.py: -------------------------------------------------------------------------------- 1 | #!/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import asyncio 5 | import aiohttp 6 | import bs4 7 | import tqdm 8 | 9 | 10 | urls = [] 11 | with open('urls.txt', 'r') as f: 12 | for url in f: 13 | urls.append(url.strip()) 14 | 15 | 16 | @asyncio.coroutine 17 | def get(*args, **kwargs): 18 | response = yield from aiohttp.request('GET', *args, **kwargs) 19 | return (yield from response.text()) 20 | 21 | 22 | @asyncio.coroutine 23 | def wait_with_progress(coros): 24 | for f in tqdm.tqdm(asyncio.as_completed(coros), total=len(coros)): 25 | yield from f 26 | 27 | 28 | def parser_title(page): 29 | soup = bs4.BeautifulSoup(page, 'lxml') 30 | a = soup.find('div', 'report-title') 31 | return a.text.strip() 32 | 33 | 34 | @asyncio.coroutine 35 | def print_title(url): 36 | with (yield from sem): 37 | page = yield from get(url, compress=True) 38 | title = parser_title(page) 39 | print('{}: {}'.format(url, title)) 40 | 41 | 42 | sem = asyncio.Semaphore(5) 43 | loop = asyncio.get_event_loop() 44 | f = asyncio.wait([print_title(url) for url in urls]) 45 | #f = wait_with_progress([print_title(url) for url in urls]) 46 | loop.run_until_complete(f) 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /py/server-side-y2b-connect-speed-screenshot.py: -------------------------------------------------------------------------------- 1 | #!/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # use: https://blog.ishell.me/a/you2be-connection-speed.html 5 | 6 | from selenium import webdriver 7 | from selenium.webdriver.common.keys import Keys 8 | from selenium.webdriver.common.action_chains import ActionChains 9 | import time 10 | 11 | profile = webdriver.FirefoxProfile() 12 | profile.add_extension('/root/downloads/addon-328839-latest.xpi') 13 | profile.set_preference("extensions.y2bautohd.currentVersion", "49.1") 14 | 15 | driver = webdriver.Firefox(firefox_profile=profile) 16 | 17 | #driver = webdriver.Firefox() 18 | 19 | 20 | driver.get('https://www.youtube.com/watch?v=TmDKbUrSYxQ') 21 | driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + Keys.TAB) 22 | 23 | driver.get('https://www.youtube.com/watch?v=TmDKbUrSYxQ') 24 | time.sleep(30) 25 | 26 | ele = driver.find_element_by_id('movie_player') 27 | action_chains = ActionChains(driver) 28 | action_chains.move_to_element_with_offset(ele, 100, 100).context_click().perform() 29 | time.sleep(3) 30 | 31 | driver.find_element_by_xpath('//div[text() = "Stats for nerds"]').click() 32 | time.sleep(3) 33 | 34 | img_name = str(time.time())[0:10] + '.png' 35 | driver.save_screenshot('/root/downloads/'+img_name) 36 | 37 | -------------------------------------------------------------------------------- /sh/JPG2jpg.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Usage: ./low.sh <-l | -u> 3 | #./low.sh -l directory 为全部转化为小写 4 | #./low.sh -u directory 为全部转化为大写 5 | # 6 | # 第二形参必须是目录,第一形参指定-l或-u 7 | # 8 | if [ $# -ne 2 ] ; then 9 | echo "Usage: ${0} <-l | -u> " 10 | exit 1 11 | fi 12 | if [ ! -d ${2} -o "${1}" != "-l" -a "${1}" != "-u" ] ; then 13 | echo "Usage: ${0} <-l | -u> " 14 | exit 1 15 | fi 16 | dir=`dirname "${2}"` 17 | cd ${dir} > /dev/null 2>&1 18 | if [ $? -ne 0 ] ; then 19 | echo "Error: checking your ${dir}" 20 | exit 1 21 | fi 22 | exec 1>/dev/null 2>&1 23 | if [ "${1}" = "-l" ] ; then 24 | base=`basename "${2}" | tr "[A-Z]" "[a-z]"` 25 | else 26 | base=`basename "${2}" | tr "[a-z]" "[A-Z]"` 27 | fi 28 | mv -f "`basename ${2}`" "${base}" > /dev/null 2>&1 29 | for entry in `find ${base}` 30 | do 31 | before="." 32 | for after in `echo "${entry}" | sed -e 's,/, ,g'` 33 | do 34 | tmp_entry="${before}/${after}" 35 | if [ "${1}" = "-l" ] ; then 36 | before=`echo "${tmp_entry}" | tr "[A-Z]" "[a-z]"` 37 | else 38 | before=`echo "${tmp_entry}" | tr "[a-z]" "[A-Z]"` 39 | fi 40 | mv -f "${tmp_entry}" "${before}" 41 | done 42 | done 43 | fi 44 | done 45 | done 46 | fi 47 | -------------------------------------------------------------------------------- /ant-test/css/style.css: -------------------------------------------------------------------------------- 1 | header { 2 | width: 100%; 3 | background-color: #fff; 4 | border-bottom: 1px solid #eee; 5 | font-size: 16px; 6 | } 7 | 8 | /* 清除浮动 */ 9 | .clearfix:before,.clearfix:after{ 10 | content:""; 11 | display:table; 12 | } 13 | .clearfix:after{clear:both;} 14 | .clearfix{ 15 | *zoom:1; /*IE/7/6*/ 16 | } 17 | 18 | .logo img { 19 | float: left; 20 | margin-top: -7px; 21 | } 22 | 23 | a.logo { 24 | float: left; 25 | height: 46px; 26 | line-height: 46px; 27 | margin: 17px 48px 17px 40px; 28 | font-size: 18px; 29 | } 30 | 31 | .main-wrapper { 32 | background-color: #fff; 33 | } 34 | 35 | .aside-container { 36 | width: 260px; 37 | /*background-color: #F9F9F9;*/ 38 | padding-top: 30px; 39 | padding-bottom: 50px; 40 | float: left; 41 | border-right: 1px solid #eee; 42 | } 43 | 44 | .aside-container li a { 45 | line-height: 40px; 46 | height: 40px; 47 | color: #5C6B76; 48 | } 49 | 50 | .aside-container > ul > li > a { 51 | padding-left: 90px; 52 | font-size: 14px; 53 | } 54 | 55 | ul, li { 56 | list-style: none; 57 | } 58 | 59 | a { 60 | color: 61 | } 62 | 63 | .main-container { 64 | margin-left: 260px; 65 | padding: 30px 40px 120px; 66 | background-color: #fff; 67 | min-height: 500px; 68 | } 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 不忘初心,方得始终 6 | 36 | 37 | 38 |
39 | Soli Deo Gloria 40 |
41 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/basic-jsx-precompile/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Basic Example with Precompiled JSX 6 | 7 | 8 | 9 |

Basic Example with Precompiled JSX

10 |
11 |

12 | If you can see this, React is not running. Try running: 13 |

14 |
npm install -g react-tools
15 | cd examples/basic-jsx-precompile/
16 | jsx . build/
17 |
18 |

Example Details

19 |

This is written with JSX in a separate file and precompiled to vanilla JS by running:

20 |
npm install -g react-tools
21 | cd examples/basic-jsx-precompile/
22 | jsx . build/
23 |

24 | Learn more about React at 25 | facebook.github.io/react. 26 |

27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /py/sort/bubble_sort.py: -------------------------------------------------------------------------------- 1 | #!/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import random 5 | import copy 6 | 7 | 8 | def bubble(data): 9 | 10 | ''' 11 | 冒泡排序(bubble sort) 12 | ''' 13 | 14 | count = 0 15 | for i in range(len(data)-1, 0, -1): 16 | for j in range(0, i): 17 | count = count + 1 18 | if data[j] > data[j+1]: 19 | data[j+1], data[j] = data[j], data[j+1] 20 | 21 | return (data, count) 22 | 23 | 24 | def bubble2(data): 25 | 26 | ''' 27 | 冒泡排序- 优化(bubble sort) 28 | 当内层j循环一遍没有发生交换时,排序已经完成,设立exchange判断并跳出 29 | ''' 30 | 31 | count = 0 32 | for i in range(len(data)-1, 0, -1): 33 | exchange = False 34 | for j in range(0, i): 35 | count = count + 1 36 | if data[j] > data[j+1]: 37 | data[j+1], data[j] = data[j], data[j+1] 38 | exchange = True 39 | 40 | if not exchange: 41 | return (data, count) 42 | 43 | return (data, count) 44 | 45 | 46 | 47 | if __name__ == '__main__': 48 | 49 | data = random.sample(range(100), 6) 50 | #data = [1, 2, 3, 4, 5, 6] # 当有序时,冒泡排序的最佳时间复杂度为O(n) 51 | #data = [1, 2, 3, 4, 5, 6][::-1] 52 | data2 = copy.deepcopy(data) 53 | 54 | print(data) 55 | print(bubble(data)) 56 | print(bubble2(data2)) 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /react/react-tutorial/server.lua: -------------------------------------------------------------------------------- 1 | -- This file provided by Facebook is for non-commercial testing and evaluation 2 | -- purposes only. Facebook reserves all rights not expressly granted. 3 | -- 4 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 5 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 6 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 7 | -- FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 8 | -- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 9 | -- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE 10 | 11 | -- 12 | -- For use with Algernon / Lua 13 | -- 14 | -- Project page: https://github.com/xyproto/algernon 15 | -- Web page: http://algernon.roboticoverlords.org/ 16 | -- 17 | 18 | handle("/comments.json", function() 19 | 20 | -- Set the headers 21 | content("application/javascript") 22 | setheader("Cache-Control", "no-cache") 23 | 24 | -- Use a JSON file for the comments 25 | comments = JFile("comments.json") 26 | 27 | -- Handle requests 28 | if method() == "POST" then 29 | -- Add the form data table to the JSON document 30 | comments:add(ToJSON(formdata(), 4)) 31 | end 32 | 33 | -- Return the contents of the JSON file 34 | print(tostring(comments)) 35 | 36 | end) 37 | 38 | servedir("/", "public") 39 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/basic-commonjs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Basic CommonJS Example with Browserify 6 | 7 | 8 | 9 |

Basic CommonJS Example with Browserify

10 |
11 |

12 | To install React, follow the instructions on 13 | GitHub. 14 |

15 |

16 | If you can see this, React is not working right. 17 | If you checked out the source from GitHub make sure to run grunt. 18 |

19 |
20 |

Example Details

21 |

This is written with JSX in a CommonJS module and precompiled to vanilla JS by running:

22 |
browserify --debug --transform reactify index.js > bundle.js
23 |

24 | Learn more about React at 25 | facebook.github.io/react. 26 |

27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/quadratic/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Quadratic Formula Calculator 6 | 7 | 8 | 9 |

Quadratic Formula Calculator

10 |
11 |

12 | If you can see this, React is not working right. This is probably because you're viewing 13 | this on your file system instead of a web server. Try running 14 |

15 |           python -m SimpleHTTPServer
16 |         
17 | and going to http://localhost:8000/. 18 |

19 |
20 |

Example Details

21 |

This is written with JSX in a separate file and transformed in the browser.

22 |

23 | Learn more about React at 24 | facebook.github.io/react. 25 |

26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /react/react-trader/server.js: -------------------------------------------------------------------------------- 1 | var express = require('express'), 2 | app = express(), 3 | path = require('path'), 4 | http = require('http').Server(app), 5 | io = require('socket.io')(http), 6 | feed = require('./feed'); 7 | 8 | app.use(express.static(path.join(__dirname, './www'))); 9 | 10 | io.on('connection', function (socket) { 11 | console.log('User connected. Socket id %s', socket.id); 12 | 13 | socket.on('join', function (rooms) { 14 | console.log('Socket %s subscribed to %s', socket.id, rooms); 15 | if (Array.isArray(rooms)) { 16 | rooms.forEach(function(room) { 17 | socket.join(room); 18 | }); 19 | } else { 20 | socket.join(rooms); 21 | } 22 | }); 23 | 24 | socket.on('leave', function (rooms) { 25 | console.log('Socket %s unsubscribed from %s', socket.id, rooms); 26 | if (Array.isArray(rooms)) { 27 | rooms.forEach(function(room) { 28 | socket.leave(room); 29 | }); 30 | } else { 31 | socket.leave(rooms); 32 | } 33 | }); 34 | 35 | socket.on('disconnect', function () { 36 | console.log('User disconnected. %s. Socket id %s', socket.id); 37 | }); 38 | }); 39 | 40 | feed.start(function(room, type, message) { 41 | io.to(room).emit(type, message); 42 | }); 43 | 44 | http.listen(3000, function () { 45 | console.log('listening on: 3000'); 46 | }); 47 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/basic-jsx-external/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Basic Example with External JSX 6 | 7 | 8 | 9 | 10 |

Basic Example with External JSX

11 |
12 |

13 | If you can see this, React is not working right. This is probably because you're viewing 14 | this on your file system instead of a web server. Try running 15 |

16 |           python -m SimpleHTTPServer
17 |         
18 | and going to http://localhost:8000/. 19 |

20 |
21 |

Example Details

22 |

This is written with JSX in a separate file and transformed in the browser.

23 |

24 | Learn more about React at 25 | facebook.github.io/react. 26 |

27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /react/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Learn React! 5 | 6 | 7 | 63 | 64 | 65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /react/react-tutorial/server.py: -------------------------------------------------------------------------------- 1 | # This file provided by Facebook is for non-commercial testing and evaluation 2 | # purposes only. Facebook reserves all rights not expressly granted. 3 | # 4 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 5 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 6 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 7 | # FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 8 | # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 9 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | import json 12 | import os 13 | from flask import Flask, Response, request 14 | 15 | app = Flask(__name__, static_url_path='', static_folder='public') 16 | app.add_url_rule('/', 'root', lambda: app.send_static_file('index.html')) 17 | 18 | @app.route('/comments.json', methods=['GET', 'POST']) 19 | def comments_handler(): 20 | 21 | with open('comments.json', 'r') as file: 22 | comments = json.loads(file.read()) 23 | 24 | if request.method == 'POST': 25 | comments.append(request.form.to_dict()) 26 | 27 | with open('comments.json', 'w') as file: 28 | file.write(json.dumps(comments, indent=4, separators=(',', ': '))) 29 | 30 | return Response(json.dumps(comments), mimetype='application/json', headers={'Cache-Control': 'no-cache'}) 31 | 32 | if __name__ == '__main__': 33 | app.run(port=int(os.environ.get("PORT",3000))) 34 | -------------------------------------------------------------------------------- /css-layout/top-bar/css/style.css_bak: -------------------------------------------------------------------------------- 1 | html { 2 | box-sizing: border-box; 3 | font-size: 62.5%; 4 | } 5 | 6 | body { 7 | font-size: 1.6em; 8 | } 9 | 10 | .wrapper { 11 | margin: 0; 12 | padding: 0; 13 | } 14 | 15 | .container { 16 | padding-top: 7.5rem; 17 | padding-bottom: 7.5rem; 18 | margin-bottom: 0; 19 | max-width: 80.0rem; 20 | } 21 | 22 | .navigation { 23 | background: #f4f5f6; 24 | border-bottom: .1rem solid #d1d1d1; 25 | display: block; 26 | height: 5.2rem; 27 | width: 100%; 28 | } 29 | 30 | .navigation .container { 31 | box-sizing: border-box; 32 | margin: 0 auto; 33 | padding-top: 0; 34 | padding-bottom: 0; 35 | position: relative; 36 | width: 100%; 37 | } 38 | 39 | .navigation .title, .navigation-title { 40 | color: #606c76; 41 | font-family: 'Gotham Rounded A', 'Gotham Rounded B', 'Helvetica Neue', Arial, sans-serif; 42 | display: inline; 43 | line-height: 5.2rem; 44 | font-size: 1.6rem; 45 | letter-spacing: -0.1rem; 46 | padding: 0; 47 | } 48 | 49 | .navigation img { 50 | position: relative; 51 | top: .4rem; 52 | height: 2.0rem; 53 | } 54 | 55 | .navigation-list { 56 | list-style: none; 57 | /* line-height: 5.2rem; */ 58 | /* margin-top: 1.4rem; */ 59 | margin-bottom: 0; 60 | } 61 | 62 | .navigation-item { 63 | position: relative; 64 | float: left; 65 | margin-left: 2.5rem; 66 | margin-right: 0; 67 | margin-bottom: 0; 68 | } 69 | 70 | .navigation-link { 71 | line-height: 5.2rem; 72 | font-size: 1.6rem; 73 | /* float: left; */ 74 | } 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /py/pymongo-1/test.py: -------------------------------------------------------------------------------- 1 | #!/bin/env python 2 | #encoding:utf-8 3 | import os 4 | import pymongo 5 | 6 | DATA_DIR = 'data' 7 | 8 | # 连接数据库 9 | conn = pymongo.Connection('127.0.0.1', 27017) 10 | #conn = pymongo.Connection('115.28.55.217', 27017) 11 | db = conn.haha 12 | 13 | 14 | db.users.remove() 15 | 16 | # Insert & Save 17 | db.users.insert({'name': 'user1', 'age': 16, 'index': 1}) 18 | db.users.insert({'name': 'user2', 'age': 17, 'index': 2}) 19 | db.users.insert({'name': 'user3', 'age': 18, 'index': 3}) 20 | db.users.save({'name': 'user4', 'age': 19, 'index': 4}) 21 | 22 | # Update 23 | db.users.update({'name':'user1'}, {'$set': {'age': 20}}) 24 | json = { 25 | 'age':20 26 | } 27 | db.users.update({'name':'user2'}, {'$set': json}) 28 | 29 | # Upsert 30 | db.users.update({'name':'user5'}, {'$set': {'age': 22}, '$setOnInsert': {'index':5}}, upsert=True) 31 | 32 | json = { 33 | 'age':36 34 | } 35 | name = 'user5' 36 | db.users.update({'name':name}, {'$set': json, '$setOnInsert': {'index':5}}, upsert=True) 37 | 38 | # ---------------------------------------------------- 39 | update_json = { 40 | 'nickname': 'hahahaha', 41 | 'title': 'biaoti', 42 | 'desc': 'miaoshu', 43 | 'index': 36 44 | } 45 | 46 | init_json = { 47 | 'score': 0, 48 | 'count': 0, 49 | 'courses': [], 50 | 'meta':{ 51 | 'createAt':'', 52 | 'updateAt':'' 53 | } 54 | } 55 | nickname = 'user6' 56 | db.users.update({'nickname': nickname}, {'$set':update_json, '$setOnInsert': init_json}, upsert=True) 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /react/react-tutorial/server.rb: -------------------------------------------------------------------------------- 1 | # This file provided by Facebook is for non-commercial testing and evaluation 2 | # purposes only. Facebook reserves all rights not expressly granted. 3 | # 4 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 5 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 6 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 7 | # FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 8 | # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 9 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | require 'webrick' 12 | require 'json' 13 | 14 | port = ENV['PORT'].nil? ? 3000 : ENV['PORT'].to_i 15 | 16 | puts "Server started: http://localhost:#{port}/" 17 | 18 | root = File.expand_path './public' 19 | server = WEBrick::HTTPServer.new :Port => port, :DocumentRoot => root 20 | 21 | server.mount_proc '/comments.json' do |req, res| 22 | comments = JSON.parse(File.read('./comments.json')) 23 | 24 | if req.request_method == 'POST' 25 | # Assume it's well formed 26 | comment = {} 27 | req.query.each do |key, value| 28 | comment[key] = value.force_encoding('UTF-8') 29 | end 30 | comments << comment 31 | File.write('./comments.json', JSON.pretty_generate(comments, :indent => ' ')) 32 | end 33 | 34 | # always return json 35 | res['Content-Type'] = 'application/json' 36 | res['Cache-Control'] = 'no-cache' 37 | res.body = JSON.generate(comments) 38 | end 39 | 40 | trap 'INT' do server.shutdown end 41 | 42 | server.start 43 | -------------------------------------------------------------------------------- /ant-test/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 22 |
23 | 31 |
32 |
33 |
34 |
35 |
36 |
37 | 38 | 41 | 42 | -------------------------------------------------------------------------------- /css-layout/css3/learnlayout.com/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Learn layout 5 | 55 | 56 | 57 |
58 |
59 |
60 |
61 |
62 |
63 | 111111111111111111 64 |
65 |
66 |
67 |
68 | 2333, hello I am fixed! 69 | 2333, hello I am fixed! 70 | 2333, hello I am fixed! 71 |
72 |
73 |
74 | This is relative 75 |
This is absolute
76 |
77 | 78 | -------------------------------------------------------------------------------- /py/bs4-demo.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from bs4 import BeautifulSoup 4 | import re 5 | import os 6 | 7 | bodyStr = ''' 8 | 9 |

Dispatched £34.99

10 |

Order Number: 78207165

11 |

Order Date: 04/10/16

12 |
13 | ''' 14 | 15 | soup = BeautifulSoup(bodyStr, 'html.parser') 16 | 17 | # accountOrder.account?order=78207165 18 | print '------------------' 19 | print soup.a['href'] 20 | print soup.a.get('href') 21 | print soup.find('a', 'orderCard_cardAsLink')['href'] 22 | print soup('a', 'orderCard_cardAsLink')[0]['href'] 23 | print soup.find_all('a', 'orderCard_cardAsLink')[0]['href'] 24 | print soup.find(class_='orderCard_cardAsLink')['href'] 25 | print soup.find(class_='orderCard_cardAsLink').get('href') 26 | print soup.select('a')[0]['href'] 27 | print soup.select('a[href*="order="]')[0]['href'] 28 | 29 | # Order Number: 78207165 30 | print '------------------' 31 | print soup.find(text=re.compile('Order Number')) 32 | print soup.find(class_='orderCard_text').string 33 | print soup.find(class_='orderCard_orderStatus').find_next('p').string 34 | print soup.find_all(class_='orderCard_text')[0].string 35 | print soup.select('p:nth-of-type(2)')[0].string 36 | print soup.select('.orderCard_cardAsLink p:nth-of-type(2)')[0].string 37 | 38 | # Dispatched 39 | print '------------------' 40 | print soup.find('p', 'orderCard_orderStatus').text.strip() 41 | 42 | span_ele = soup.find('span') 43 | span_ele.extract() 44 | print soup.find('p', 'orderCard_orderStatus').text.strip() 45 | 46 | 47 | print soup.prettify() 48 | 49 | -------------------------------------------------------------------------------- /css-layout/waterfall-flow/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 瀑布流 8 | 9 | 10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /react/react-trader/feed.js: -------------------------------------------------------------------------------- 1 | var interval, 2 | onChangeHandler; 3 | 4 | var stocks = [ 5 | {symbol: "GM", open: 38.87}, 6 | {symbol: "GE", open: 25.40}, 7 | {symbol: "MCD", open: 97.05}, 8 | {symbol: "UAL", open: 69.45}, 9 | {symbol: "WMT", open: 83.24}, 10 | {symbol: "AAL", open: 55.76}, 11 | {symbol: "LLY", open: 76.12}, 12 | {symbol: "JPM", open: 61.75}, 13 | {symbol: "BAC", open: 15.84}, 14 | {symbol: "BA", open: 154.50} 15 | ]; 16 | 17 | stocks.forEach(function(stock) { 18 | stock.last = stock.open; 19 | stock.high = stock.open; 20 | stock.low = stock.open; 21 | }); 22 | 23 | function simulateChange() { 24 | 25 | var index = Math.floor(Math.random() * stocks.length), 26 | stock = stocks[index], 27 | 28 | maxChange = stock.open * 0.005, 29 | change = maxChange - Math.random() * maxChange * 2, 30 | last; 31 | 32 | change = Math.round(change * 100) / 100; 33 | change = change === 0 ? 0.01 : change; 34 | 35 | last = stock.last + change; 36 | 37 | if (last > stock.open * 1.15 || last < stock.open * 0.85) 38 | { 39 | change = -change; 40 | last = stock.last + change; 41 | } 42 | 43 | stock.change = change; 44 | stock.last = Math.round(last * 100) / 100; 45 | if (stock.last > stock.high) { 46 | stock.high = stock.last; 47 | } 48 | if (stock.last < stock.low) { 49 | stock.low = stock.last; 50 | } 51 | onChangeHandler(stock.symbol, 'stock', stock); 52 | } 53 | 54 | function start(onChange) { 55 | onChangeHandler = onChange; 56 | interval = setInterval(simulateChange, 200); 57 | } 58 | 59 | function stop() { 60 | clearInterval(interval); 61 | } 62 | 63 | exports.start = start; 64 | exports.stop = stop; 65 | -------------------------------------------------------------------------------- /react/react-tutorial/server.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This file provided by Facebook is for non-commercial testing and evaluation 3 | * purposes only. Facebook reserves all rights not expressly granted. 4 | * 5 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 6 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 7 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 8 | * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 9 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 10 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 11 | */ 12 | 13 | var fs = require('fs'); 14 | var path = require('path'); 15 | var express = require('express'); 16 | var bodyParser = require('body-parser'); 17 | var app = express(); 18 | 19 | app.set('port', (process.env.PORT || 3000)); 20 | 21 | app.use('/', express.static(path.join(__dirname, 'public'))); 22 | app.use(bodyParser.json()); 23 | app.use(bodyParser.urlencoded({extended: true})); 24 | 25 | app.get('/comments.json', function(req, res) { 26 | fs.readFile('comments.json', function(err, data) { 27 | res.setHeader('Cache-Control', 'no-cache'); 28 | res.json(JSON.parse(data)); 29 | }); 30 | }); 31 | 32 | app.post('/comments.json', function(req, res) { 33 | fs.readFile('comments.json', function(err, data) { 34 | var comments = JSON.parse(data); 35 | comments.push(req.body); 36 | fs.writeFile('comments.json', JSON.stringify(comments, null, 4), function(err) { 37 | res.setHeader('Cache-Control', 'no-cache'); 38 | res.json(comments); 39 | }); 40 | }); 41 | }); 42 | 43 | 44 | app.listen(app.get('port'), function() { 45 | console.log('Server started: http://localhost:' + app.get('port') + '/'); 46 | }); 47 | -------------------------------------------------------------------------------- /py/v2ex_daily_mission.py: -------------------------------------------------------------------------------- 1 | #!/bin/env python 2 | #encoding:utf-8 3 | from bs4 import BeautifulSoup 4 | import requests 5 | 6 | # https://github.com/yxjxx/v2ex_daily_mission 7 | 8 | username = 'username' # your v2ex username 9 | password = 'password' # your v2ex password 10 | login_url = 'https://v2ex.com/signin' 11 | home_page = 'https://www.v2ex.com' 12 | mission_url = 'https://www.v2ex.com/mission/daily' 13 | 14 | UA = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36" 15 | 16 | headers = { 17 | "User-Agent" : UA, 18 | "Host" : "www.v2ex.com", 19 | "Referer" : "https://www.v2ex.com/signin", 20 | "Origin" : "https://www.v2ex.com" 21 | } 22 | 23 | v2ex_session = requests.Session() 24 | 25 | def make_soup(url,tag,name): 26 | page = v2ex_session.get(url,headers=headers,verify=True).text 27 | soup = BeautifulSoup(page) 28 | soup_result = soup.find(attrs = {tag:name}) 29 | # print soup_result 30 | return soup_result 31 | 32 | once_vaule = make_soup(login_url,'name','once')['value'] 33 | print(once_vaule) 34 | 35 | post_info = { 36 | 'u' : username, 37 | 'p' : password, 38 | 'once' : once_vaule, 39 | 'next' : '/' 40 | } 41 | 42 | resp = v2ex_session.post(login_url,data=post_info,headers=headers,verify=True) 43 | 44 | short_url = make_soup(mission_url, 'class', 'super normal button')['onclick'] 45 | 46 | 47 | first_quote = short_url.find("'") 48 | last_quote = short_url.find("'", first_quote+1) #str.find(str, beg=0 end=len(string)) 49 | final_url = home_page + short_url[first_quote+1:last_quote] 50 | 51 | page = v2ex_session.get(final_url,headers=headers,verify=True).content 52 | 53 | suceessful = make_soup(mission_url, 'class', 'fa fa-ok-sign') 54 | if suceessful: 55 | print ("Sucessful.") 56 | else: 57 | print ("Something wrong.") 58 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/quadratic/example.js: -------------------------------------------------------------------------------- 1 | var QuadraticCalculator = React.createClass({ 2 | getInitialState: function() { 3 | return { 4 | a: 1, 5 | b: 3, 6 | c: -4 7 | }; 8 | }, 9 | 10 | /** 11 | * This function will be re-bound in render multiple times. Each .bind() will 12 | * create a new function that calls this with the appropriate key as well as 13 | * the event. The key is the key in the state object that the value should be 14 | * mapped from. 15 | */ 16 | handleInputChange: function(key, event) { 17 | var partialState = {}; 18 | partialState[key] = parseFloat(event.target.value); 19 | this.setState(partialState); 20 | }, 21 | 22 | render: function() { 23 | var a = this.state.a; 24 | var b = this.state.b; 25 | var c = this.state.c 26 | var x1 = (-b + Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a); 27 | var x2 = (-b - Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a); 28 | return ( 29 |
30 | 31 | ax2 + bx + c = 0 32 | 33 |

Solve for x:

34 |

35 | 38 |
39 | 42 |
43 | 46 |
47 | x: {x1}, {x2} 48 |

49 |
50 | ); 51 | } 52 | }); 53 | 54 | React.render( 55 | , 56 | document.getElementById('container') 57 | ); 58 | -------------------------------------------------------------------------------- /ant-test/js/app.js: -------------------------------------------------------------------------------- 1 | //var Menu = antd.Menu; 2 | //var SubMenu = Menu.SubMenu; 3 | 4 | var Header = React.createClass({ 5 | render() { 6 | return ( 7 |
1222
8 | 新建文章 40 | 41 | 文章列表 42 | 43 | 博客设置}> 44 | Hexo设置 45 | 主题设置 46 | 47 | 关于}> 48 | 选项9 49 | 选项10 50 | 选项11 51 | 选项12 52 | 53 | ; 54 | } 55 | }); 56 | 57 | React.render(, document.getElementById('sider')); 58 | */ 59 | -------------------------------------------------------------------------------- /tumblrlikeg/scss/app.scss: -------------------------------------------------------------------------------- 1 | @import "settings"; 2 | @import "foundation"; 3 | 4 | // Or selectively include components 5 | // @import 6 | 7 | .img-panel { 8 | position: relative; 9 | padding-left: 6rem; 10 | margin-bottom: 2rem; 11 | 12 | img { 13 | position: absolute; 14 | top: 1.7rem; 15 | left: -($panel-padding * 1.5); 16 | max-width: 6rem; 17 | } 18 | } 19 | 20 | // "foundation/components/accordion", 21 | // "foundation/components/alert-boxes", 22 | // "foundation/components/block-grid", 23 | // "foundation/components/breadcrumbs", 24 | // "foundation/components/button-groups", 25 | // "foundation/components/buttons", 26 | // "foundation/components/clearing", 27 | // "foundation/components/dropdown", 28 | // "foundation/components/dropdown-buttons", 29 | // "foundation/components/flex-video", 30 | // "foundation/components/forms", 31 | // "foundation/components/grid", 32 | // "foundation/components/inline-lists", 33 | // "foundation/components/joyride", 34 | // "foundation/components/keystrokes", 35 | // "foundation/components/labels", 36 | // "foundation/components/magellan", 37 | // "foundation/components/orbit", 38 | // "foundation/components/pagination", 39 | // "foundation/components/panels", 40 | // "foundation/components/pricing-tables", 41 | // "foundation/components/progress-bars", 42 | // "foundation/components/reveal", 43 | // "foundation/components/side-nav", 44 | // "foundation/components/split-buttons", 45 | // "foundation/components/sub-nav", 46 | // "foundation/components/switches", 47 | // "foundation/components/tables", 48 | // "foundation/components/tabs", 49 | // "foundation/components/thumbs", 50 | // "foundation/components/tooltips", 51 | // "foundation/components/top-bar", 52 | // "foundation/components/type", 53 | // "foundation/components/offcanvas", 54 | // "foundation/components/visibility"; 55 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/basic-jsx-harmony/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Basic Example with JSX and ES6 features 6 | 7 | 8 | 9 |

Basic Example with JSX and ES6 features

10 |
11 |

12 | To install React, follow the instructions on 13 | GitHub. 14 |

15 |

16 | If you can see this, React is not working right. 17 | If you checked out the source from GitHub make sure to run grunt. 18 |

19 |
20 |

Example Details

21 |

This is written with JSX with Harmony (ES6) syntax and transformed in the browser.

22 |

23 | Learn more about React at 24 | facebook.github.io/react. 25 |

26 | 27 | 28 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /simple-blog/public/stylesheets/style.css: -------------------------------------------------------------------------------- 1 | /* inspired by http://yihui.name/cn/ */ 2 | *{padding:0;margin:0;} 3 | body{width:600px;margin:2em auto;padding:0 2em;font-size:14px;font-family:"Microsoft YaHei";} 4 | p{line-height:24px;margin:1em 0;} 5 | header{padding:.5em 0;border-bottom:1px solid #cccccc;} 6 | nav{float:left;font-family:"Microsoft YaHei";font-size:1.1em;text-transform:uppercase;margin-left:-12em;width:9em;text-align:right;} 7 | nav a{display:block;text-decoration:none;padding:.7em 1em;color:#000000;} 8 | nav a:hover{background-color:#ff0000;color:#f9f9f9;-webkit-transition:color .2s linear;} 9 | article{font-size:16px;padding-top:.5em;} 10 | article a{color:#dd0000;text-decoration:none;} 11 | article a:hover{color:#333333;text-decoration:underline;} 12 | .info{font-size:14px;} 13 | 14 | .edit{margin:3px;padding:2px 5px;border-radius:3px;background-color:#f3f3f3;color:#333;font-size:13px;} 15 | .edit:hover{text-decoration:none;background-color:#f00;color:#fff;-webkit-transition:color .2s linear;} 16 | 17 | .prepage a{float:left;text-decoration:none;padding:.5em 1em;color:#ff0000;font-weight:bold;} 18 | .nextpage a{float:right;text-decoration:none;padding:.5em 1em;color:#ff0000;font-weight:bold;} 19 | .prepage a:hover,.nextpage a:hover{text-decoration:none;background-color:#ff0000;color:#f9f9f9;-webkit-transition:color .2s linear;} 20 | 21 | .archive{list-style:none;line-height:28px;} 22 | .archive h3{margin:0.5em 0;} 23 | .archive time{float:left;font-size:14px;color:#999999;margin-right:1.2em;} 24 | 25 | .tag{background-color:#ff0000;border-radius:3px;font-size:14px;color:#ffffff;display:inline-block;padding:0 5px;margin-bottom:8px;} 26 | .tag:hover{text-decoration:none;background-color:#ffffff;color:#000000;-webkit-transition:color .2s linear;} 27 | 28 | .search{border:0;width:6em;text-align:center;font-size:1em;margin:0.5em 0;} 29 | 30 | .l_head{float:left;margin-left:-4em;box-shadow:0px 1px 4px #888;} 31 | .r_head{float:right;margin-top:-2.5em;box-shadow:0px 1px 4px #888;} 32 | -------------------------------------------------------------------------------- /node/speak/bin/www: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * Module dependencies. 5 | */ 6 | 7 | var app = require('../app'); 8 | var debug = require('debug')('server:server'); 9 | var http = require('http'); 10 | 11 | /** 12 | * Get port from environment and store in Express. 13 | */ 14 | 15 | var port = normalizePort(process.env.PORT || '3000'); 16 | app.set('port', port); 17 | 18 | /** 19 | * Create HTTP server. 20 | */ 21 | 22 | var server = http.createServer(app); 23 | 24 | /** 25 | * Listen on provided port, on all network interfaces. 26 | */ 27 | 28 | server.listen(port); 29 | server.on('error', onError); 30 | server.on('listening', onListening); 31 | 32 | /** 33 | * Normalize a port into a number, string, or false. 34 | */ 35 | 36 | function normalizePort(val) { 37 | var port = parseInt(val, 10); 38 | 39 | if (isNaN(port)) { 40 | // named pipe 41 | return val; 42 | } 43 | 44 | if (port >= 0) { 45 | // port number 46 | return port; 47 | } 48 | 49 | return false; 50 | } 51 | 52 | /** 53 | * Event listener for HTTP server "error" event. 54 | */ 55 | 56 | function onError(error) { 57 | if (error.syscall !== 'listen') { 58 | throw error; 59 | } 60 | 61 | var bind = typeof port === 'string' 62 | ? 'Pipe ' + port 63 | : 'Port ' + port; 64 | 65 | // handle specific listen errors with friendly messages 66 | switch (error.code) { 67 | case 'EACCES': 68 | console.error(bind + ' requires elevated privileges'); 69 | process.exit(1); 70 | break; 71 | case 'EADDRINUSE': 72 | console.error(bind + ' is already in use'); 73 | process.exit(1); 74 | break; 75 | default: 76 | throw error; 77 | } 78 | } 79 | 80 | /** 81 | * Event listener for HTTP server "listening" event. 82 | */ 83 | 84 | function onListening() { 85 | var addr = server.address(); 86 | var bind = typeof addr === 'string' 87 | ? 'pipe ' + addr 88 | : 'port ' + addr.port; 89 | debug('Listening on ' + bind); 90 | } 91 | -------------------------------------------------------------------------------- /react/react-tutorial/server.php: -------------------------------------------------------------------------------- 1 | $_POST['author'], 38 | 'text' => $_POST['text']]; 39 | 40 | $comments = json_encode($commentsDecoded, JSON_PRETTY_PRINT); 41 | file_put_contents('comments.json', $comments); 42 | } 43 | header('Content-Type: application/json'); 44 | header('Cache-Control: no-cache'); 45 | echo $comments; 46 | } else { 47 | return false; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /simple-blog/bin/www: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * Module dependencies. 5 | */ 6 | 7 | var app = require('../app'); 8 | var debug = require('debug')('simple-blog:server'); 9 | var http = require('http'); 10 | 11 | /** 12 | * Get port from environment and store in Express. 13 | */ 14 | 15 | var port = normalizePort(process.env.PORT || '4000'); 16 | app.set('port', port); 17 | 18 | /** 19 | * Create HTTP server. 20 | */ 21 | 22 | var server = http.createServer(app); 23 | 24 | /** 25 | * Listen on provided port, on all network interfaces. 26 | */ 27 | 28 | server.listen(port); 29 | server.on('error', onError); 30 | server.on('listening', onListening); 31 | 32 | /** 33 | * Normalize a port into a number, string, or false. 34 | */ 35 | 36 | function normalizePort(val) { 37 | var port = parseInt(val, 10); 38 | 39 | if (isNaN(port)) { 40 | // named pipe 41 | return val; 42 | } 43 | 44 | if (port >= 0) { 45 | // port number 46 | return port; 47 | } 48 | 49 | return false; 50 | } 51 | 52 | /** 53 | * Event listener for HTTP server "error" event. 54 | */ 55 | 56 | function onError(error) { 57 | if (error.syscall !== 'listen') { 58 | throw error; 59 | } 60 | 61 | var bind = typeof port === 'string' 62 | ? 'Pipe ' + port 63 | : 'Port ' + port 64 | 65 | // handle specific listen errors with friendly messages 66 | switch (error.code) { 67 | case 'EACCES': 68 | console.error(bind + ' requires elevated privileges'); 69 | process.exit(1); 70 | break; 71 | case 'EADDRINUSE': 72 | console.error(bind + ' is already in use'); 73 | process.exit(1); 74 | break; 75 | default: 76 | throw error; 77 | } 78 | } 79 | 80 | /** 81 | * Event listener for HTTP server "listening" event. 82 | */ 83 | 84 | function onListening() { 85 | var addr = server.address(); 86 | var bind = typeof addr === 'string' 87 | ? 'pipe ' + addr 88 | : 'port ' + addr.port; 89 | debug('Listening on ' + bind); 90 | } 91 | -------------------------------------------------------------------------------- /py/sqlite-demo/sqlite3_demo.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import sqlite3 4 | import json 5 | 6 | db_name = 'shipping.db' 7 | org_json_data = 'shipping_data.json' 8 | table_rules = {'shipping_store': '''CREATE TABLE shipping_store (order_sn text primary key, logistics_name text, logistics_code text, robot_status integer, order_status text)'''} 9 | 10 | 11 | def load_data(filename): 12 | 13 | with open(filename, 'r') as f: 14 | data = json.loads(f.read()) 15 | 16 | return data 17 | 18 | 19 | def init_database(): 20 | 21 | conn = sqlite3.connect(db_name) 22 | cur = conn.cursor() 23 | 24 | for table_name in table_rules.keys(): 25 | cur.execute("SELECT name FROM sqlite_master WHERE type='table' AND name=?", (table_name,)) 26 | if cur.fetchone() == None: 27 | cur.execute(table_rules[table_name]) 28 | 29 | 30 | def save_data(data): 31 | 32 | tuple_list = [] 33 | for i in data: 34 | tuple_list.append((i['order_id'], i['logistics_name'], i['logistics_code'], i['robot_status'], i['order_status'])) 35 | 36 | conn = sqlite3.connect(db_name) 37 | cur = conn.cursor() 38 | for item in tuple_list: 39 | order_sn = item[0] 40 | logistics_name = item[1] 41 | logistics_code = item[2] 42 | robot_status = item[3] 43 | order_status = item[4] 44 | cur.execute("INSERT OR REPLACE INTO shipping_store VALUES(?, ?, ?, ?, ?)", (order_sn, logistics_name, logistics_code, robot_status, order_status)) 45 | conn.commit() 46 | conn.close() 47 | 48 | def select_data(): 49 | 50 | conn = sqlite3.connect(db_name) 51 | cur = conn.cursor() 52 | cur.execute("SELECT * FROM shipping_store") 53 | data = cur.fetchall() 54 | for i in data: 55 | print i[0], i[1], i[2], i[3] 56 | conn.close() 57 | 58 | 59 | if __name__ == '__main__': 60 | 61 | init_database() 62 | data = load_data(org_json_data) 63 | save_data(data) 64 | select_data() 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /simple-blog/Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function(grunt) { 2 | // 项目配置信息. 3 | grunt.initConfig({ 4 | pkg: grunt.file.readJSON('package.json'), 5 | jshint: { 6 | options : { 7 | jshintrc: '.jshintrc', 8 | // eqeqeq: true, 9 | // tradiling: true, 10 | ignores: ['node_modules/**/*.js'] 11 | }, 12 | all: ['**/*.js'] 13 | }, 14 | coffee:{ 15 | compile: { 16 | options: { 17 | sourceMap: false, 18 | bare: true 19 | }, 20 | files: [{ 21 | expand: true, 22 | cwd: "coffee/", 23 | src: '**/*.coffee', 24 | dest: 'js/', 25 | ext: '.js' 26 | }] 27 | } 28 | }, 29 | watch: { 30 | coffee: { 31 | files: ['**/*.coffee'], 32 | tasks: ['coffee:compile'] 33 | // }, 34 | // js: { 35 | // files: ['**/*.js'], 36 | // tasks: ['jshint'], 37 | // options: { 38 | // livereload: true 39 | // } 40 | } 41 | }, 42 | nodemon: { 43 | dev: { 44 | script: 'bin/www', 45 | options: { 46 | args: [], 47 | ignoredFiles: [], 48 | watchedExtensions: ['js'], 49 | watchedFolders: ['./'], 50 | debug: true, 51 | delayTime: 1, 52 | env: { 53 | PORT: 3000 54 | }, 55 | cwd: __dirname 56 | } 57 | } 58 | }, 59 | concurrent: { 60 | tasks: ['watch','nodemon'], 61 | options: { 62 | logConcurrentOutput: true 63 | } 64 | } 65 | }); 66 | // 加载"uglify"插件.. 67 | grunt.loadNpmTasks('grunt-contrib-watch'); 68 | grunt.loadNpmTasks('grunt-contrib-coffee'); 69 | grunt.loadNpmTasks('grunt-contrib-jshint'); 70 | grunt.loadNpmTasks('grunt-nodemon'); 71 | grunt.loadNpmTasks('grunt-concurrent'); 72 | //grunt.loadNpmTasks('grunt-ssh'); 73 | 74 | grunt.option('force', true); 75 | 76 | // 注册默认任务. 77 | grunt.registerTask('default', ['concurrent']); 78 | }; 79 | -------------------------------------------------------------------------------- /learn-html5/3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 13 | 14 | html5 canvas 15 | 16 | 17 |
18 | 19 |
20 | 21 | 22 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/basic-jsx/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Basic Example with JSX 6 | 7 | 8 | 9 |

Basic Example with JSX

10 |
11 |

12 | To install React, follow the instructions on 13 | GitHub. 14 |

15 |

16 | If you can see this, React is not working right. 17 | If you checked out the source from GitHub make sure to run grunt. 18 |

19 |
20 |

Example Details

21 |

This is written with JSX and transformed in the browser.

22 |

23 | Learn more about React at 24 | facebook.github.io/react. 25 |

26 | 27 | 28 | 29 | 30 | 31 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /ant-test/js/my.js: -------------------------------------------------------------------------------- 1 | /* 侧边栏响应 */ 2 | 3 | // 新建文章 4 | $(function() { 5 | $(document).on('click', '#new', function() { 6 | $('.main-container').load("tiles/new.html"); 7 | }); 8 | }); 9 | 10 | // 文章列表 11 | $(function() { 12 | $(document).on('click', '#list', function() { 13 | $('.main-container').load("tiles/list.html"); 14 | // 载入列表数据 15 | $.getJSON("http://127.0.0.1:3000/list", function (json, status) { 16 | $("#getlist").html(""); 17 | $.each(json['data'], function (i, item) { 18 | $("#artlist").append( 19 | "
  • " + item.title + "
  • " 20 | ); 21 | }); 22 | }); 23 | }); 24 | }); 25 | 26 | // Hexo设置 27 | $(function () { 28 | $(document).on('click', '#hexo_settings', function() { 29 | $('.main-container').load("tiles/hexo_settings.html"); 30 | // 载入Hexo配置文件数据 31 | $.getJSON("http://127.0.0.1:3000/hexo_settings", function (json, status) { 32 | $("#settings").append( 33 | json['data'] 34 | ); 35 | }); 36 | }); 37 | }); 38 | 39 | /* 新建文章 */ 40 | $(function () { 41 | $(document).on("click", '#create', function () { 42 | alert($('input[name=title]').val()); 43 | $.ajax({ 44 | type: 'POST', 45 | url: 'http://127.0.0.1:3000/new', 46 | data: { 47 | title: $('input[name=title]').val(), 48 | date: $('input[name=date]').val(), 49 | filename: $('input[name=filename]').val(), 50 | tags: $('input[name=tags]').val(), 51 | content: $('textarea[name=content]').val() 52 | }, 53 | success: function (res, status, xhr) { 54 | alert('success!: ' + res.title); 55 | } 56 | }) 57 | }) 58 | }) 59 | 60 | /* 61 | $(function () { 62 | $(document).on("onload", "#getlist", function () { 63 | $.getJSON("http://127.0.0.1:3000/list", function (json, status) { 64 | $("#getlist").html(""); 65 | $.each(json['data'], function (i, item) { 66 | $("#artlist").append( 67 | "
  • " + item.title + "
  • " 68 | ); 69 | }); 70 | }); 71 | }); 72 | }) 73 | */ 74 | -------------------------------------------------------------------------------- /simple-blog/models/user.js: -------------------------------------------------------------------------------- 1 | var mongodb = require('./db'); 2 | var crypto = require('crypto'); 3 | 4 | function User(user) { 5 | this.name = user.name; 6 | this.password = user.password; 7 | this.email = user.email; 8 | }; 9 | 10 | module.exports = User; 11 | 12 | //存储用户信息 13 | User.prototype.save = function(callback) { 14 | 15 | //要存入数据库的用户文档 16 | var md5 = crypto.createHash('md5'), 17 | email_MD5 = md5.update(this.email.toLowerCase()).digest('hex'), 18 | head = "http://gravatar.duoshuo.com//avatar/" + email_MD5 + "?s=48"; 19 | 20 | //要存入数据库的用户信息文档 21 | var user = { 22 | name: this.name, 23 | password: this.password, 24 | email: this.email, 25 | head: head 26 | }; 27 | 28 | //打开数据库 29 | mongodb.open(function (err, db) { 30 | if (err) { 31 | return callback(err);//错误,返回 err 信息 32 | } 33 | //读取 users 集合 34 | db.collection('users', function (err, collection) { 35 | if (err) { 36 | mongodb.close(); 37 | return callback(err);//错误,返回 err 信息 38 | } 39 | //将用户数据插入 users 集合 40 | collection.insert(user, { 41 | safe: true 42 | }, function (err, user) { 43 | mongodb.close(); 44 | if (err) { 45 | return callback(err);//错误,返回 err 信息 46 | } 47 | callback(null, user[0]);//成功!err 为 null,并返回存储后的用户文档 48 | }); 49 | }); 50 | }); 51 | }; 52 | 53 | //读取用户信息 54 | User.get = function(name, callback) { 55 | //打开数据库 56 | mongodb.open(function (err, db) { 57 | if (err) { 58 | return callback(err);//错误,返回 err 信息 59 | } 60 | //读取 users 集合 61 | db.collection('users', function (err, collection) { 62 | if (err) { 63 | mongodb.close(); 64 | return callback(err);//错误,返回 err 信息 65 | } 66 | //查找用户名(name键)值为 name 一个文档 67 | collection.findOne({ 68 | name: name 69 | }, function (err, user) { 70 | mongodb.close(); 71 | if (err) { 72 | return callback(err);//失败!返回 err 信息 73 | } 74 | callback(null, user);//成功!返回查询的用户信息 75 | }); 76 | }); 77 | }); 78 | }; 79 | -------------------------------------------------------------------------------- /node/speak/app.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var path = require('path'); 3 | var favicon = require('serve-favicon'); 4 | var logger = require('morgan'); 5 | var cookieParser = require('cookie-parser'); 6 | var bodyParser = require('body-parser'); 7 | 8 | var routes = require('./routes/index'); 9 | var users = require('./routes/users'); 10 | 11 | var app = express(); 12 | 13 | //设置跨域访问 14 | app.all('*', function(req, res, next) { 15 | res.header("Access-Control-Allow-Origin", "*"); 16 | res.header("Access-Control-Allow-Headers", "Content-Type, Content-Length, Authorization, Accept, X-Requested-With"); 17 | res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS"); 18 | res.header("X-Powered-By",' 3.2.1') 19 | // res.header("Content-Type", "application/json;charset=utf-8"); 20 | next(); 21 | }); 22 | 23 | // view engine setup 24 | app.set('views', path.join(__dirname, 'views')); 25 | app.set('view engine', 'ejs'); 26 | 27 | // uncomment after placing your favicon in /public 28 | //app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))); 29 | app.use(logger('dev')); 30 | app.use(bodyParser.json()); 31 | app.use(bodyParser.urlencoded({ extended: false })); 32 | app.use(cookieParser()); 33 | app.use(express.static(path.join(__dirname, 'public'))); 34 | 35 | app.use('/', routes); 36 | app.use('/users', users); 37 | 38 | // catch 404 and forward to error handler 39 | app.use(function(req, res, next) { 40 | var err = new Error('Not Found'); 41 | err.status = 404; 42 | next(err); 43 | }); 44 | 45 | // error handlers 46 | 47 | // development error handler 48 | // will print stacktrace 49 | if (app.get('env') === 'development') { 50 | app.use(function(err, req, res, next) { 51 | res.status(err.status || 500); 52 | res.render('error', { 53 | message: err.message, 54 | error: err 55 | }); 56 | }); 57 | } 58 | 59 | // production error handler 60 | // no stacktraces leaked to user 61 | app.use(function(err, req, res, next) { 62 | res.status(err.status || 500); 63 | res.render('error', { 64 | message: err.message, 65 | error: {} 66 | }); 67 | }); 68 | 69 | 70 | module.exports = app; 71 | -------------------------------------------------------------------------------- /async/control-flow.js: -------------------------------------------------------------------------------- 1 | var async = require('async'); 2 | 3 | 4 | /* 5 | async.parallel([ 6 | function(callback){ 7 | setTimeout(function(){ 8 | callback(null, 'one'); 9 | }, 200); 10 | }, 11 | function(callback){ 12 | setTimeout(function(){ 13 | callback(null, 'two'); 14 | }, 100); 15 | }, 16 | function(callback){ 17 | setTimeout(function(){ 18 | var err = new Error('I am the error'); 19 | callback(err); 20 | }, 400); 21 | }, 22 | function(callback){ 23 | setTimeout(function(){ 24 | callback(null, 'three'); 25 | }, 600); 26 | }, 27 | ], 28 | // optional callback 29 | function(err, results){ 30 | if(err){ 31 | console.log('Error', err); 32 | } else { 33 | 34 | } 35 | console.log(results); 36 | //results is now equal to [ 'one', 'two', undefined ] 37 | // the second function had a shorter timeout. 38 | }); 39 | */ 40 | 41 | /* 42 | async.series([ 43 | function(callback){ 44 | setTimeout(function(){ 45 | callback(null, 'one'); 46 | }, 200); 47 | }, 48 | function(callback){ 49 | setTimeout(function(){ 50 | callback(null, 'two'); 51 | }, 100); 52 | }, 53 | function(callback){ 54 | setTimeout(function(){ 55 | var err = new Error('I am the error'); 56 | callback(err); 57 | }, 400); 58 | }, 59 | function(callback){ 60 | setTimeout(function(){ 61 | callback(null, 'three'); 62 | }, 600); 63 | } 64 | ], 65 | // optional callback 66 | function(err, results){ 67 | //results is now equal to [ 'one', 'two', undefined ] 68 | if(err){ 69 | console.log('Error'); 70 | } else { 71 | 72 | } 73 | console.log(results); 74 | }); 75 | 76 | */ 77 | 78 | 79 | var count = 0; 80 | 81 | async.whilst( 82 | function () { 83 | console.log(count); 84 | return count < 5; }, 85 | function (callback) { 86 | count++; 87 | setTimeout(callback, 1000); 88 | }, 89 | function (err) { 90 | // 5 seconds have passed 91 | } 92 | ); 93 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/basic/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Basic Example 6 | 7 | 8 | 9 |

    Basic Example

    10 |
    11 |

    12 | To install React, follow the instructions on 13 | GitHub. 14 |

    15 |

    16 | If you can see this, React is not working right. 17 | If you checked out the source from GitHub make sure to run grunt. 18 |

    19 |
    20 |

    Example Details

    21 |

    This is written in vanilla JavaScript (without JSX) and transformed in the browser.

    22 |

    23 | Learn more about React at 24 | facebook.github.io/react. 25 |

    26 | 27 | 28 | 29 | 30 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /css-layout/top-bar/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
    12 | 42 |
    43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/server-rendering/webapp/index.php: -------------------------------------------------------------------------------- 1 | 38 | (function() { 39 | var React = require('react'); 40 | var Component = require($module_for_js); 41 | React.render( 42 | React.createElement(Component, $props_json), 43 | document.getElementById($container_id_for_js) 44 | ); 45 | })(); 46 | 47 | SCRIPT; 48 | 49 | $container_markup = '
    ' . $server_markup . '
    '; 50 | 51 | return $container_markup . $startup_code; 52 | } 53 | ?> 54 | 55 | 56 | 57 | React server rendering example 58 | 59 | 60 | 61 | Welcome to the React server rendering example. Here is a server-rendered React component: 62 | 'Pete')); ?> 63 | 64 | 65 | -------------------------------------------------------------------------------- /py/property-demo.py: -------------------------------------------------------------------------------- 1 | #!/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | # ------------------------------------------------------------------------ 6 | # 可以使用property对类添加额外的属性,来扩展函数的功能 7 | # 如下Person类所示,不过想要修改值,需要间接修改first_name, last_name实现 8 | # ------------------------------------------------------------------------ 9 | 10 | class Person(object): 11 | 12 | def __init__(self, first_name, last_name): 13 | self.first_name = first_name 14 | self.last_name = last_name 15 | 16 | @property 17 | def full_name(self): 18 | print 'hello, %s %s' % (self.first_name, self.last_name) 19 | 20 | 21 | p = Person('xiao', 'ming') 22 | p.full_name # hello, xiao ming 23 | 24 | 25 | # ------------------------------------------------------------------------ 26 | # 对属性进行校验 27 | # 当需要对属性在获取或者赋值的同时,希望进行一些额外的操作,可以使用property 28 | # 新建一个`name`内置方法,然后用装饰器@property修饰,那么可以使用@name.setter 29 | # 支持通过赋值来修改变量的值 30 | # 另外值得注意的是下边注释_name,是可以工作的,因为property在使用同名的变量后 31 | # 将数据存储在了以下划线开头的_同名变量中 32 | # 使用self.name = name可以使得初始化的时候也可以进行校验 33 | # ------------------------------------------------------------------------ 34 | 35 | class Person2(object): 36 | def __init__(self, name): 37 | self.name = name 38 | #self._name = name 39 | 40 | @property 41 | def name(self): 42 | print self._name 43 | 44 | @name.setter 45 | def name(self, value): 46 | if value != 'gimp': 47 | self._name = value 48 | 49 | p = Person2('xiao ming') 50 | p.name # xiao ming 51 | p.name = 'dongdong' 52 | p.name # dongdong 53 | p.name = 'gimp' 54 | p.name # dongdong 55 | 56 | 57 | # ------------------------------------------------------------------------ 58 | # 对于已经定义了获取属性,设置属性的类,可以使用如下方法来对属性进行控制 59 | # 值得说明的是property后边的参数顺序是不能变的,获取/设置/删除(如果有的话) 60 | # ------------------------------------------------------------------------ 61 | 62 | 63 | class Person3(object): 64 | def __init__(self, name): 65 | self._name = name 66 | 67 | def get_name(self): 68 | print self._name 69 | 70 | def set_name(self, value): 71 | self._name = value 72 | 73 | name = property(get_name, set_name) 74 | 75 | 76 | p = Person3('mr.liu') 77 | p.name # mr.liu 78 | p.name = 'mr.zhang' 79 | p.name # mr.zhang 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /react/react-tutorial/Server.hs: -------------------------------------------------------------------------------- 1 | -- This file provided by Facebook is for non-commercial testing and evaluation 2 | -- purposes only. Facebook reserves all rights not expressly granted. 3 | -- 4 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 5 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 6 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 7 | -- FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 8 | -- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 9 | -- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE 10 | 11 | {-# LANGUAGE OverloadedStrings #-} 12 | 13 | module Main (main) where 14 | 15 | import Web.Scotty 16 | 17 | import Control.Monad (mzero) 18 | import Control.Monad.Trans 19 | import Network.Wai.Middleware.Static 20 | import Network.Wai.Middleware.RequestLogger (logStdoutDev) 21 | import Data.ByteString.Lazy (readFile, writeFile, fromStrict) 22 | import qualified Data.ByteString as BS (readFile) 23 | import Prelude hiding (readFile, writeFile) 24 | import Data.Aeson hiding (json) 25 | import Data.Text 26 | import Data.Maybe (fromJust) 27 | 28 | data Comment = Comment { 29 | commentText :: Text, 30 | author :: Text 31 | } deriving (Eq, Show, Ord) 32 | 33 | instance FromJSON Comment where 34 | parseJSON (Object v) = Comment <$> 35 | v .: "text" <*> 36 | v .: "author" 37 | parseJSON _ = mzero 38 | 39 | instance ToJSON Comment where 40 | toJSON (Comment ctext author) = object ["text" .= ctext, "author" .= author] 41 | 42 | 43 | main :: IO () 44 | main = scotty 3000 $ do 45 | 46 | middleware $ staticPolicy (noDots >-> addBase "public") 47 | middleware logStdoutDev 48 | 49 | get "/" $ file "./public/index.html" 50 | 51 | get "/comments.json" $ do 52 | comments <- liftIO $ readFile "comments.json" 53 | json $ fromJust $ (decode comments :: Maybe [Comment]) 54 | 55 | post "/comments.json" $ do 56 | comments <- liftIO $ BS.readFile "comments.json" 57 | let jsonComments = fromJust $ (decode $ fromStrict comments :: Maybe [Comment]) 58 | author <- param "author" 59 | comment <- param "text" 60 | let allComments = jsonComments ++ [Comment comment author] 61 | liftIO $ writeFile "comments.json" (encode allComments) 62 | json allComments 63 | -------------------------------------------------------------------------------- /py/v2ex.py: -------------------------------------------------------------------------------- 1 | #!/bin/env python 2 | # -*- coding: utf-8 -*- 3 | from bs4 import BeautifulSoup 4 | import requests 5 | 6 | # https://gist.github.com/187j3x1/6349451 7 | 8 | username = 'username' 9 | password = 'password' 10 | login_url = 'http://v2ex.com/signin' 11 | index_url = 'http://v2ex.com' 12 | mission_url = 'http://www.v2ex.com/mission/daily' 13 | UA = "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) \ 14 | Chrome/27.0.1453.116 Safari/537.36" 15 | headers = { 16 | "User-Agent": "UA", 17 | "Host": "v2ex.com", 18 | "Origin": "http://v2ex.com", 19 | "Referer": "http://www.v2ex.com/signin" 20 | } 21 | v2ex_session = requests.Session() 22 | 23 | def make_soup(url, tag, name): 24 | page = get_page(url) 25 | soup = BeautifulSoup(page) 26 | what_we_got = soup.find(attrs={tag:name}) 27 | return what_we_got 28 | 29 | def get_page(url): 30 | page = v2ex_session.get(url, headers=headers, verify=False).text 31 | return page 32 | 33 | def mix_post_info(url): 34 | once_value = make_soup(url, 'name', 'once')['value'].encode('ascii') 35 | post_info = { 36 | "next": "/", 37 | "u": username, 38 | "p": password, 39 | "once": once_value, 40 | "next": "/" 41 | } 42 | return post_info 43 | 44 | def try_login(url): 45 | post_info = mix_post_info(url) 46 | resp = v2ex_session.post(url, data=post_info, headers=headers, verify=False) 47 | if check_balance(index_url): 48 | return True 49 | else: 50 | return False 51 | 52 | def money_link(url): 53 | short_url = make_soup(url, 'class', 'super normal button')['onclick'] 54 | first_quote = short_url.find("'") 55 | last_quote = short_url.find("'", first_quote+1) 56 | short_url = short_url[first_quote+1:last_quote] 57 | return index_url + short_url 58 | 59 | def check_balance(url): 60 | money_tag = make_soup(url, 'class', 'balance_area') 61 | if money_tag: 62 | money = money_tag.contents[0].strip() + money_tag.contents[2].strip() 63 | return money 64 | else: 65 | return None 66 | 67 | def check_and_do(): 68 | if try_login(login_url): 69 | print 'login successfully...' 70 | print 'current balance: ' + check_balance(index_url) 71 | mission = make_soup(index_url, 'class', 'icon-gift') 72 | if mission: 73 | print 'now take todays money...' 74 | get_money = money_link(mission_url) 75 | print 'update balance: ' + check_balance(get_money) 76 | else: 77 | print 'already take todays money...' 78 | else: 79 | print 'login fail...' 80 | 81 | check_and_do() 82 | -------------------------------------------------------------------------------- /py/v2ex_daily_mission_gai.py: -------------------------------------------------------------------------------- 1 | #/usr/bin/python 2 | # -*- coding : utf-8 -*- 3 | from bs4 import BeautifulSoup 4 | import requests 5 | 6 | #https://github.com/yxjxx/v2ex_daily_mission 7 | 8 | # settings 9 | username = 'username' # your v2ex username 10 | password = 'password' # your v2ex password 11 | login_url = 'https://v2ex.com/signin' 12 | home_page = 'https://www.v2ex.com' 13 | mission_url = 'https://www.v2ex.com/mission/daily' 14 | 15 | UA = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36" 16 | 17 | headers = { 18 | "User-Agent" : UA, 19 | "Host" : "www.v2ex.com", 20 | "Referer" : "https://www.v2ex.com/signin", 21 | "Origin" : "https://www.v2ex.com" 22 | } 23 | 24 | 25 | def make_soup(url,tag,name, v2ex_session): 26 | 27 | page = v2ex_session.get(url,headers=headers,verify=True).text 28 | soup = BeautifulSoup(page) 29 | soup_result = soup.find(attrs = {tag:name}) 30 | # print soup_result 31 | return soup_result 32 | 33 | def build_post(v2ex_session): 34 | 35 | once_vaule = make_soup(login_url,'name','once', v2ex_session)['value'] 36 | print(once_vaule) 37 | 38 | post_info = { 39 | 'u' : username, 40 | 'p' : password, 41 | 'once' : once_vaule, 42 | 'next' : '/' 43 | } 44 | return post_info 45 | 46 | def start_run(): 47 | 48 | # Get session 49 | v2ex_session = requests.Session() 50 | 51 | # Build the post data 52 | post_data = build_post(v2ex_session) 53 | 54 | # 55 | resp = v2ex_session.post(login_url, data=post_data, headers=headers, verify=True) 56 | 57 | short_url = make_soup(mission_url, 'class', 'super normal button', v2ex_session)['onclick'] 58 | 59 | 60 | first_quote = short_url.find("'") 61 | last_quote = short_url.find("'", first_quote+1) #str.find(str, beg=0 end=len(string)) 62 | final_url = home_page + short_url[first_quote+1:last_quote] 63 | 64 | page = v2ex_session.get(final_url,headers=headers,verify=True).content 65 | 66 | flag = make_soup(mission_url, 'class', 'fa fa-ok-sign', v2ex_session) 67 | 68 | return flag 69 | 70 | 71 | if __name__ == '__main__': 72 | 73 | flag = start_run() 74 | 75 | if flag: 76 | print ("Sucessful.") 77 | else: 78 | print ("Something wrong.") 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /node/mocha/coverage/coverage.json: -------------------------------------------------------------------------------- 1 | {"/home/sincerefly/Works/Projects/node/mocha/index.js":{"path":"/home/sincerefly/Works/Projects/node/mocha/index.js","s":{"1":1,"2":182,"3":35,"4":147,"5":56,"6":91,"7":1,"8":90,"9":1,"10":89,"11":1,"12":88,"13":1,"14":0,"15":0,"16":1},"b":{"1":[35,147],"2":[56,91],"3":[1,90],"4":[1,89],"5":[1,88],"6":[0,1]},"f":{"1":182},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":29}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":19,"column":1}},"2":{"start":{"line":3,"column":2},"end":{"line":5,"column":3}},"3":{"start":{"line":4,"column":4},"end":{"line":4,"column":13}},"4":{"start":{"line":6,"column":2},"end":{"line":8,"column":3}},"5":{"start":{"line":7,"column":4},"end":{"line":7,"column":13}},"6":{"start":{"line":9,"column":2},"end":{"line":11,"column":3}},"7":{"start":{"line":10,"column":4},"end":{"line":10,"column":37}},"8":{"start":{"line":12,"column":2},"end":{"line":14,"column":3}},"9":{"start":{"line":13,"column":4},"end":{"line":13,"column":38}},"10":{"start":{"line":15,"column":2},"end":{"line":17,"column":3}},"11":{"start":{"line":16,"column":4},"end":{"line":16,"column":44}},"12":{"start":{"line":18,"column":2},"end":{"line":18,"column":41}},"13":{"start":{"line":21,"column":0},"end":{"line":24,"column":1}},"14":{"start":{"line":22,"column":2},"end":{"line":22,"column":34}},"15":{"start":{"line":23,"column":2},"end":{"line":23,"column":55}},"16":{"start":{"line":26,"column":0},"end":{"line":26,"column":30}}},"branchMap":{"1":{"line":3,"type":"if","locations":[{"start":{"line":3,"column":2},"end":{"line":3,"column":2}},{"start":{"line":3,"column":2},"end":{"line":3,"column":2}}]},"2":{"line":6,"type":"if","locations":[{"start":{"line":6,"column":2},"end":{"line":6,"column":2}},{"start":{"line":6,"column":2},"end":{"line":6,"column":2}}]},"3":{"line":9,"type":"if","locations":[{"start":{"line":9,"column":2},"end":{"line":9,"column":2}},{"start":{"line":9,"column":2},"end":{"line":9,"column":2}}]},"4":{"line":12,"type":"if","locations":[{"start":{"line":12,"column":2},"end":{"line":12,"column":2}},{"start":{"line":12,"column":2},"end":{"line":12,"column":2}}]},"5":{"line":15,"type":"if","locations":[{"start":{"line":15,"column":2},"end":{"line":15,"column":2}},{"start":{"line":15,"column":2},"end":{"line":15,"column":2}}]},"6":{"line":21,"type":"if","locations":[{"start":{"line":21,"column":0},"end":{"line":21,"column":0}},{"start":{"line":21,"column":0},"end":{"line":21,"column":0}}]}}}} -------------------------------------------------------------------------------- /react/react-trader/www/js/feed-mock.js: -------------------------------------------------------------------------------- 1 | feed = (function () { 2 | 3 | var watchList = []; 4 | 5 | var stocks = [ 6 | {symbol: "GM", open: 38.87}, 7 | {symbol: "GE", open: 25.40}, 8 | {symbol: "MCD", open: 97.05}, 9 | {symbol: "UAL", open: 69.45}, 10 | {symbol: "WMT", open: 83.24}, 11 | {symbol: "AAL", open: 55.76}, 12 | {symbol: "LLY", open: 76.12}, 13 | {symbol: "JPM", open: 61.75}, 14 | {symbol: "BAC", open: 15.84}, 15 | {symbol: "BA", open: 154.50} 16 | ]; 17 | 18 | stocks.forEach(function(stock) { 19 | stock.last = stock.open; 20 | stock.high = stock.open; 21 | stock.low = stock.open; 22 | }); 23 | 24 | return { 25 | onChange: function(callback) { 26 | setInterval(function() { 27 | var index = Math.floor(Math.random() * stocks.length), 28 | stock = stocks[index], 29 | maxChange = stock.open * 0.005, 30 | change = maxChange - Math.random() * maxChange * 2, 31 | last; 32 | 33 | change = Math.round(change * 100) / 100; 34 | change = change === 0 ? 0.01 : change; 35 | 36 | last = stock.last + change; 37 | 38 | if (last > stock.open * 1.15 || last < stock.open * 0.85) 39 | { 40 | change = -change; 41 | last = stock.last + change; 42 | } 43 | 44 | stock.change = change; 45 | stock.last = Math.round(last * 100) / 100; 46 | if (stock.last > stock.high) { 47 | stock.high = stock.last; 48 | } 49 | if (stock.last < stock.low) { 50 | stock.low = stock.last; 51 | } 52 | if (watchList.indexOf(stock.symbol) > -1) { 53 | callback(stock); 54 | } 55 | }, 200); 56 | }, 57 | watch: function(symbols) { 58 | console.log(symbols); 59 | symbols.forEach(function(symbol) { 60 | if (watchList.indexOf(symbol) < 0) { 61 | watchList.push(symbol); 62 | } 63 | }); 64 | }, 65 | unwatch: function(symbol) { 66 | var index = watchList.indexOf(symbol); 67 | if (index > -1) { 68 | watchList.splice(index, 1); 69 | } 70 | } 71 | }; 72 | 73 | }()); -------------------------------------------------------------------------------- /py/pythonic.py: -------------------------------------------------------------------------------- 1 | #!/bin/python 2 | #encoding:utf-8 3 | # 题目来自Pythontip 部分答案也整理自此 4 | 5 | # List排序 6 | l = [2, 8, 3, 50] 7 | l.sort() 8 | print l 9 | print '------' 10 | 11 | # 字符串逆序 12 | s = '12345' 13 | print s[::-1] 14 | print '------' 15 | 16 | # 输出字典key 17 | # 一字典d,如d={1:'one', 2:'two', 3:'three'} 18 | # 输出字典d的key,以','链接,如‘1,2,3' 19 | d = {1: 'one', 2: 'two', 3: 'three'} 20 | print ','.join([str(key) for key in d.keys()]) 21 | print '------' 22 | 23 | # 输出字符奇数位置的字符串 24 | # 一个字符串 a, 输出字符奇数位置的字符串 25 | # 如a=‘12345’,则输出135 26 | a = '12345' 27 | print a[::2] 28 | print '------' 29 | 30 | # 求解100以内的所有素数 31 | # 输出100以内的所有素数,素数之间以一个空格区分 32 | print ' '.join(['%s' % x for x in range(2,100) if not [y for y in range(2,x/2+1) if x % y == 0]]) 33 | 34 | alist = [] 35 | for i in range(2, 101): 36 | for j in range(2, i): 37 | if i % j == 0: 38 | break 39 | else: 40 | alist.append(i) 41 | 42 | print ' '.join(str(i) for i in alist) 43 | 44 | def getPrime(maxNum): 45 | aList = [x for x in range(0,maxNum)] 46 | prime = [] 47 | for i in range(2,len(aList)): 48 | if aList[i] != 0: 49 | prime.append(aList[i]) 50 | clear(aList[i],aList,maxNum) 51 | return prime 52 | 53 | def clear(aPrime,aList,maxNum): 54 | for i in range(2,int((maxNum/aPrime)+1)): 55 | if not aPrime*i>maxNum-1: 56 | aList[i*aPrime]=0 57 | 58 | print ' '.join(str(i) for i in getPrime(100)) 59 | 60 | print '------' 61 | 62 | # 最大公约数 63 | # 两个正整数a和b, 输出它们的最大公约数 64 | a = 10 65 | b = 25 66 | 67 | while b: 68 | a, b = b, a%b 69 | print a 70 | 71 | a = 10 72 | b = 25 73 | 74 | gcd = lambda x,y: gcd(y,x) if x < y else gcd(y,x%y) if x%y else y 75 | print gcd(a,b) 76 | 77 | a = 10 78 | b = 25 79 | 80 | if(b>a): 81 | a, b = b, a 82 | while(b!=0): 83 | c=b 84 | b=a%b 85 | a=c 86 | print(a) 87 | 88 | a = 10 89 | b = 25 90 | 91 | def gcd(big,small): 92 | remainder = big % small #求余数 93 | if remainder == 0: #如果两个数相除,余数为0,那么除数就是最大公约数了 94 | print small 95 | else: 96 | gcd(small,remainder) #调用gcd函数,带入最小的数(在这里也就是除数)和余数继续辗转相除运算,(两个数相除,除数肯定大于余数) 97 | 98 | #接下来就是判断a和b谁的值大,因为求最大公约数是用大值除以小值 99 | if a > b: 100 | gcd(a,b) 101 | else: 102 | gcd(b,a) 103 | 104 | print '------' 105 | 106 | # 最小公倍数 107 | # 两个正整数a和b, 输出它们的最小公倍数 108 | a = 10 109 | b = 25 110 | def gcd(x, y): 111 | while y: 112 | x, y = y, x%y 113 | return x 114 | print a*b/gcd(a, b) 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /react/react-0.13.3/examples/transitions/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Example with Transitions 6 | 7 | 8 | 9 | 10 |

    Example with Transitions

    11 |
    12 |

    13 | To install React, follow the instructions on 14 | GitHub. 15 |

    16 |

    17 | If you can see this, React is not working right. 18 | If you checked out the source from GitHub make sure to run grunt. 19 |

    20 |
    21 |

    Example Details

    22 |

    This is written with JSX and transformed in the browser.

    23 |

    24 | Learn more about React at 25 | facebook.github.io/react. 26 |

    27 | 28 | 29 | 30 | 31 | 32 | 80 | 81 | 82 | --------------------------------------------------------------------------------