├── .editorconfig ├── .gitattributes ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── _static └── .gitkeep ├── _templates └── .gitkeep ├── conf.py ├── index.rst ├── make.bat ├── mos ├── 2017-spring │ ├── docker │ │ ├── index.md │ │ ├── lab │ │ │ ├── Dockerfile │ │ │ ├── long-running.sh │ │ │ └── readme.md │ │ └── resources │ │ │ └── Docker.pdf │ └── index.rst └── index.rst └── web ├── 2016-spring ├── environment │ ├── cmd.md │ ├── editor.md │ ├── env.rst │ ├── homework.md │ ├── images │ │ ├── at15-workspace.PNG │ │ ├── inception.jpg │ │ ├── mess-folders.PNG │ │ ├── open_cmd.PNG │ │ ├── virtualbox_xp.PNG │ │ ├── vmware_ub_server.PNG │ │ ├── win_cmd.PNG │ │ └── win_cmd_hello.PNG │ ├── index.rst │ ├── linux.md │ ├── nginx.md │ ├── php.md │ ├── request.md │ ├── vagrant.md │ ├── virtual.md │ └── workspace.md ├── git-html │ ├── branch.md │ ├── html.md │ ├── images │ │ ├── branch.png │ │ ├── commit_message_0.png │ │ ├── commit_message_1.png │ │ └── git_vs_svn.png │ ├── index.rst │ ├── introduce.md │ ├── setup.md │ ├── teamwork.md │ └── workflow.md ├── http-rest │ ├── assignment.md │ ├── index.rst │ ├── outline.md │ └── slide.md ├── index.rst └── instant-php │ ├── assignment.md │ ├── index.rst │ ├── outline.md │ ├── slide.md │ ├── source.md │ └── src │ ├── v1 │ ├── order.html │ └── process.php │ ├── v2 │ ├── .gitignore │ ├── complete_order.php │ └── process.php │ ├── v3 │ ├── add_item.php │ ├── cart.php │ ├── include │ │ └── function.php │ ├── remove_item.php │ └── save_cart.php │ └── v4 │ ├── add_item.php │ ├── cart.php │ ├── include │ └── autoload.php │ ├── remove_item.php │ ├── save_cart.php │ ├── src │ └── Dy │ │ └── Component │ │ └── Cart.php │ └── view │ └── cart.php └── index.rst /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | charset = utf-8 7 | end_of_line = lf 8 | indent_style = space 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Force sh file use lf 2 | *.sh text eol=lf 3 | Makefile text eol=lf 4 | *.bat text eol=crlf -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # IDE 2 | .idea 3 | 4 | # Mac 5 | .DS_Store 6 | 7 | # build 8 | _build 9 | 10 | # Logs 11 | logs 12 | *.log 13 | npm-debug.log* 14 | 15 | # Runtime data 16 | pids 17 | *.pid 18 | *.seed 19 | 20 | # Directory for instrumented libs generated by jscoverage/JSCover 21 | lib-cov 22 | 23 | # Coverage directory used by tools like istanbul 24 | coverage 25 | 26 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 27 | .grunt 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directory 36 | node_modules 37 | 38 | # Optional npm cache directory 39 | .npm 40 | 41 | # Optional REPL history 42 | .node_repl_history 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # User-friendly check for sphinx-build 11 | ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) 12 | $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) 13 | endif 14 | 15 | # Internal variables. 16 | PAPEROPT_a4 = -D latex_paper_size=a4 17 | PAPEROPT_letter = -D latex_paper_size=letter 18 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 19 | # the i18n builder cannot share the environment and doctrees with the others 20 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 21 | 22 | .PHONY: help 23 | help: 24 | @echo "Please use \`make ' where is one of" 25 | @echo " html to make standalone HTML files" 26 | @echo " dirhtml to make HTML files named index.html in directories" 27 | @echo " singlehtml to make a single large HTML file" 28 | @echo " pickle to make pickle files" 29 | @echo " json to make JSON files" 30 | @echo " htmlhelp to make HTML files and a HTML help project" 31 | @echo " qthelp to make HTML files and a qthelp project" 32 | @echo " applehelp to make an Apple Help Book" 33 | @echo " devhelp to make HTML files and a Devhelp project" 34 | @echo " epub to make an epub" 35 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 36 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 37 | @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" 38 | @echo " text to make text files" 39 | @echo " man to make manual pages" 40 | @echo " texinfo to make Texinfo files" 41 | @echo " info to make Texinfo files and run them through makeinfo" 42 | @echo " gettext to make PO message catalogs" 43 | @echo " changes to make an overview of all changed/added/deprecated items" 44 | @echo " xml to make Docutils-native XML files" 45 | @echo " pseudoxml to make pseudoxml-XML files for display purposes" 46 | @echo " linkcheck to check all external links for integrity" 47 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 48 | @echo " coverage to run coverage check of the documentation (if enabled)" 49 | 50 | .PHONY: clean 51 | clean: 52 | rm -rf $(BUILDDIR)/* 53 | 54 | .PHONY: html 55 | html: 56 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 57 | @echo 58 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 59 | 60 | .PHONY: dirhtml 61 | dirhtml: 62 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 63 | @echo 64 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 65 | 66 | .PHONY: singlehtml 67 | singlehtml: 68 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 69 | @echo 70 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 71 | 72 | .PHONY: pickle 73 | pickle: 74 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 75 | @echo 76 | @echo "Build finished; now you can process the pickle files." 77 | 78 | .PHONY: json 79 | json: 80 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 81 | @echo 82 | @echo "Build finished; now you can process the JSON files." 83 | 84 | .PHONY: htmlhelp 85 | htmlhelp: 86 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 87 | @echo 88 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 89 | ".hhp project file in $(BUILDDIR)/htmlhelp." 90 | 91 | .PHONY: qthelp 92 | qthelp: 93 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 94 | @echo 95 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 96 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 97 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Test-Doc.qhcp" 98 | @echo "To view the help file:" 99 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Test-Doc.qhc" 100 | 101 | .PHONY: applehelp 102 | applehelp: 103 | $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp 104 | @echo 105 | @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." 106 | @echo "N.B. You won't be able to view it unless you put it in" \ 107 | "~/Library/Documentation/Help or install it in your application" \ 108 | "bundle." 109 | 110 | .PHONY: devhelp 111 | devhelp: 112 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 113 | @echo 114 | @echo "Build finished." 115 | @echo "To view the help file:" 116 | @echo "# mkdir -p $$HOME/.local/share/devhelp/Test-Doc" 117 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Test-Doc" 118 | @echo "# devhelp" 119 | 120 | .PHONY: epub 121 | epub: 122 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 123 | @echo 124 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 125 | 126 | .PHONY: latex 127 | latex: 128 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 129 | @echo 130 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 131 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 132 | "(use \`make latexpdf' here to do that automatically)." 133 | 134 | .PHONY: latexpdf 135 | latexpdf: 136 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 137 | @echo "Running LaTeX files through pdflatex..." 138 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 139 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 140 | 141 | .PHONY: latexpdfja 142 | latexpdfja: 143 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 144 | @echo "Running LaTeX files through platex and dvipdfmx..." 145 | $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja 146 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 147 | 148 | .PHONY: text 149 | text: 150 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 151 | @echo 152 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 153 | 154 | .PHONY: man 155 | man: 156 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 157 | @echo 158 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 159 | 160 | .PHONY: texinfo 161 | texinfo: 162 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 163 | @echo 164 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 165 | @echo "Run \`make' in that directory to run these through makeinfo" \ 166 | "(use \`make info' here to do that automatically)." 167 | 168 | .PHONY: info 169 | info: 170 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 171 | @echo "Running Texinfo files through makeinfo..." 172 | make -C $(BUILDDIR)/texinfo info 173 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 174 | 175 | .PHONY: gettext 176 | gettext: 177 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 178 | @echo 179 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 180 | 181 | .PHONY: changes 182 | changes: 183 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 184 | @echo 185 | @echo "The overview file is in $(BUILDDIR)/changes." 186 | 187 | .PHONY: linkcheck 188 | linkcheck: 189 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 190 | @echo 191 | @echo "Link check complete; look for any errors in the above output " \ 192 | "or in $(BUILDDIR)/linkcheck/output.txt." 193 | 194 | .PHONY: doctest 195 | doctest: 196 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 197 | @echo "Testing of doctests in the sources finished, look at the " \ 198 | "results in $(BUILDDIR)/doctest/output.txt." 199 | 200 | .PHONY: coverage 201 | coverage: 202 | $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage 203 | @echo "Testing of coverage in the sources finished, look at the " \ 204 | "results in $(BUILDDIR)/coverage/python.txt." 205 | 206 | .PHONY: xml 207 | xml: 208 | $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml 209 | @echo 210 | @echo "Build finished. The XML files are in $(BUILDDIR)/xml." 211 | 212 | .PHONY: pseudoxml 213 | pseudoxml: 214 | $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml 215 | @echo 216 | @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." 217 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # README 2 | Dongyue Web Studio course and lecture 3 | 4 | - [View Documentation](https://course.readthedocs.io/en/latest/) 5 | - [View Course website](https://dyweb.github.io/course/) 6 | 7 | ## How to write doc 8 | 9 | - have `python` and `pip` installed. [python](https://www.python.org/) 10 | - `pip install sphinx sphinx-autobuild` to install sphinx 11 | - `pip install recommonmark` to install markdown support 12 | - use `md` or `rst` file 13 | - run `make html` to build html 14 | 15 | ## Syntax quick guide 16 | 17 | - [Markdown Guide from GitHub](https://guides.github.com/features/mastering-markdown/) 18 | - [Sphinx tutorial](http://www.sphinx-doc.org/en/stable/tutorial.html) 19 | - [Sphinx common markups](http://www.sphinx-doc.org/en/stable/rest.html) 20 | - [Sphinx example Readthedocs repo](https://github.com/rtfd/readthedocs.org) 21 | -------------------------------------------------------------------------------- /_static/.gitkeep: -------------------------------------------------------------------------------- 1 | # put your static html here? 2 | -------------------------------------------------------------------------------- /_templates/.gitkeep: -------------------------------------------------------------------------------- 1 | # put your style sheet and etc here 2 | -------------------------------------------------------------------------------- /conf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Test-Doc documentation build configuration file, created by 5 | # sphinx-quickstart on Thu Mar 17 18:19:49 2016. 6 | # 7 | # This file is execfile()d with the current directory set to its 8 | # containing dir. 9 | # 10 | # Note that not all possible configuration values are present in this 11 | # autogenerated file. 12 | # 13 | # All configuration values have a default; values that are commented out 14 | # serve to show the default. 15 | 16 | import sys 17 | import os 18 | from recommonmark.parser import CommonMarkParser 19 | 20 | # If extensions (or modules to document with autodoc) are in another directory, 21 | # add these directories to sys.path here. If the directory is relative to the 22 | # documentation root, use os.path.abspath to make it absolute, like shown here. 23 | #sys.path.insert(0, os.path.abspath('.')) 24 | 25 | # -- General configuration ------------------------------------------------ 26 | 27 | # If your documentation needs a minimal Sphinx version, state it here. 28 | #needs_sphinx = '1.0' 29 | 30 | # Add any Sphinx extension module names here, as strings. They can be 31 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 32 | # ones. 33 | extensions = [ 34 | 'sphinx.ext.autodoc', 35 | 'sphinx.ext.doctest', 36 | 'sphinx.ext.todo', 37 | 'sphinx.ext.coverage', 38 | 'sphinx.ext.mathjax', 39 | 'sphinx.ext.ifconfig', 40 | ] 41 | 42 | # Add any paths that contain templates here, relative to this directory. 43 | templates_path = ['_templates'] 44 | 45 | # The suffix(es) of source filenames. 46 | # You can specify multiple suffix as a list of string: 47 | # source_suffix = ['.rst', '.md'] 48 | source_suffix = ['.rst','.md'] 49 | 50 | source_parsers = { 51 | '.md': CommonMarkParser, 52 | } 53 | 54 | # The encoding of source files. 55 | #source_encoding = 'utf-8-sig' 56 | 57 | # The master toctree document. 58 | master_doc = 'index' 59 | 60 | # General information about the project. 61 | project = 'Course' 62 | copyright = '2012-2016, Dongyue Web Studio' 63 | author = 'Dongyue Web Dev Team' 64 | 65 | # The version info for the project you're documenting, acts as replacement for 66 | # |version| and |release|, also used in various other places throughout the 67 | # built documents. 68 | # 69 | # The short X.Y version. 70 | version = '0.1' 71 | # The full version, including alpha/beta/rc tags. 72 | release = '0.1.0' 73 | 74 | # The language for content autogenerated by Sphinx. Refer to documentation 75 | # for a list of supported languages. 76 | # 77 | # This is also used if you do content translation via gettext catalogs. 78 | # Usually you set "language" from the command line for these cases. 79 | language = 'en' 80 | 81 | # There are two options for replacing |today|: either, you set today to some 82 | # non-false value, then it is used: 83 | #today = '' 84 | # Else, today_fmt is used as the format for a strftime call. 85 | #today_fmt = '%B %d, %Y' 86 | 87 | # List of patterns, relative to source directory, that match files and 88 | # directories to ignore when looking for source files. 89 | exclude_patterns = ['_build'] 90 | 91 | # The reST default role (used for this markup: `text`) to use for all 92 | # documents. 93 | #default_role = None 94 | 95 | # If true, '()' will be appended to :func: etc. cross-reference text. 96 | #add_function_parentheses = True 97 | 98 | # If true, the current module name will be prepended to all description 99 | # unit titles (such as .. function::). 100 | #add_module_names = True 101 | 102 | # If true, sectionauthor and moduleauthor directives will be shown in the 103 | # output. They are ignored by default. 104 | #show_authors = False 105 | 106 | # The name of the Pygments (syntax highlighting) style to use. 107 | pygments_style = 'sphinx' 108 | 109 | # A list of ignored prefixes for module index sorting. 110 | #modindex_common_prefix = [] 111 | 112 | # If true, keep warnings as "system message" paragraphs in the built documents. 113 | #keep_warnings = False 114 | 115 | # If true, `todo` and `todoList` produce output, else they produce nothing. 116 | todo_include_todos = True 117 | 118 | 119 | # -- Options for HTML output ---------------------------------------------- 120 | 121 | # The theme to use for HTML and HTML Help pages. See the documentation for 122 | # a list of builtin themes. 123 | on_rtd = os.environ.get('READTHEDOCS', None) == 'True' 124 | if on_rtd: 125 | html_theme = 'default' 126 | else: 127 | html_theme = 'nature' 128 | 129 | # Theme options are theme-specific and customize the look and feel of a theme 130 | # further. For a list of options available for each theme, see the 131 | # documentation. 132 | #html_theme_options = {} 133 | 134 | # Add any paths that contain custom themes here, relative to this directory. 135 | #html_theme_path = [] 136 | 137 | # The name for this set of Sphinx documents. If None, it defaults to 138 | # " v documentation". 139 | #html_title = None 140 | 141 | # A shorter title for the navigation bar. Default is the same as html_title. 142 | #html_short_title = None 143 | 144 | # The name of an image file (relative to this directory) to place at the top 145 | # of the sidebar. 146 | #html_logo = None 147 | 148 | # The name of an image file (relative to this directory) to use as a favicon of 149 | # the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 150 | # pixels large. 151 | #html_favicon = None 152 | 153 | # Add any paths that contain custom static files (such as style sheets) here, 154 | # relative to this directory. They are copied after the builtin static files, 155 | # so a file named "default.css" will overwrite the builtin "default.css". 156 | html_static_path = ['_static'] 157 | 158 | # Add any extra paths that contain custom files (such as robots.txt or 159 | # .htaccess) here, relative to this directory. These files are copied 160 | # directly to the root of the documentation. 161 | #html_extra_path = [] 162 | 163 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 164 | # using the given strftime format. 165 | #html_last_updated_fmt = '%b %d, %Y' 166 | 167 | # If true, SmartyPants will be used to convert quotes and dashes to 168 | # typographically correct entities. 169 | #html_use_smartypants = True 170 | 171 | # Custom sidebar templates, maps document names to template names. 172 | #html_sidebars = {} 173 | 174 | # Additional templates that should be rendered to pages, maps page names to 175 | # template names. 176 | #html_additional_pages = {} 177 | 178 | # If false, no module index is generated. 179 | #html_domain_indices = True 180 | 181 | # If false, no index is generated. 182 | #html_use_index = True 183 | 184 | # If true, the index is split into individual pages for each letter. 185 | #html_split_index = False 186 | 187 | # If true, links to the reST sources are added to the pages. 188 | #html_show_sourcelink = True 189 | 190 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 191 | #html_show_sphinx = True 192 | 193 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 194 | #html_show_copyright = True 195 | 196 | # If true, an OpenSearch description file will be output, and all pages will 197 | # contain a tag referring to it. The value of this option must be the 198 | # base URL from which the finished HTML is served. 199 | #html_use_opensearch = '' 200 | 201 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 202 | #html_file_suffix = None 203 | 204 | # Language to be used for generating the HTML full-text search index. 205 | # Sphinx supports the following languages: 206 | # 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja' 207 | # 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr' 208 | #html_search_language = 'en' 209 | 210 | # A dictionary with options for the search language support, empty by default. 211 | # Now only 'ja' uses this config value 212 | #html_search_options = {'type': 'default'} 213 | 214 | # The name of a javascript file (relative to the configuration directory) that 215 | # implements a search results scorer. If empty, the default will be used. 216 | #html_search_scorer = 'scorer.js' 217 | 218 | # Output file base name for HTML help builder. 219 | htmlhelp_basename = 'Test-Docdoc' 220 | 221 | # -- Options for LaTeX output --------------------------------------------- 222 | 223 | latex_elements = { 224 | # The paper size ('letterpaper' or 'a4paper'). 225 | #'papersize': 'letterpaper', 226 | 227 | # The font size ('10pt', '11pt' or '12pt'). 228 | #'pointsize': '10pt', 229 | 230 | # Additional stuff for the LaTeX preamble. 231 | #'preamble': '', 232 | 233 | # Latex figure (float) alignment 234 | #'figure_align': 'htbp', 235 | } 236 | 237 | # Grouping the document tree into LaTeX files. List of tuples 238 | # (source start file, target name, title, 239 | # author, documentclass [howto, manual, or own class]). 240 | latex_documents = [ 241 | (master_doc, 'Test-Doc.tex', 'Test-Doc Documentation', 242 | 'at15', 'manual'), 243 | ] 244 | 245 | # The name of an image file (relative to this directory) to place at the top of 246 | # the title page. 247 | #latex_logo = None 248 | 249 | # For "manual" documents, if this is true, then toplevel headings are parts, 250 | # not chapters. 251 | #latex_use_parts = False 252 | 253 | # If true, show page references after internal links. 254 | #latex_show_pagerefs = False 255 | 256 | # If true, show URL addresses after external links. 257 | #latex_show_urls = False 258 | 259 | # Documents to append as an appendix to all manuals. 260 | #latex_appendices = [] 261 | 262 | # If false, no module index is generated. 263 | #latex_domain_indices = True 264 | 265 | 266 | # -- Options for manual page output --------------------------------------- 267 | 268 | # One entry per manual page. List of tuples 269 | # (source start file, name, description, authors, manual section). 270 | man_pages = [ 271 | (master_doc, 'test-doc', 'Test-Doc Documentation', 272 | [author], 1) 273 | ] 274 | 275 | # If true, show URL addresses after external links. 276 | #man_show_urls = False 277 | 278 | 279 | # -- Options for Texinfo output ------------------------------------------- 280 | 281 | # Grouping the document tree into Texinfo files. List of tuples 282 | # (source start file, target name, title, author, 283 | # dir menu entry, description, category) 284 | texinfo_documents = [ 285 | (master_doc, 'Test-Doc', 'Test-Doc Documentation', 286 | author, 'Test-Doc', 'One line description of project.', 287 | 'Miscellaneous'), 288 | ] 289 | 290 | # Documents to append as an appendix to all manuals. 291 | #texinfo_appendices = [] 292 | 293 | # If false, no module index is generated. 294 | #texinfo_domain_indices = True 295 | 296 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 297 | #texinfo_show_urls = 'footnote' 298 | 299 | # If true, do not generate a @detailmenu in the "Top" node's menu. 300 | #texinfo_no_detailmenu = False 301 | 302 | 303 | # -- Options for Epub output ---------------------------------------------- 304 | 305 | # Bibliographic Dublin Core info. 306 | epub_title = project 307 | epub_author = author 308 | epub_publisher = author 309 | epub_copyright = copyright 310 | 311 | # The basename for the epub file. It defaults to the project name. 312 | #epub_basename = project 313 | 314 | # The HTML theme for the epub output. Since the default themes are not 315 | # optimized for small screen space, using the same theme for HTML and epub 316 | # output is usually not wise. This defaults to 'epub', a theme designed to save 317 | # visual space. 318 | #epub_theme = 'epub' 319 | 320 | # The language of the text. It defaults to the language option 321 | # or 'en' if the language is not set. 322 | #epub_language = '' 323 | 324 | # The scheme of the identifier. Typical schemes are ISBN or URL. 325 | #epub_scheme = '' 326 | 327 | # The unique identifier of the text. This can be a ISBN number 328 | # or the project homepage. 329 | #epub_identifier = '' 330 | 331 | # A unique identification for the text. 332 | #epub_uid = '' 333 | 334 | # A tuple containing the cover image and cover page html template filenames. 335 | #epub_cover = () 336 | 337 | # A sequence of (type, uri, title) tuples for the guide element of content.opf. 338 | #epub_guide = () 339 | 340 | # HTML files that should be inserted before the pages created by sphinx. 341 | # The format is a list of tuples containing the path and title. 342 | #epub_pre_files = [] 343 | 344 | # HTML files that should be inserted after the pages created by sphinx. 345 | # The format is a list of tuples containing the path and title. 346 | #epub_post_files = [] 347 | 348 | # A list of files that should not be packed into the epub file. 349 | epub_exclude_files = ['search.html'] 350 | 351 | # The depth of the table of contents in toc.ncx. 352 | #epub_tocdepth = 3 353 | 354 | # Allow duplicate toc entries. 355 | #epub_tocdup = True 356 | 357 | # Choose between 'default' and 'includehidden'. 358 | #epub_tocscope = 'default' 359 | 360 | # Fix unsupported image types using the Pillow. 361 | #epub_fix_images = False 362 | 363 | # Scale large images. 364 | #epub_max_image_width = 0 365 | 366 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 367 | #epub_show_urls = 'inline' 368 | 369 | # If false, no index is generated. 370 | #epub_use_index = True 371 | -------------------------------------------------------------------------------- /index.rst: -------------------------------------------------------------------------------- 1 | .. Dongyue Courses documentation master file, created by 2 | sphinx-quickstart on Thu Mar 17 18:19:49 2016. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to Donyue Web Stuido Courses 7 | ==================================== 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 3 13 | 14 | README 15 | web/index 16 | mos/index 17 | 18 | Indices and tables 19 | ================== 20 | 21 | * :ref:`genindex` 22 | * :ref:`modindex` 23 | * :ref:`search` 24 | -------------------------------------------------------------------------------- /make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 10 | set I18NSPHINXOPTS=%SPHINXOPTS% . 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. xml to make Docutils-native XML files 37 | echo. pseudoxml to make pseudoxml-XML files for display purposes 38 | echo. linkcheck to check all external links for integrity 39 | echo. doctest to run all doctests embedded in the documentation if enabled 40 | echo. coverage to run coverage check of the documentation if enabled 41 | goto end 42 | ) 43 | 44 | if "%1" == "clean" ( 45 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 46 | del /q /s %BUILDDIR%\* 47 | goto end 48 | ) 49 | 50 | 51 | REM Check if sphinx-build is available and fallback to Python version if any 52 | %SPHINXBUILD% 1>NUL 2>NUL 53 | if errorlevel 9009 goto sphinx_python 54 | goto sphinx_ok 55 | 56 | :sphinx_python 57 | 58 | set SPHINXBUILD=python -m sphinx.__init__ 59 | %SPHINXBUILD% 2> nul 60 | if errorlevel 9009 ( 61 | echo. 62 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 63 | echo.installed, then set the SPHINXBUILD environment variable to point 64 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 65 | echo.may add the Sphinx directory to PATH. 66 | echo. 67 | echo.If you don't have Sphinx installed, grab it from 68 | echo.http://sphinx-doc.org/ 69 | exit /b 1 70 | ) 71 | 72 | :sphinx_ok 73 | 74 | 75 | if "%1" == "html" ( 76 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 77 | if errorlevel 1 exit /b 1 78 | echo. 79 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 80 | goto end 81 | ) 82 | 83 | if "%1" == "dirhtml" ( 84 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 85 | if errorlevel 1 exit /b 1 86 | echo. 87 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 88 | goto end 89 | ) 90 | 91 | if "%1" == "singlehtml" ( 92 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 93 | if errorlevel 1 exit /b 1 94 | echo. 95 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 96 | goto end 97 | ) 98 | 99 | if "%1" == "pickle" ( 100 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 101 | if errorlevel 1 exit /b 1 102 | echo. 103 | echo.Build finished; now you can process the pickle files. 104 | goto end 105 | ) 106 | 107 | if "%1" == "json" ( 108 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 109 | if errorlevel 1 exit /b 1 110 | echo. 111 | echo.Build finished; now you can process the JSON files. 112 | goto end 113 | ) 114 | 115 | if "%1" == "htmlhelp" ( 116 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 117 | if errorlevel 1 exit /b 1 118 | echo. 119 | echo.Build finished; now you can run HTML Help Workshop with the ^ 120 | .hhp project file in %BUILDDIR%/htmlhelp. 121 | goto end 122 | ) 123 | 124 | if "%1" == "qthelp" ( 125 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 126 | if errorlevel 1 exit /b 1 127 | echo. 128 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 129 | .qhcp project file in %BUILDDIR%/qthelp, like this: 130 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Test-Doc.qhcp 131 | echo.To view the help file: 132 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Test-Doc.ghc 133 | goto end 134 | ) 135 | 136 | if "%1" == "devhelp" ( 137 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 138 | if errorlevel 1 exit /b 1 139 | echo. 140 | echo.Build finished. 141 | goto end 142 | ) 143 | 144 | if "%1" == "epub" ( 145 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 146 | if errorlevel 1 exit /b 1 147 | echo. 148 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 149 | goto end 150 | ) 151 | 152 | if "%1" == "latex" ( 153 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 154 | if errorlevel 1 exit /b 1 155 | echo. 156 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 157 | goto end 158 | ) 159 | 160 | if "%1" == "latexpdf" ( 161 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 162 | cd %BUILDDIR%/latex 163 | make all-pdf 164 | cd %~dp0 165 | echo. 166 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 167 | goto end 168 | ) 169 | 170 | if "%1" == "latexpdfja" ( 171 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 172 | cd %BUILDDIR%/latex 173 | make all-pdf-ja 174 | cd %~dp0 175 | echo. 176 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 177 | goto end 178 | ) 179 | 180 | if "%1" == "text" ( 181 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 182 | if errorlevel 1 exit /b 1 183 | echo. 184 | echo.Build finished. The text files are in %BUILDDIR%/text. 185 | goto end 186 | ) 187 | 188 | if "%1" == "man" ( 189 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 190 | if errorlevel 1 exit /b 1 191 | echo. 192 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 193 | goto end 194 | ) 195 | 196 | if "%1" == "texinfo" ( 197 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 198 | if errorlevel 1 exit /b 1 199 | echo. 200 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 201 | goto end 202 | ) 203 | 204 | if "%1" == "gettext" ( 205 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 206 | if errorlevel 1 exit /b 1 207 | echo. 208 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 209 | goto end 210 | ) 211 | 212 | if "%1" == "changes" ( 213 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 214 | if errorlevel 1 exit /b 1 215 | echo. 216 | echo.The overview file is in %BUILDDIR%/changes. 217 | goto end 218 | ) 219 | 220 | if "%1" == "linkcheck" ( 221 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 222 | if errorlevel 1 exit /b 1 223 | echo. 224 | echo.Link check complete; look for any errors in the above output ^ 225 | or in %BUILDDIR%/linkcheck/output.txt. 226 | goto end 227 | ) 228 | 229 | if "%1" == "doctest" ( 230 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 231 | if errorlevel 1 exit /b 1 232 | echo. 233 | echo.Testing of doctests in the sources finished, look at the ^ 234 | results in %BUILDDIR%/doctest/output.txt. 235 | goto end 236 | ) 237 | 238 | if "%1" == "coverage" ( 239 | %SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage 240 | if errorlevel 1 exit /b 1 241 | echo. 242 | echo.Testing of coverage in the sources finished, look at the ^ 243 | results in %BUILDDIR%/coverage/python.txt. 244 | goto end 245 | ) 246 | 247 | if "%1" == "xml" ( 248 | %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml 249 | if errorlevel 1 exit /b 1 250 | echo. 251 | echo.Build finished. The XML files are in %BUILDDIR%/xml. 252 | goto end 253 | ) 254 | 255 | if "%1" == "pseudoxml" ( 256 | %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml 257 | if errorlevel 1 exit /b 1 258 | echo. 259 | echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. 260 | goto end 261 | ) 262 | 263 | :end 264 | -------------------------------------------------------------------------------- /mos/2017-spring/docker/index.md: -------------------------------------------------------------------------------- 1 | # Docker 2 | 3 | ## Slides 4 | 5 | [google slides](https://docs.google.com/presentation/d/1Ru4Dm9TLoyxnJgFqvsCHrb82VT622H-zBSgAe1vJL44/edit?usp=sharing) or [offline version](./resources/Docker.pdf) 6 | -------------------------------------------------------------------------------- /mos/2017-spring/docker/lab/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.4 2 | 3 | ADD long-running.sh /long-running.sh 4 | 5 | ENTRYPOINT ["/long-running.sh"] 6 | -------------------------------------------------------------------------------- /mos/2017-spring/docker/lab/long-running.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | while [[ 1 == 1 ]]; do 4 | sleep 5s 5 | echo "sleep 5s" 6 | done 7 | -------------------------------------------------------------------------------- /mos/2017-spring/docker/lab/readme.md: -------------------------------------------------------------------------------- 1 | # Minimal Long Running Task 2 | 3 | [![](https://images.microbadger.com/badges/image/gaocegege/minimal-long-running-task.svg)](https://microbadger.com/images/gaocegege/minimal-long-running-task "Get your own image badge on microbadger.com") 4 | [![](https://images.microbadger.com/badges/version/gaocegege/minimal-long-running-task.svg)](https://microbadger.com/images/gaocegege/minimal-long-running-task "Get your own version badge on microbadger.com") 5 | 6 | 一个Long Running的小镜像。 7 | -------------------------------------------------------------------------------- /mos/2017-spring/docker/resources/Docker.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyweb/course/2d6f7b4207be3a62861fce4332e8fb72d2d2b8e9/mos/2017-spring/docker/resources/Docker.pdf -------------------------------------------------------------------------------- /mos/2017-spring/index.rst: -------------------------------------------------------------------------------- 1 | 2017 Spring 2 | ==================================== 3 | 4 | Courses for 2017 Spring 5 | 6 | Contents: 7 | 8 | .. toctree:: 9 | :maxdepth: 2 10 | 11 | docker/index 12 | -------------------------------------------------------------------------------- /mos/index.rst: -------------------------------------------------------------------------------- 1 | .. Mos develop courses, provided by the following awesome members 2 | gaocegege 3 | 4 | Mos courses 5 | ==================================== 6 | 7 | Contents: 8 | 9 | .. toctree:: 10 | :maxdepth: 2 11 | 12 | 2017-spring/index 13 | -------------------------------------------------------------------------------- /web/2016-spring/environment/cmd.md: -------------------------------------------------------------------------------- 1 | # Command line 2 | 3 | aka: terminal, console, cli, cmd, bash etc. 4 | 5 | ## What is command line 6 | 7 | You type and run commands in plain text, and get text output. NO GUI (Graphic User Interface) interaction. 8 | 9 | tl;dw 10 | 11 | ## How to 12 | 13 | ### Open a command line 14 | 15 | - `win + R` ( this means you press the windows icon on your keyboard, and press the `R` leter at same time. ) 16 | - type `cmd` 17 | - press `enter` 18 | 19 | ![open cmd](images/open_cmd.PNG) 20 | 21 | - you can see a black window 22 | 23 | ![win_cmd](images/win_cmd.PNG) 24 | 25 | - type something like `echo Hello cmd` 26 | 27 | ![win_cmd_hello](images/win_cmd_hello.PNG) 28 | 29 | - list folders `dir` 30 | 31 | ## Concepts 32 | 33 | ### Executeable 34 | 35 | - binary TODO: vagrant, a c example. (windows: exe, linux: executeable) 36 | - script TODO: a bat example, a python example. 37 | 38 | ### Arguments 39 | 40 | - a php example 41 | 42 | ### Current folder 43 | 44 | ### PATH 45 | 46 | - windows config 47 | - linux config 48 | 49 | how to use it. 50 | 51 | ### Environment variables 52 | 53 | - windows config 54 | - linux config 55 | 56 | ### Autocomplete 57 | 58 | use tab 59 | -------------------------------------------------------------------------------- /web/2016-spring/environment/editor.md: -------------------------------------------------------------------------------- 1 | # Editor 2 | 3 | ## Problems 4 | 5 | - encoding 6 | - style 7 | - hint 8 | - large code base 9 | - extension 10 | 11 | ## Solution 12 | 13 | ### gitattributes 14 | 15 | Git can handle file encoding and line ending, use config file to override gloabl config. 16 | 17 | [Offical Doc](https://git-scm.com/docs/gitattributes) 18 | 19 | - encoding, UTF-8 20 | - end of line (crlf) , `sh` files can only use `LF` 21 | 22 | Example: 23 | 24 | ```` 25 | # Force sh file use lf 26 | *.sh text eol=lf 27 | Makefile text eol=lf 28 | *.bat text eol=crlf 29 | ```` 30 | 31 | ### editorconfig 32 | 33 | A editor independent style config. Some editor has it built in, most has plugin for it. 34 | 35 | [Offical Site](http://editorconfig.org/) 36 | 37 | - encoding 38 | - end of line (crlf) 39 | - indent 40 | - tab 41 | 42 | Example 43 | 44 | ```` 45 | root = true 46 | 47 | [*] 48 | insert_final_newline = true 49 | indent_style = space 50 | charset = utf-8 51 | 52 | [*.{sh,js,php,css,scss}] 53 | end_of_line = lf 54 | charset = utf-8 55 | 56 | [*.{js,json,yml}] 57 | indent_size = 2 58 | 59 | [*.php] 60 | indent_size = 4 61 | 62 | [*.{md,markdown}] 63 | indent_size = 4 64 | 65 | [Makefile] 66 | indent_style = tab 67 | ```` 68 | 69 | ### lint tools 70 | 71 | Lint tools can change your style, some can auto fix minor problems. You can also config git hooks to 72 | force running lint tools before commit. Some git host like [phabricator](http://phabricator.org/) also 73 | support running it on server. 74 | 75 | - Javascript [eslint](http://eslint.org/) 76 | - PHP [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) 77 | 78 | ### IDE 79 | 80 | Integrated Development Environment. Editor + Code runner + Debugger .... etc. 81 | 82 | #### Jetbrains 83 | 84 | - [official site](https://www.jetbrains.com/) 85 | 86 | **[Student can have free liciense](https://www.jetbrains.com/student/)** 87 | 88 | - [WebStorm](https://www.jetbrains.com/webstorm) Front end 89 | - **[PhpStorm](https://www.jetbrains.com/phpstorm/)** Front end + PHP 90 | - [IDEA](https://www.jetbrains.com/idea) Front end + Java + Scala + Groovy 91 | - [PyCharm](https://www.jetbrains.com/pycharm) Front end + Python 92 | 93 | Also have plugin for [Golang](https://github.com/go-lang-plugin-org/go-lang-idea-plugin) 94 | 95 | ### How hint works 96 | 97 | Hint is the editor show a list of words based on what you typed. It is also known as 98 | autocomplete, [intellisense](https://msdn.microsoft.com/en-us/library/hcw1s69b.aspx). 99 | 100 | #### Text only 101 | 102 | The editor show hint based on the words in this file only. 103 | 104 | TODO: image 105 | 106 | Example 107 | 108 | - Atom 109 | - Sublmie 110 | - VSCode 111 | 112 | #### Analysis result 113 | 114 | The editor (most time IDE) analysis all the code used in current project, including your code, library code, 115 | standard library code. This is also called index, similar to what search engine does. 116 | 117 | TODO: image 118 | 119 | Example 120 | 121 | - Eclipse 122 | - JetBrains IDE 123 | - Visual Studio 124 | 125 | However, with plugins, a lot editors can also show hint based on analysis result, like VSCode works perfectly 126 | with C# if you have Visual Studio installed. 127 | 128 | ## Recommended editors 129 | 130 | - [Atom](https://atom.io/) 131 | - [Sublime](https://www.sublimetext.com/) 132 | - [VSCode](https://code.visualstudio.com/) 133 | 134 | ## Not recommended 135 | 136 | They are well known editors, but since using them require a lot of config, it's better to use editor or IDE that comes 137 | out with a lot of default settings and plugins. You can try if you think you can handle them. 138 | 139 | - Vim 140 | - Emacs 141 | 142 | ## Outdated editor and IDE 143 | 144 | If you want to waste time, try one of the following. If you want to waste other people's time, recommend those to them. 145 | 146 | - Dreamweaver 147 | -------------------------------------------------------------------------------- /web/2016-spring/environment/env.rst: -------------------------------------------------------------------------------- 1 | Environment 2 | =========== 3 | 4 | You write and run your code on certain machine. It contains two parts, your code, and the execution environment of your code. Like your `index.php` and the `LNMP` 5 | stack. see refernece for formal explaination. 6 | 7 | 8 | * **local**: your laptop, PC. 9 | * **remote**: server, bare metal, vps, ec2 etc. 10 | 11 | Simplest: Develop -> Production 12 | -------------------------------- 13 | 14 | You write code in your local machine, they deploy it to remote machine, which is the production environment. 15 | 16 | NOTE: Not all local environment is develop environment, you can use your own laptop to publish your works, DONT do this in SJTU, you will 17 | get a phone call. Not all remote environment is production environment, you can use a server to write code, like you use vim or you sync 18 | code to server everytime you change something. 19 | 20 | Problems 21 | ^^^^^^^^^^^^^^^^^^^^^ 22 | 23 | * You use Windows, but the server is running Ubuntu. 24 | * You use PHP5.6, but the server uses PHP5.3. 25 | * You use Chinese as local (GB2312), but the server uses English (UTF-8). 26 | 27 | You may have encounter similar problems when your are installing games or softwares, they cannot be installed to path with Chinese or space, and 28 | the text are displayed as strange marks. 29 | 30 | Solution 31 | ^^^^^^^^^^^^^^^^^^^^^ 32 | 33 | Use the exact same environment for your laptop and server. 34 | 35 | But what if: 36 | 37 | * You want to use Windows to play Dota. (BGM: I want to play some dota ...) 38 | * You can't install dual system. 39 | * You have a small team working on the project, you can't force everyone to install Ubuntu. 40 | 41 | Formal: Develop -> Test -> Production 42 | ------------------------------------- 43 | 44 | You write you code locally, push to Git host, trigger test in CI (Continuous Integration), test pass, you deploy it to production. When you are working like this, 45 | you are highly likely not alone (but still single), either you are working on some opensource projects or you are working with a team (which has no girls). DONT use 46 | this for your homework. 47 | 48 | Problems 49 | ^^^^^^^^^^^^^^^^^^^^^ 50 | 51 | * Test works fine locally, but breaks in CI. 52 | * CI pass, but the production system is down. 53 | * CI pass, production works, your local environment can't pass test. 54 | 55 | Solution 56 | ^^^^^^^^^^^^^^^^^^^^^ 57 | 58 | * Have detail guide for environment setup. 59 | * Use the exact same environment for your laptop, CI server, Production server. 60 | 61 | But what if: 62 | 63 | * Someone forgot to write the guide. 64 | * Forgot to update CI or Production server. Worse if only production server is not up to date. 65 | 66 | Complex: Develop -> Test -> QA -> Part of Production -> Production 67 | ------------------------------------------------------------------ 68 | 69 | tl;dw 70 | 71 | How to setup a unfamiliar environment 72 | ------------------------------------- 73 | 74 | * DONT be afraid. 75 | * Backup your important things if you are NOT using virtual machine. 76 | * READ the offical documentation before google. 77 | * Google for stackoverflow answers. 78 | * Read blogs 79 | * Ask others 80 | * Give up and use docker 81 | 82 | this kind of work is inclued in a position called `Dev Ops`_ 83 | 84 | Future of Develop Environment 85 | ----------------------------- 86 | 87 | * Cloud develop environment, ie: Koding, c9.io, Eclipse Che 88 | * Hybird, ie: Koding, Coding.net 89 | * Docker 90 | 91 | Reference 92 | --------- 93 | 94 | * `Wiki Deploy Environment`_ 95 | * `Dev Ops`_ 96 | 97 | .. _Wiki Deploy Environment: https://en.wikipedia.org/wiki/Deployment_environment 98 | .. _Dev Ops: https://en.wikipedia.org/wiki/DevOps 99 | -------------------------------------------------------------------------------- /web/2016-spring/environment/homework.md: -------------------------------------------------------------------------------- 1 | # Homework 2 | 3 | ## workspace 4 | 5 | If you don't know Git, you can skip this one until you have took the course for it or learned it by yourself. 6 | 7 | - [ ] create a project on GitHub 8 | - [ ] create a project on git.tongqu.me, ask @arrowrowe if you do not have an account. 9 | - [ ] all the project you created must have readme, gitignore, gitattributes. 10 | - [ ] clone the project to your local work space 11 | - [ ] fork one of [gaocegege](https://github.com/gaocegege)'s repo, clone the original one and your fork to your local work space. 12 | - [ ] submit your a picture of your workspace using a editor/IDE that supports open folder. 13 | 14 | ## command line 15 | 16 | For both windows and linux users 17 | 18 | - [ ] change directory 19 | - [ ] change partition, from `C:` to `D:` 20 | - [ ] list files 21 | - [ ] create, remove folder 22 | 23 | For windows users, you can do the linx part after you have installed Git Bash, which will be introduced in the following Git course. 24 | 25 | For linux and mac users 26 | 27 | - [ ] ~~try `rm -rf /`~~ 28 | 29 | TODO: .... @arrowrowe 30 | 31 | ## vagrant 32 | 33 | - [ ] have `at15/lnmp` up and running 34 | - [ ] ssh into it. 35 | - [ ] `phpinfo` 36 | 37 | ## PHP 38 | 39 | - [ ] write a script and run it from commandline, and works like following 40 | 41 | ```` 42 | $ php hello.php mie 43 | $ Hello, this is mie! 44 | ```` 45 | 46 | - [ ] write a script and get its output from browser 47 | 48 | ```` 49 | http://localhost/hello.php?name=mie 50 | Hello, this is mie! 51 | ```` -------------------------------------------------------------------------------- /web/2016-spring/environment/images/at15-workspace.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyweb/course/2d6f7b4207be3a62861fce4332e8fb72d2d2b8e9/web/2016-spring/environment/images/at15-workspace.PNG -------------------------------------------------------------------------------- /web/2016-spring/environment/images/inception.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyweb/course/2d6f7b4207be3a62861fce4332e8fb72d2d2b8e9/web/2016-spring/environment/images/inception.jpg -------------------------------------------------------------------------------- /web/2016-spring/environment/images/mess-folders.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyweb/course/2d6f7b4207be3a62861fce4332e8fb72d2d2b8e9/web/2016-spring/environment/images/mess-folders.PNG -------------------------------------------------------------------------------- /web/2016-spring/environment/images/open_cmd.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyweb/course/2d6f7b4207be3a62861fce4332e8fb72d2d2b8e9/web/2016-spring/environment/images/open_cmd.PNG -------------------------------------------------------------------------------- /web/2016-spring/environment/images/virtualbox_xp.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyweb/course/2d6f7b4207be3a62861fce4332e8fb72d2d2b8e9/web/2016-spring/environment/images/virtualbox_xp.PNG -------------------------------------------------------------------------------- /web/2016-spring/environment/images/vmware_ub_server.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyweb/course/2d6f7b4207be3a62861fce4332e8fb72d2d2b8e9/web/2016-spring/environment/images/vmware_ub_server.PNG -------------------------------------------------------------------------------- /web/2016-spring/environment/images/win_cmd.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyweb/course/2d6f7b4207be3a62861fce4332e8fb72d2d2b8e9/web/2016-spring/environment/images/win_cmd.PNG -------------------------------------------------------------------------------- /web/2016-spring/environment/images/win_cmd_hello.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyweb/course/2d6f7b4207be3a62861fce4332e8fb72d2d2b8e9/web/2016-spring/environment/images/win_cmd_hello.PNG -------------------------------------------------------------------------------- /web/2016-spring/environment/index.rst: -------------------------------------------------------------------------------- 1 | Web Development Environment Setup 2 | ==================================== 3 | 4 | This course mainly tells you how to setup a web develop environment 5 | 6 | Contents: 7 | 8 | .. toctree:: 9 | :maxdepth: 2 10 | 11 | env 12 | workspace 13 | editor 14 | cmd 15 | virtual 16 | vagrant 17 | request 18 | linux 19 | nginx 20 | php 21 | homework 22 | 23 | You will start form the defination of environment to your how to organize your local workspace, the editor you use. 24 | How to use commandline, what is virtual machine, how vagrant makes a difference. The famous LNMP stack. The homework 25 | is quite simple, write a helloworld in php, and show the result in your browser. 26 | -------------------------------------------------------------------------------- /web/2016-spring/environment/linux.md: -------------------------------------------------------------------------------- 1 | # Linux 2 | 3 | - Cheap. No License fee, less electricity fee. 4 | - Open source. 5 | 6 | NOTE: Mac OSX is based on Unix, but it works like Linux distributions most of the time. 7 | 8 | ## Differences between Linux and Windows in Command line 9 | 10 | This only list some frequently asked questions when you start using command line. 11 | 12 | ### Directory separtor 13 | 14 | **Windows use `\` as directory separator, while Linux use `/`** 15 | 16 | Example 17 | 18 | Windows 19 | 20 | `partition` + `:\` + `folder` + `\` + `filename` 21 | 22 | ```` 23 | C:\Program Files\Adobe\Photoshop CC\amtlib.dll 24 | D:\学习\abs-132.rmvb 25 | ```` 26 | 27 | Linux 28 | 29 | `Folder` + `/` + `filename`. Linux DOES NOT have `partition` in path. NO `C`,`D` etc. 30 | 31 | ```` 32 | /home/at15/Downloads/abs-132.rmvb 33 | /etc/nginx/conf.d/tongqu.lk.conf 34 | ```` 35 | 36 | However, most programming lanague can deal with it automaticlly. 37 | 38 | ### Case sensitive 39 | 40 | - **Windows is NOT case sensitive** 41 | - **Linux IS cas sensitvie** 42 | 43 | Winodws 44 | 45 | ```` 46 | D:\Code\Happy.txt 47 | D:\Code\happy.txt -> This file is not allowed 48 | ```` 49 | 50 | Linux 51 | 52 | ```` 53 | /home/at15/Downloads/abs-123.rmvb -> ok 54 | /home/at15/Downloads/abs-123.rmvB -> ok, notice that b is upper case. 55 | ```` 56 | 57 | This could cause TROUBLE when you are using Git. 58 | 59 | TODO: how to solve that trouble ... and image, error message for that trouble. 60 | 61 | ### Password 62 | 63 | - **Windows have `*` to show you how many words you have entered for password** 64 | - **Linux shows nothing** 65 | 66 | TODO: images 67 | -------------------------------------------------------------------------------- /web/2016-spring/environment/nginx.md: -------------------------------------------------------------------------------- 1 | # Nginx 2 | 3 | [Nginx](http://nginx.org/) is a static server, though it could become an application server using lua, ie: [openresty](https://openresty.org/en/) 4 | 5 | > nginx [engine x] is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP/UDP proxy server, originally written by Igor Sysoev. 6 | 7 | TODO: 8 | 9 | - config file syntax 10 | - root 11 | - location 12 | 13 | ## Difference with Apache 14 | 15 | - fast 16 | -------------------------------------------------------------------------------- /web/2016-spring/environment/php.md: -------------------------------------------------------------------------------- 1 | # PHP 2 | 3 | The best language in the world 4 | 5 | ## php-fpm php mod_php 6 | -------------------------------------------------------------------------------- /web/2016-spring/environment/request.md: -------------------------------------------------------------------------------- 1 | # Request lifecycle 2 | 3 | We omit the low level and irrelevant part, this is the short version of the famous question 4 | [what happens when you type google.com into your browser and press enter](https://github.com/alex/what-happens-when). 5 | 6 | TODO: 7 | 8 | - my short video 9 | - browser make a http request. (omit tcp handshake etc) 10 | - nginx 11 | - php 12 | - mysql 13 | - return to browser 14 | - css 15 | - javascript 16 | - ajax (interaction without refresh the whole page) 17 | -------------------------------------------------------------------------------- /web/2016-spring/environment/vagrant.md: -------------------------------------------------------------------------------- 1 | # Vagrant 2 | 3 | [Official site](https://www.vagrantup.com/) 4 | 5 | > Create and configure lightweight, reproducible, and portable develop environment. 6 | 7 | ## Vagrant vs Virtual machine vs Docker 8 | 9 | - vagrant is more friendly for development 10 | - you should not package everthing in one docker image 11 | 12 | ## Concepts 13 | 14 | ### Vagrantfile 15 | 16 | ### Shared folder 17 | 18 | ### Port 19 | 20 | ### Provision 21 | 22 | ### SSH 23 | 24 | TODO: don't need to go into detail of ssh right away ... 25 | 26 | - vagrant ssh 27 | - putty 28 | 29 | ## Commands 30 | 31 | ### vagrant up 32 | 33 | ### vagrant ssh 34 | 35 | ### vagrant destroy 36 | 37 | ### vagrant 38 | 39 | ## Use the lnmp box 40 | 41 | [at15/lnmp](https://github.com/at15/lnmp) is a prconfiged box for LNMP stack. 42 | 43 | ```` 44 | vagrant box init at15/lnmp 45 | vagrant up 46 | ```` 47 | 48 | ## FAQ 49 | 50 | TODO: time out (ssh), VT-X 51 | -------------------------------------------------------------------------------- /web/2016-spring/environment/virtual.md: -------------------------------------------------------------------------------- 1 | # Virtual Machine 2 | 3 | ## How virtual machine works 4 | 5 | ![inception](images/inception.jpg) 6 | 7 | e.... in fact, I don't know how it works.... 8 | 9 | ## Concepts 10 | 11 | ### Host 12 | 13 | Your laptop 14 | 15 | ### Guest 16 | 17 | The Ubuntu system running inside virtualbox/vmware/hyper-v 18 | 19 | ### Shared folder 20 | 21 | You can edit your documents on host inside guest. You can also edit document inside guest in your host. 22 | 23 | ## Problems 24 | 25 | - Network 26 | - File sync 27 | - Resource wasted on GUI 28 | 29 | **Hard to config** 30 | 31 | ## Solution 32 | 33 | TODO: change to rst and link internal doc for vagrant 34 | 35 | - vagrant 36 | - docker 37 | -------------------------------------------------------------------------------- /web/2016-spring/environment/workspace.md: -------------------------------------------------------------------------------- 1 | # Workspace Setup 2 | 3 | How to orgnaize all your projects 4 | 5 | ## Problems 6 | 7 | **tl;dr** 8 | 9 | - version control and sync 10 | - name collision, ie: fork 11 | - too many projects, ie: [gaocegege](https://github.com/gaocegege) 12 | 13 | ### The long story 14 | 15 | (This is not real) 16 | 17 | #### Version Control and Sync 18 | 19 | Jack is working on his homework, he want to try a new algorithm, so he copied a new folder. 20 | 21 | ```` 22 | D:/Code/ 23 | -- homework 24 | -- homework-2 25 | ```` 26 | 27 | And Jack asked Mike to check his code, he send the code via email(QQ), and put Mike's modification in a new folder. 28 | 29 | ```` 30 | D:/Code/ 31 | -- homework 32 | -- homework-2 33 | -- homework-3 34 | ..... 35 | ```` 36 | 37 | And he got 10 homework and 4 labs for this course, boom! (No picture no BB) 38 | 39 | ![messy folders](images/mess-folders.PNG) 40 | 41 | Jack got a laptop and a PC, he have to copy all the code in flash disk in order to sync, and sometimes he forgot it. 42 | Jack want to go back to his old code, he want to add tag for certain code, like `fix-memory-leak`, also he needs to work with Mike. 43 | 44 | That's why `Git`, `GitHub` shows up. 45 | 46 | Git is a version control system, and GitHub is the most popular Git repository host, free for opensource projects. 47 | 48 | #### Name collision 49 | 50 | Jack forked a project, [gaocegege's scrala](https://github.com/gaocegege/scrala) 51 | 52 | ```` 53 | D:/Code/ 54 | -- scrala 55 | ```` 56 | 57 | But he wants to have a local copy for the original repo, so he have to rename it. 58 | 59 | ```` 60 | D:/Code/ 61 | -- scrala 62 | -- gaocegege-scrala 63 | ```` 64 | 65 | He wrote a scarala that can only be for his lab project 66 | 67 | ```` 68 | D:/Code/ 69 | -- scrala 70 | -- gaocegege-scrala 71 | -- lab-scrala 72 | ```` 73 | 74 | He is tired of renaming the repo. 75 | 76 | #### Too many projects 77 | 78 | Jack got homework, lab, outsource, opensource, for gf, for goddess's bf etc. 79 | 80 | ## Solution 81 | 82 | **tl;dr** 83 | 84 | - use git 85 | - tree 86 | - [the Go way](https://golang.org/doc/code.html) 87 | 88 | ### Put your folders in a tree 89 | 90 | You have many source for your projects, homework, lab, outsource, opensource, for gf, for goddess's bf etc. You can have workspace like the following 91 | 92 | ```` 93 | D:/Code/ 94 | -- homework 95 | -- 2016-Spring 96 | -- environment 97 | -- lab 98 | -- cit 99 | -- distributed-monitoring 100 | -- cat 101 | -- wangwangwang 102 | -- eclipse 103 | -- che 104 | -- flux 105 | -- che 106 | -- good-man 107 | -- ex 108 | -- python-final 109 | -- goodess-bf-1 110 | -- goodess-ex-bf 111 | -- master-thesis 112 | ```` 113 | 114 | ### Organize by Git host 115 | 116 | This is [the Go way](https://golang.org/doc/code.html) , if you have a parent directory for `bin`. 117 | 118 | Since it's a goode idea to have all your code in sync, you may have multiple Git host, GitHub for public repos, GitLab for internal projects 119 | 120 | ```` 121 | D:/Code/ 122 | -- github.com 123 | -- at15 124 | -- crawler 125 | -- how-to-play-tennis 126 | -- gaocegege 127 | -- scrala 128 | -- how-to-dig-holes 129 | -- git.tongqu.me 130 | -- tongqu 131 | -- tongqu5 132 | -- tongqu-api 133 | -- tongqu-web 134 | ```` 135 | 136 | the workspace for at15. the editor is [VSCode](https://code.visualstudio.com/) 137 | 138 | ![at15-workspace](images/at15-workspace.PNG) 139 | 140 | ## Reference 141 | 142 | - [Git](https://git-scm.com/) 143 | - [GitHub](https://github.com) 144 | -------------------------------------------------------------------------------- /web/2016-spring/git-html/branch.md: -------------------------------------------------------------------------------- 1 | # Git Branch 2 | 3 | ## What is branch? 4 | 5 | - Nearly every VCS has some form of branching support. 6 | - Branching means you diverge from the main line of development and continue to do work without messing with that main line. 7 | 8 | see the following picture 9 | 10 | ![image](./images/branch.png) 11 | 12 | ## Working with branches 13 | 14 | ### Create branch 15 | 16 | ``git branch `` 17 | 18 | ### Switch branch 19 | 20 | ``git checkout `` 21 | 22 | It is worth mentioning that if you want to checkout to an inexistent branch, you will get error message. Like this one. 23 | 24 | ``` 25 | $ git checkout vain-branch 26 | error: pathspec 'vain-branch' did not match any file(s) known to git. 27 | ``` 28 | But if you add ``-b`` option, you will create a new branch and switch to the new branch 29 | ``` 30 | $ git checkout -b vain-branch 31 | Switched to a new branch 'vain-branch' 32 | ``` 33 | 34 | 35 | ### Merge branch 36 | 37 | See the above picture, you will find sometimes branches should be merged. Run the following command, you will merge appointed branch into your current branch. 38 | 39 | ``git merge `` 40 | 41 | But frequently, The operation won't execute well when same codes were modified by different people in different branch. This time, when you run ``git merge``, git will tell you where are the conflicts. Like this one. 42 | 43 | ``` 44 | $ git merge gh-pages 45 | Auto-merging index.html 46 | CONFLICT (content): Merge conflict in index.html 47 | Automatic merge failed; fix conflicts and then commit the result. 48 | ``` 49 | You can see the conflict is in 'index.html', so open the file and find the conflict mark. 50 | 51 | ``` 52 | <<<<<<< HEAD 53 | The codes in current branch 54 | ====== 55 | The codes in merging branch 56 | >>>>>>> Merging branch 57 | ``` 58 | The codes under the ``<<<<<<< HEAD`` is your current branch codes, the codes between the ``====== `` and `>>>>>>> Merging branch` is the codes in merging branch. 59 | 60 | Here is a sample. 61 | ``` 62 | <<<<<<< HEAD:index.html 63 | 64 | ======= 65 | 68 | >>>>>>> gh-pages:index.html 69 | ``` 70 | 71 | ## Reference 72 | 73 | - [Learn Git Branching](http://pcottle.github.io/learnGitBranching/) 74 | -------------------------------------------------------------------------------- /web/2016-spring/git-html/html.md: -------------------------------------------------------------------------------- 1 | # HTML 2 | 3 | ## What is HTML? 4 | 5 | - HyperText Markup Language. 6 | - Describe web documents (the basic of web). 7 | - Consist of different tags. 8 | 9 | When you type a domain in browser, you send a request the website server. 10 | 11 | The website server will receive your request and return a HTML string to you. 12 | 13 | The browser will interpret the HTML string and display the web page. 14 | 15 | 16 | 17 | ## A Sample HTML 18 | 19 | ``` 20 | 21 | 22 | 23 | My first html 24 | 25 | 26 |
27 |

My first paragraph

28 |
29 |

My second paragraph.

30 | 31 | 32 | ``` 33 | 34 | - The text between ```` and ```` describes an HTML document. 35 | - The text between ```` and ```` provides information about the document. 36 | - The text between ```` and ```` provides a title for the document. 37 | - The text between ```` and ```` describes the visible page content. 38 | - The text between ``
`` and ``
`` describes a block element. 39 | - The text between ``

`` and ``

`` describes a paragraph. 40 | 41 | 42 | ## HTML DOM TREE 43 | 44 | If you look the above sample carefully, you will find the structure of the HTML is a tree. 45 | 46 | ``` 47 | html 48 | | \ 49 | head body 50 | | | \ 51 | title div p 52 | | 53 | p 54 | ``` 55 | 56 | This standard makes HTML more structuring, and be easy converted to object model which we can easily modify it. 57 | 58 | ## Reference 59 | 60 | - [W3schoool HTML Tutorial](http://www.w3schools.com/html/default.asp) 61 | 62 | -------------------------------------------------------------------------------- /web/2016-spring/git-html/images/branch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyweb/course/2d6f7b4207be3a62861fce4332e8fb72d2d2b8e9/web/2016-spring/git-html/images/branch.png -------------------------------------------------------------------------------- /web/2016-spring/git-html/images/commit_message_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyweb/course/2d6f7b4207be3a62861fce4332e8fb72d2d2b8e9/web/2016-spring/git-html/images/commit_message_0.png -------------------------------------------------------------------------------- /web/2016-spring/git-html/images/commit_message_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyweb/course/2d6f7b4207be3a62861fce4332e8fb72d2d2b8e9/web/2016-spring/git-html/images/commit_message_1.png -------------------------------------------------------------------------------- /web/2016-spring/git-html/images/git_vs_svn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyweb/course/2d6f7b4207be3a62861fce4332e8fb72d2d2b8e9/web/2016-spring/git-html/images/git_vs_svn.png -------------------------------------------------------------------------------- /web/2016-spring/git-html/index.rst: -------------------------------------------------------------------------------- 1 | Git & HTML 2 | ==================================== 3 | 4 | This course mainly tells you how to start writing HTMLs in an editor, using Git for version control. 5 | 6 | Contents: 7 | 8 | .. toctree:: 9 | :maxdepth: 2 10 | 11 | introduce 12 | setup 13 | workflow 14 | branch 15 | teamwork 16 | html 17 | 18 | 19 | 20 | You will start form the defination of environment to your how to organize your local workspace, the editor you use. 21 | How to use commandline, what is virtual machine, how vagrant makes a difference. The famous LNMP stack. The homework 22 | is quite simple, write a helloworld in php, and show the result in your browser. 23 | -------------------------------------------------------------------------------- /web/2016-spring/git-html/introduce.md: -------------------------------------------------------------------------------- 1 | # Git Introduce 2 | 3 | ## What is Git? 4 | 5 | The widely used source code management system for software development in the world. 6 | 7 | ## History 8 | 9 | - In 2002, the developers of the Linux kernel use [Bitkeeper](https://en.wikipedia.org/wiki/BitKeeper) to maintain the project, but the Bitkeeper is not good for developing. 10 | - In 2005, the copyright holder of BitKeeper, Larry McVoy, had withdrawn gratis use of the product after claiming that Andrew Tridgell had reverse-engineered the BitKeeper protocols. 11 | - In 2005, Torvalds decided to develop a distributed system to replace the Bitkeeper. So, he create git. 12 | 13 | ## Version Control 14 | 15 | You won't like this: 16 | 17 | ```` 18 | D:/Schoolwork/Group-work-1 19 | -- our-fancy-work-v1-outline-only 20 | -- our-fancy-work-v2-victor-part-done 21 | -- our-fancy-work-v2-cece-part-done 22 | -- our-fancy-work-v3-victor-and-cece-merged 23 | -- our-fancy-work-v3-victor-part-updated 24 | -- our-fancy-work-v4-victor-part-updated-again 25 | -- our-fancy-work-v5-victor-part-updated-again-and-cece-merged 26 | -- our-fancy-work-v8-final 27 | -- our-fancy-work-v9-final-updated-by-victor 28 | -- our-fancy-work-v9-final-updated-by-cece 29 | -- our-fancy-work-v10-final-updated-merged 30 | -- our-fancy-work-v11-final-final 31 | ```` 32 | 33 | What if we have Git? 34 | 35 | ```` 36 | D:/Schoolwork/Group-work-1 37 | -- our-fancy-work 38 | -- .git # <- Hidden 39 | ```` 40 | 41 | ```` 42 | $ git log --graph --oneline 43 | * 1fa35d1 final final 44 | * d0eb39d Merge branch 'cece' 45 | |\ 46 | | * 10604d8 final updated by cece 47 | * | 243bd99 final updated by victor 48 | |/ 49 | * 8e4c071 final 50 | * a8e02e7 Merge branch 'master' into cece 51 | |\ 52 | | * 222a46f victor part updated again 53 | | * 391ea6c victor part updated 54 | * | 7b3fe97 Merge branch 'master' into cece 55 | |\ \ 56 | | |/ 57 | | * e919d2d victor part done 58 | * | e0c35e5 cece part done 59 | |/ 60 | * 8ab6c50 outline only 61 | ```` 62 | 63 | ## Collaboration 64 | 65 | When you work in a team. It's necessary to integrate everyone's work. 66 | 67 | - copying and cover the files ? 68 | - svn, working-copy collaboration 69 | - git, repo-to-repo collaboration 70 | 71 | ![image](./images/git_vs_svn.png) 72 | 73 | 74 | ## Benefit 75 | 76 | - Detailed history. 77 | - Better collaboration: safely write on your own, then merge. 78 | - Peer review. 79 | 80 | 81 | ## Reference 82 | 83 | - [Wike.Git(software)](https://en.wikipedia.org/wiki/Git_(software)) 84 | -------------------------------------------------------------------------------- /web/2016-spring/git-html/setup.md: -------------------------------------------------------------------------------- 1 | # Git Setup 2 | 3 | ## Install on windows 4 | 5 | Maybe it's complicated, but I don't use windows for several years. But with the big news for ubuntu in windows10, everything may become easy. 6 | 7 | ## Install on Mac OS X or Linux 8 | 9 | I don't want to tell you, because it's so easy. 10 | 11 | ## Use command line 12 | 13 | If you are in Windows 14 | 15 | - Go to the directory you want to work in, and click your right mouse and choose git bash. 16 | - Input 'git' to see the usage 17 | 18 | if you are in Mac OS X or Linux 19 | - Input 'git' to see the usage 20 | 21 | if should look like this 22 | 23 | ``` 24 | $ git 25 | usage: git [--version] [--help] [-C ] [-c name=value] 26 | [--exec-path[=]] [--html-path] [--man-path] [--info-path] 27 | [-p | --paginate | --no-pager] [--no-replace-objects] [--bare] 28 | [--git-dir=] [--work-tree=] [--namespace=] 29 | [] 30 | ``` 31 | 32 | ## First command: set up your personal info 33 | 34 | ``` 35 | $ git config --global user.name [username] 36 | $ git config --global user.email [email] 37 | ``` 38 | 39 | The commands above will let the git know who you are. the ``global`` option will set the attribute globally. 40 | 41 | Remove the ``global`` will set the attribute inside your project. 42 | 43 | ## The basic commands you have to know 44 | 45 | ### Initialize a repository 46 | ``git init`` 47 | ``` 48 | $ git init 49 | Initialized empty Git repository in /Users/sway/WebProj/test-project/.git/ 50 | ``` 51 | 52 | This command will initialize a repository in current directory. 53 | ``` 54 | $ ls -a 55 | . .. .git 56 | ``` 57 | And as you see, a new subdirectory named ``.git`` was created in current directory which contains all your repository files. 58 | 59 | ### Clone an existing repository 60 | 61 | ``git clone [url]`` 62 | 63 | ``` 64 | $ git clone https://github.com/dyweb/web-stuff 65 | remote: Counting objects: 695, done. 66 | remote: Compressing objects: 100% (11/11), done. 67 | remote: Total 695 (delta 4), reused 0 (delta 0), pack-reused 684 68 | Receiving objects: 100% (695/695), 1.56 MiB | 224.00 KiB/s, done. 69 | Resolving deltas: 100% (320/320), done. 70 | Checking connectivity... done. 71 | ``` 72 | 73 | This will copy the a existing remote repository into your local and every version of every file for the history of the project will be pulled down. 74 | 75 | ### Checking the status of the repository 76 | 77 | ``git status`` 78 | 79 | ``` 80 | $ git status 81 | 82 | ``` 83 | As the title says, this command will show you current status of the repository. 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /web/2016-spring/git-html/teamwork.md: -------------------------------------------------------------------------------- 1 | # Git Teamwork 2 | 3 | ## Commit message 4 | 5 | Why we should write good commit messages? 6 | 7 | - To speed up the reviewing process. 8 | - To help us write a good release note. 9 | - To help the future maintainers. 10 | 11 | How to write good commit messages? 12 | 13 | Cause we are all students, I don't think we should obey lots of rules of writing commit messages. If your messages can satisfy the following three points, I think it's ok. 14 | 15 | - Write the accuracy first word in your message subject. Like fix, enhance, doc, style, bug ... 16 | - Don't take your subjective emotion. Like fuck, wo cao, !!! ... 17 | - Make the messages clear. Know the meaning of your own message at least... 18 | 19 | ## Comparison of two different teamwork 20 | 21 | ![image](./images/commit_message_0.png) 22 | 23 | 24 | ![image](./images/commit_message_1.png) 25 | 26 | **Every commit messages will be your possible black history ~ ** 27 | 28 | ## Maintain multiple branches 29 | 30 | If you only have one branches, you may meet some problems. 31 | 32 | - Boss: The clients say the product should add xxx function! You should add it before tomorrow! 33 | - *You add the function in you only branch hardly, you forget other programmer change some architecture yesterday. Finally, you build a incomplete version and hand out the clients* 34 | - It's a stupid tragedy. 35 | 36 | So, you should always maintain multiple branches in your work, especially in teamwork. 37 | 38 | Popularly, we always maintain two different types of branches. 39 | 40 | - Main branches 41 | - master 42 | - stable 43 | 44 | - Support branches 45 | - feature 46 | - bug 47 | - hotfix 48 | 49 | ## Reference 50 | 51 | - [A commit message guid by Ruan Yifeng](http://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html) 52 | 53 | - [Git/GitHub branching standards & conventions](https://gist.github.com/digitaljhelms/4287848) 54 | 55 | -------------------------------------------------------------------------------- /web/2016-spring/git-html/workflow.md: -------------------------------------------------------------------------------- 1 | # Git Workflow 2 | 3 | ## Submit your local change 4 | 5 | Last topic, we list some common commands, like ``git init``, ``git clone``, ``git status``. Now we will track a change from your local repository to remote. 6 | 7 | For example we create a README.md file in your initialized directory. Now, run ``git status`` 8 | 9 | ``` 10 | $ git status 11 | On branch master 12 | 13 | Initial commit 14 | 15 | Untracked files: 16 | (use "git add ..." to include in what will be committed) 17 | 18 | README.md 19 | ``` 20 | 21 | As we see, git found a new file named README.md was created in the directory, and the file hasn't been tracked. 22 | 23 | So, we follow it's guide, run ``git add`` to add the file to the git index, which is called stage changes. 24 | 25 | ``` 26 | $ git add README.md 27 | $ git status 28 | On branch master 29 | 30 | Initial commit 31 | 32 | Changes to be committed: 33 | (use "git rm --cached ..." to unstage) 34 | 35 | new file: README.md 36 | ``` 37 | Now, the file has been really added to git index, but before you want to submit it to remote repository, you should use ``git commit`` to create record contained all your stage changes. 38 | ``` 39 | $ git commit -m"Init" 40 | [master (root-commit) 8ecc069] Init 41 | 1 file changed, 1 insertion(+) 42 | create mode 100644 README.md 43 | 44 | $ git status 45 | On branch master 46 | nothing to commit, working directory clean 47 | ``` 48 | This time, run ``git status``, you will see nothing to commit, it proves that your local change has been saved as a commit record. 49 | 50 | Use ``git push`` to submit your commit to remote master branch. 51 | 52 | ``` 53 | $ git push origin master 54 | ``` 55 | 56 | 57 | ## Update your local repository from remote 58 | 59 | When you find the remote respositoy has updated some changes, you can use ``git pull`` to fetch the latest changes. 60 | ``` 61 | $ git pull origin master 62 | ``` -------------------------------------------------------------------------------- /web/2016-spring/http-rest/assignment.md: -------------------------------------------------------------------------------- 1 | # Assignment 2 | 3 | ## Hand In 4 | 5 | - Email: web@dongyue.io 6 | - GitHub / GitLab Tq: 7 | 1. Crete a new repository and make it public 8 | 2. Open an issue [here](https://github.com/dyweb/course/issues) and tell us your repository link 9 | - QQ, Wechat is also OK! 10 | 11 | ## Due? 12 | - Deadline: May 16th 13 | - Answers available next week 14 | 15 | ## Assignment I 16 | 17 | 1. Learn to use Chrom DevTool & Fiddler to observe HTTP connections. 18 | 2. Select a PHP microframework (Slim/Flight/...) and implement a simple REST service of a to-do list. 19 | ```c 20 | GET /api/v1/tasks // Get all tasks 21 | GET /api/v1/tasks/:id // Get a task by id 22 | POST /api/v1/tasks // Create a new task 23 | PUT /api/v1/tasks/:id // Update a given task 24 | DELETE /api/v1/tasks/:id // Delete a task 25 | ``` 26 | 3. (Optional) Write a crawler for [Tongqu Act API](http://tongqu.me/api/act/type). Here is the [doc](https://github.com/dyweb/android-stuff/blob/master/interview/old/api.md) of this API. 27 | 28 | ## Reading Materials 29 | 30 | ### Tutorials 31 | - HTTP: The Protocol Every Web Developer Must Know 32 | - [Part I](http://code.tutsplus.com/tutorials/http-the-protocol-every-web-developer-must-know-part-1--net-31177) 33 | - [Part II](http://code.tutsplus.com/tutorials/http-the-protocol-every-web-developer-must-know-part-2--net-31155) 34 | - [深入理解 HTTP 协议](http://www.360doc.com/content/10/0930/17/3668821_57590979.shtml) 35 | - [HTTP 教程](http://www.tutorialspoint.com/http/) 36 | 37 | - [RESTful API 设计指南](http://www.ruanyifeng.com/blog/2014/05/restful_api.html) 38 | - [理解 RESTful 架构](http://www.ruanyifeng.com/blog/2011/09/restful.html) 39 | - [REST API Tutorial](http://www.restapitutorial.com/) 40 | 41 | ### Frameworks 42 | - [Slim](http://www.slimframework.com/) 43 | - [Flight](http://flightphp.com/) 44 | 45 | ### Tools 46 | - [Fiddler](http://www.telerik.com/fiddler) 47 | - [Chrome DevTools OverView](https://developer.chrome.com/devtools) 48 | - [Wireshark](https://www.wireshark.org/) 49 | 50 | - [Postman](http://www.getpostman.com/) 51 | - [Scrapy](http://scrapy.org/) 52 | -------------------------------------------------------------------------------- /web/2016-spring/http-rest/index.rst: -------------------------------------------------------------------------------- 1 | HTTP & RESTful API 2 | ==================================== 3 | 4 | This course gives you a brief introduction of HTTP protocol & RESTful API. 5 | 6 | Contents: 7 | 8 | .. toctree:: 9 | :maxdepth: 2 10 | 11 | slide 12 | assignment 13 | -------------------------------------------------------------------------------- /web/2016-spring/http-rest/outline.md: -------------------------------------------------------------------------------- 1 | ## HTTP & RESTful API 2 | 3 | 0. What happened entering a website (Simple Ver.) 5 min 4 | - https://github.com/alex/what-happens-when 5 | 1. How can we get access to pages? 5 min 6 | - Type an address and enter 7 | - The browser sends a request to a server 8 | - The server gives back a response 9 | - The browser parse the response and render the page 10 | 2. What does request/response pair work? 10 min 11 | - By a application layer protocol HTTP 12 | - Stateless 13 | - Port: 80 14 | - Where is the server? 15 | - IP address 16 | - DNS Server 17 | - DNS Pollution 18 | - How to observe HTTP? 19 | - Chrome DevTool 20 | - Fiddler 21 | 3. Basic structure of HTTP 20 min 22 | - Version 1 min 23 | - HTTP/1.0, HTTP/1.1, HTTP/2.0 24 | - URI 2 min 25 | - URL, URN 26 | - Locator for resources 27 | - format: scheme:[//[user:password@]host[:port]][/]path[?query][#fragment] 28 | - protocol, http, https, ftp, ... 29 | - server name ip 30 | - port 31 | - path 32 | - query string 33 | - fragment 34 | - Verb 5 min 35 | - GET 36 | - POST 37 | - Post Content 38 | - x-www-url-encoded 39 | - form-data 40 | - customized type 41 | - PUT/DELETE/PATCH 42 | - HEAD/OPTIONS 43 | - Status Code 5 min 44 | - 1xx 45 | - 2xx 46 | - 200 OK 47 | - 201 Created 48 | - 202 Accepted 49 | - 204 No Content 50 | - 3xx 51 | - 301 Moved Permanently 52 | - 302 Moved Temporarily (header Location) 53 | - 304 Not Modified 54 | - 4xx 55 | - 400 Bad Request 56 | - 401 Unauthorized 57 | - 403 Forbidden 58 | - 404 Not Found 59 | - 405 Method Not Allowed 60 | - 409 Conflict 61 | - 5xx 62 | - 500 Internal Server Error 63 | - 501 Not Implemented 64 | - 502 Bad Gateway 65 | - 503 Service Unavailable 66 | - Message Format 5 min 67 | - Request/Response Pair 68 | - General Header 69 | general-header = Cache-Control 70 | | Connection 71 | | Date 72 | | Pragma 73 | | Trailer 74 | | Transfer-Encoding 75 | | Upgrade 76 | | Via 77 | | Warning 78 | - Entity Header 79 | entity-header = Allow 80 | | Content-Encoding 81 | | Content-Language 82 | | Content-Length 83 | | Content-Location 84 | | Content-MD5 85 | | Content-Range 86 | | Content-Type * 87 | | Expires 88 | | Last-Modified 89 | - Request Header 90 | GET /articles/http-basics HTTP/1.1 91 | Host: www.articles.com 92 | Connection: keep-alive 93 | Cache-Control: no-cache 94 | Pragma: no-cache 95 | Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 96 | 97 | request-header = Accept * 98 | | Accept-Charset 99 | | Accept-Encoding 100 | | Accept-Language 101 | | Authorization 102 | | Expect 103 | | From 104 | | Host * 105 | | If-Match 106 | | If-Modified-Since 107 | | If-None-Match 108 | | If-Range 109 | | If-Unmodified-Since 110 | | Max-Forwards 111 | | Proxy-Authorization 112 | | Range 113 | | Referer * 114 | | TE 115 | | User-Agent * 116 | - Response Header 117 | response-header = Accept-Ranges 118 | | Age 119 | | ETag 120 | | Location * 121 | | Proxy-Authenticate 122 | | Retry-After 123 | | Server 124 | | Vary 125 | | WWW-Authenticate 126 | - Body 127 | - HTML 128 | - Other format 129 | 4. Identification and Authentication 130 | - Identification 5 min 131 | - Host, Referer, User-Agent 132 | - Cookie 133 | - Session 134 | - OAuth 135 | - Authentication 5 min 136 | - Basic Auth 137 | - Secure HTTP (SSL) 138 | 5. HTTP Caching 5 min 139 | - Client Cache 140 | - Cache-Control 141 | - no-cache 142 | - max-age 143 | - Expires (Old) 144 | - Server Cache 145 | - Last-Modified 146 | - ETag 147 | - Application cache 148 | 6. RESTful API 17 min 149 | - API? 1 min 150 | - REST? 1 min 151 | - Resource based 152 | - Web Service 153 | - REST examples 5 min 154 | - GitHub API 155 | - How to use RESTful API 10 min 156 | - curl 157 | - Postman 158 | 7. RESTful API Design 35 min 159 | - Versioning 2 min 160 | - Accept 161 | - Ugly URL 162 | - Naming 5 min 163 | - nouns 164 | - Verbs 5 min 165 | - Filtering (Query String) 5 min 166 | - Status Code 5 min 167 | - Documents 2 min 168 | - Authentication 9 min 169 | - Cookie based 2 min 170 | - JWT 1 min 171 | - OAuth 1 min 172 | - Content Type 173 | - JSON 2 min 174 | - XML 2 min 175 | -------------------------------------------------------------------------------- /web/2016-spring/http-rest/slide.md: -------------------------------------------------------------------------------- 1 | # Slide 2 | 3 | The slide can be found here: 4 | 5 | [Slide](http://dyweb.github.io/course/web/2016_Spring/html-rest/index.html) 6 | -------------------------------------------------------------------------------- /web/2016-spring/index.rst: -------------------------------------------------------------------------------- 1 | 2016 Spring 2 | ==================================== 3 | 4 | Courses for 2016 Spring, the last semester in Rotunda 5 | 6 | Contents: 7 | 8 | .. toctree:: 9 | :maxdepth: 2 10 | 11 | environment/index 12 | git-html/index 13 | instant-php/index 14 | http-rest/index 15 | 16 | `original schedule`_ is in dyweb/web-stuff repo. 17 | 18 | .. _original schedule: https://github.com/dyweb/web-stuff/tree/master/lecture/web-2016-spring 19 | -------------------------------------------------------------------------------- /web/2016-spring/instant-php/assignment.md: -------------------------------------------------------------------------------- 1 | # Assignment 2 | 3 | ## Hand In 4 | 5 | - Email: web@dongyue.io 6 | - GitHub / GitLab Tq: 7 | 1. Crete a new repository and make it public 8 | 2. Open an issue [here](https://github.com/dyweb/course/issues) and tell us your repository link 9 | - QQ, Wechat is also OK! 10 | 11 | ## Due? 12 | - Deadline: May 2nd 13 | - Answers available next week 14 | 15 | ## Assignment I 16 | 17 | Finish a simple To-do List application. 18 | 19 | - Only one file "todo.php" is enough 20 | - Multiple files are also ok 21 | - Try to implement displaying, creating, editing & deleting of to-do items 22 | - No JS & CSS needed 23 | - Just focus on PHP coding 24 | - (Advanced) Try to add file uploading in item creating form 25 | - *Tips: Use $_FILES superglobal* 26 | 27 | ## Assignment II 28 | 29 | The output of the following code looks strange. Try to figure out why. 30 | 31 | ```php 32 | 46 | ``` 47 | 48 | 49 | ## Assignment III 50 | 51 | - Implement simple login logic 52 | - 4 files needed: `index.php`, `private.php`, `login.php`, `logout.php` 53 | - Only a user who has logged in has access to `private.php` 54 | - Use `Session` to finish this assignment 55 | 56 | ## Assignment IV 57 | 58 | Finish an event registering site (simple-tongqu). 59 | 60 | - You need to use implement: 61 | - Event List 62 | - Event Registration CRUD 63 | - Register an event 64 | - Modify registering info 65 | - Exit an event 66 | - Get all the registrations 67 | - Login is not needed 68 | - You can implement it anyway 69 | - Keep data in disk files 70 | - No database is needed 71 | - You need to split components, logic & views 72 | - aka. MVC in later lectures 73 | - Suggested structure 74 | - register.php 75 | - event.php 76 | - libraries/functions.php 77 | - libraries/Event.php 78 | - libraries/File.php 79 | - views/register_xxxx.php, views/register_yyyy.php 80 | - views/event_xxxx.php, views/event_yyyy.php 81 | 82 | ## Reading Materials 83 | 84 | ### Tutorials 85 | - [Codecademy PHP Tutorial](https://codecademy.com) 86 | - [*PHP and MySQL Web Development (4th edition)*](https://book.douban.com/subject/2118632/) 87 | - [慕课网 PHP 入门篇](http://www.imooc.com/view/54) 88 | - [慕课网 PHP 进阶篇](http://www.imooc.com/view/26) 89 | - [PHP Fundamentals](http://code.tutsplus.com/courses/php-fundamentals) 90 | 91 | ### Guides 92 | - [PHP Manual](http://www.php.net/manual) 93 | - [The Best Way to Learn PHP](http://code.tutsplus.com/tutorials/the-best-way-to-learn-php--net-22287) 94 | - [PHP: The Right Way](http://www.phptherightway.com/) 95 | -------------------------------------------------------------------------------- /web/2016-spring/instant-php/index.rst: -------------------------------------------------------------------------------- 1 | Instant PHP 2 | ==================================== 3 | 4 | This course mainly tells you how to get a quick start with the best programming language PHP. 5 | 6 | Contents: 7 | 8 | .. toctree:: 9 | :maxdepth: 2 10 | 11 | source 12 | slide 13 | assignment 14 | -------------------------------------------------------------------------------- /web/2016-spring/instant-php/outline.md: -------------------------------------------------------------------------------- 1 | # Guideline of Instant PHP 2 | 3 | - What is PHP? 4 | - Personal Homepage Processor 5 | - PHP: Hypertext Preprocessor 6 | - The best programming language in the world 7 | - Why to use PHP? 8 | - Server logic 9 | - Easy & fast 10 | - Environment 11 | - 5 min XAMPP Configure 12 | - Vagrant 13 | - PHP Built-in Server 14 | - Our Goal 15 | - Ticket Order System 16 | - First Try: Order Page `order.php` 17 | - Form Element 18 | - Form Controls 19 | - Receive Form Data (GET Version) 20 | - `$_GET` 21 | - URL 22 | - Query String 23 | - Handle Form Data 24 | - Use variables to store 25 | - Weak types 26 | - Concancate string (`.`) 27 | - Format result (`date`, `number_format`, `sprintf`) 28 | - Show Order Result 29 | - Next Try: Complete Order Page `complete_order.php` 30 | - `$_GET` or `$_POST` 31 | - HTTP Verbs 32 | - Display repeated items 33 | - Array / `foreach` 34 | - `` (PHP 7 only) 39 | - `??` operator (PHP 7 only) 40 | - `is_xxx()`, `xxxval()`, `trim` 41 | - `filter_var()`, `preg_match()` (Leave it in a homework) 42 | - `isset` 43 | - Store & Read Data 44 | - `@` operator 45 | - `file_get_contents`, `file_put_contents` 46 | - `fopen`, `fwrite`, `fclose` (Leave it in a homework) 47 | - serialization 48 | - `explode`, `implode` 49 | - `serialize`, `unserialize` (Leave it in a homework) 50 | - `$_FILE`, file_handling (Leave it in a homework) 51 | - Third Try: Cart Page 52 | - Multiple pages 53 | - Page redirect 54 | - `header('Location: xxx.php')` 55 | - Split code & logic 56 | - `function`, scope 57 | - type declaration (PHP 7 only) 58 | - strict types (PHP 7 only) 59 | - External files: `require` 60 | - Split logic & view: `include` 61 | - PHP Template 62 | - Heredoc, Nowdoc 63 | - `define`, `const` 64 | - Store user status 65 | - Cookie / LocalStorage 66 | - Session, `$_SESSION` 67 | - Manage session 68 | - `NULL`, `isset`, `unset`, `empty` 69 | - Associative Array 70 | - Advanced `foreach` 71 | - Array & Reference (Leave it in a homework) 72 | - Another Try: Wrap cart into a component 73 | - Code Style: PSR-0, PSR-2 74 | - Class & Namespace: PSR-4 75 | - `__construct` 76 | - Inheritance `public`, `protected`, `private` 77 | - `$this` 78 | - Package Manager: PEAR & Composer 79 | - Exception 80 | - PHP Error Handling 81 | - PHP Exception Handling 82 | - SPL Exception Wrappers 83 | - SPL (Standard PHP Libraries) 84 | - Use component in our project 85 | - Assignment: 86 | - (Easy) Single page `todo.php` 87 | - (Medium) With image upload 88 | - (Medium) [Array & Reference] The output of the following code looks strange. Try to figure out why. 89 | ```php 90 | 2 | 3 | 4 | 5 | Ticket Ordering 6 | 7 | 8 |

Ticket Ordering

9 |

You are ordering tickets of the concert Hello World.

10 |
11 |

12 | 13 | 14 |

15 |

16 | 17 | 18 |

19 | 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /web/2016-spring/instant-php/src/v1/process.php: -------------------------------------------------------------------------------- 1 | 19 |

Ticket Ordering

20 |

Your order was created successfully.

21 |
    22 |
  • Name:
  • 23 |
  • Tickets:
  • 24 |
  • Amount: $
  • 25 |
  • Ordered at:
  • 26 |
  • Order No:
  • 27 |
28 | -------------------------------------------------------------------------------- /web/2016-spring/instant-php/src/v2/.gitignore: -------------------------------------------------------------------------------- 1 | /data.txt -------------------------------------------------------------------------------- /web/2016-spring/instant-php/src/v2/complete_order.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | Ticket Ordering 9 | 10 | 11 |

Ticket Ordering

12 |

You are ordering tickets of the concert Hello World.

13 |
14 |

15 | 16 | 17 |

18 | $area): ?> 19 |

20 |
21 | 22 | " type="number" placeholder="Quantity" min="0" max="5" style="width: 100px;"> 23 |

24 | 25 | 26 |
27 | 28 | 29 | -------------------------------------------------------------------------------- /web/2016-spring/instant-php/src/v2/process.php: -------------------------------------------------------------------------------- 1 | 5 || $quantities[$i] < 0) { // If quantity[i] is not in the range of [0, 5] 18 | die('Quantity should be between 0 and 5'); // Print error message and exit 19 | } 20 | } 21 | 22 | // Prepare data to store on our disk 23 | $data = "Name: $name "; // Set $data with "Name: xxx" 24 | $data .= "Tickets: " . implode($quantities, ','); // Append ticket info with turning $quantities into a string 25 | $data .= PHP_EOL; // Append EOL (usually "\n" in Linux) character 26 | 27 | // Open data.txt and write our data to this file 28 | $result = @file_put_contents('data.txt', $data, FILE_APPEND); 29 | if ($result === false) { // If the writing operation failed 30 | $error = error_get_last(); // Get last error 31 | echo $error['message'] . '
'; // Print error message 32 | die('Failed to write data into data.txt'); // Print failure info and exit 33 | } 34 | 35 | // Render HTML 36 | ?> 37 | 38 | 39 | 40 | 41 | Ticket Ordering 42 | 43 | 44 |

Ticket Ordering

45 |

Your order was created successfully.

46 |
    47 |
  • Name:
  • 48 |
  • Tickets: 49 |
      50 | $area): ?> 51 |
    • 52 | 53 |
    54 |
  • 55 |
56 | 57 | 58 | -------------------------------------------------------------------------------- /web/2016-spring/instant-php/src/v3/add_item.php: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | My Cart 12 | 13 | 14 |

My Cart

15 |

Here is your cart.

16 | 17 | 18 |
19 |
    20 | $item): ?> 21 |
  • Name:
  • 22 |
  • Quantity: 23 | " 24 | type="number" 25 | value=""> 26 |
  • 27 |
  • 28 | Remove 29 |
  • 30 | 31 |
32 | 33 |
34 | 35 | 36 |
37 |

Add new item

38 |

39 | 40 | 41 | 42 |

43 |
44 | 45 | 46 | -------------------------------------------------------------------------------- /web/2016-spring/instant-php/src/v3/include/function.php: -------------------------------------------------------------------------------- 1 | 'Area A Ticket', 'quantity' => 1], // Every item in the array is an array ['name' => x, 'quantity' => x] 22 | ['name' => 'Area B Ticket', 'quantity' => 2], // Use ',' to separate each item in an array 23 | ['name' => 'Area C Ticket', 'quantity' => 3], 24 | ['name' => 'Area D Ticket', 'quantity' => 4] // The ',' after the last item can be omitted 25 | ]; 26 | } 27 | 28 | /** 29 | * Get the cart from user session. 30 | * @return array 31 | */ 32 | function get_cart() { 33 | // Create a new cart if no cart available 34 | if (!isset($_SESSION['cart'])) { 35 | create_cart(); 36 | } 37 | 38 | // Return the cart fetched from user session 39 | return $_SESSION['cart']; 40 | } 41 | 42 | /** 43 | * Set the quantity of the given item in the cart. 44 | * @param string $item_name 45 | * @param int $quantity If $quantity <= 0, the item will be 46 | * removed from the cart. 47 | */ 48 | function set_item_quantity($item_name, $quantity) { 49 | if ($quantity <= 0) { // If the quantity of the item is not positive 50 | remove_item($item_name); // Remove the item directly 51 | return; // Exit function handling 52 | } 53 | 54 | foreach ($_SESSION['cart'] as &$item) { // Iterate each item in the cart by reference 55 | if ($item['name'] === $item_name) { // Look for the item with the given name 56 | $item['quantity'] = $quantity; // Set the new quantity 57 | return; // Exit function handling 58 | } 59 | } 60 | 61 | // If the item is not found, add it into the cart 62 | $_SESSION['cart'][] = [ // $val[] = 1 is the same as array_push($val, 1) 63 | 'name' => $item_name, 64 | 'quantity' => $quantity 65 | ]; 66 | } 67 | 68 | /** 69 | * Get the given item in the cart specified by item name. 70 | * @param string $item_name 71 | * @return array|null If the item is not found, null will be returned. 72 | */ 73 | function get_item($item_name) { 74 | foreach ($_SESSION['cart'] as $item) { 75 | if ($item['name'] === $item_name) { 76 | return $item_name; // Return the item when found 77 | } 78 | } 79 | 80 | return null; // Return null when not found 81 | } 82 | 83 | /** 84 | * Add a new item into the cart. 85 | * @param string $item_name 86 | */ 87 | function add_item($item_name) { 88 | if (get_item($item_name) !== null) { // If the item exists in the cart 89 | return; // Exit function handling 90 | } 91 | 92 | $_SESSION['cart'][] = [ 93 | 'name' => (string) $item_name, 94 | 'quantity' => 1 // The quantity must be positive 95 | ]; 96 | } 97 | 98 | /** 99 | * Remove an item from the cart. 100 | * @param string $item_name 101 | */ 102 | function remove_item($item_name) { 103 | foreach ($_SESSION['cart'] as $i => $item) { 104 | if ($item['name'] === $item_name) { 105 | unset($_SESSION['cart'][$i]); // Remove the item from the cart 106 | return; 107 | } 108 | } 109 | } 110 | 111 | // No closing tag needed in pure php file 112 | -------------------------------------------------------------------------------- /web/2016-spring/instant-php/src/v3/remove_item.php: -------------------------------------------------------------------------------- 1 | $quantity) { 13 | set_item_quantity((string) $name, $quantity); 14 | } 15 | 16 | // Redirect to cart page 17 | redirect('cart.php'); 18 | 19 | // No closing tag needed in pure php file 20 | -------------------------------------------------------------------------------- /web/2016-spring/instant-php/src/v4/add_item.php: -------------------------------------------------------------------------------- 1 | getItem($name) !== null) { 21 | die('Item exists'); 22 | } 23 | 24 | // Add it to the cart 25 | $cart->addItem($name); 26 | 27 | // Redirect to cart page 28 | header('Location: cart.php'); 29 | -------------------------------------------------------------------------------- /web/2016-spring/instant-php/src/v4/cart.php: -------------------------------------------------------------------------------- 1 | removeItem($name); 19 | 20 | // Redirect to cart page 21 | header('Location: cart.php'); 22 | -------------------------------------------------------------------------------- /web/2016-spring/instant-php/src/v4/save_cart.php: -------------------------------------------------------------------------------- 1 | $quantity) { 19 | $cart->setItemQuantity((string) $name, $quantity); 20 | } 21 | 22 | // Redirect to cart page 23 | header('Location: cart.php'); 24 | -------------------------------------------------------------------------------- /web/2016-spring/instant-php/src/v4/src/Dy/Component/Cart.php: -------------------------------------------------------------------------------- 1 | cartKey = $cartKey; 29 | session_start(); 30 | } 31 | 32 | /** 33 | * Get the cart from user session. 34 | * @return array 35 | */ 36 | public function getItems() 37 | { 38 | // Create a new cart if no cart available 39 | if (!isset($_SESSION[$this->cartKey])) { 40 | $this->createCart(); 41 | } 42 | 43 | // Return the cart fetched from user session 44 | return $_SESSION[$this->cartKey]; 45 | } 46 | 47 | /** 48 | * Set the quantity of the given item in the cart. 49 | * @param string $itemName 50 | * @param int $quantity If $quantity <= 0, the item will be 51 | * removed from the cart. 52 | */ 53 | public function setItemQuantity($itemName, $quantity) 54 | { 55 | if ($quantity <= 0) { // If the quantity of the item is not positive 56 | $this->removeItem($itemName); // Remove the item directly 57 | return; // Exit function handling 58 | } 59 | 60 | foreach ($_SESSION[$this->cartKey] as &$item) { // Iterate each item in the cart by reference 61 | if ($item['name'] === $itemName) { // Look for the item with the given name 62 | $item['quantity'] = $quantity; // Set the new quantity 63 | return; // Exit function handling 64 | } 65 | } 66 | 67 | // If the item is not found, add it into the cart 68 | $this->addItem($itemName); 69 | } 70 | 71 | /** 72 | * Get the given item in the cart specified by item name. 73 | * @param string $itemName 74 | * @return array|null If the item is not found, null will be returned. 75 | */ 76 | public function getItem($itemName) 77 | { 78 | foreach ($_SESSION[$this->cartKey] as $item) { 79 | if ($item['name'] === $itemName) { 80 | return $itemName; // Return the item when found 81 | } 82 | } 83 | 84 | return null; // Return null when not found 85 | } 86 | 87 | /** 88 | * Add a new item into the cart. 89 | * @param string $itemName 90 | */ 91 | public function addItem($itemName) 92 | { 93 | if ($this->getItem($itemName) !== null) { // If the item exists in the cart 94 | return; // Exit function handling 95 | } 96 | 97 | $_SESSION[$this->cartKey][] = [ 98 | 'name' => (string) $itemName, 99 | 'quantity' => 1 // The quantity must be positive 100 | ]; 101 | } 102 | 103 | /** 104 | * Remove an item from the cart. 105 | * @param string $itemName 106 | */ 107 | public function removeItem($itemName) 108 | { 109 | foreach ($_SESSION[$this->cartKey] as $i => $item) { 110 | if ($item['name'] === $itemName) { 111 | unset($_SESSION[$this->cartKey][$i]); // Remove the item from the cart 112 | return; 113 | } 114 | } 115 | } 116 | 117 | /** 118 | * Create an example cart. 119 | */ 120 | private function createCart() 121 | { 122 | $_SESSION['cart'] = [ // The following lines are defining an array with several array items 123 | ['name' => 'Area A Ticket', 'quantity' => 1], // Every item in the array is an array ['name' => x, 'quantity' => x] 124 | ['name' => 'Area B Ticket', 'quantity' => 2], // Use ',' to separate each item in an array 125 | ['name' => 'Area C Ticket', 'quantity' => 3], 126 | ['name' => 'Area D Ticket', 'quantity' => 4] // The ',' after the last item can be omitted 127 | ]; 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /web/2016-spring/instant-php/src/v4/view/cart.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | My Cart 6 | 7 | 8 |

My Cart

9 |

Here is your cart.

10 | 11 | 12 |
13 |
    14 | getItems() as $i => $item): ?> 15 |
  • Name:
  • 16 |
  • Quantity: 17 | " 18 | type="number" 19 | value=""> 20 |
  • 21 |
  • 22 | Remove 23 |
  • 24 | 25 |
26 | 27 |
28 | 29 | 30 |
31 |

Add new item

32 |

33 | 34 | 35 | 36 |

37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /web/index.rst: -------------------------------------------------------------------------------- 1 | .. Web develop courses, provided by the following awesome members 2 | arrowrowe 3 | at15 4 | ComMouse 5 | 6 | Web develop courses 7 | ==================================== 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | 2016-spring/index 15 | --------------------------------------------------------------------------------