├── .gitignore ├── AUTHORS.md ├── CONTRIBUTING.md ├── LICENSE ├── METHODOLOGY.md ├── Makefile ├── README.md ├── examples ├── Makefile ├── accumulator.erl └── flow_control.erl ├── index.erl ├── notes-20151112-chicago-erlang └── README.md ├── patterns ├── Makefile ├── abstract-execution.md ├── acceptor-pool.md ├── accumulator.md ├── behavior.md ├── broker.md ├── case-expression.md ├── chain.md ├── circuit_breaker.md ├── clarifying-variable.md ├── cleanup-crew.md ├── connection-pool.md ├── crash-by-default.md ├── data-service.md ├── department.md ├── dispatch.md ├── explicit-text-encoding.md ├── finite-state-machine.md ├── function.md ├── getopt-arguments.md ├── group-leader.md ├── higher-order-function.md ├── hunt-gather.md ├── if-expression.md ├── iolist.md ├── mailbox.md ├── main-loop.md ├── maybe.md ├── message-handler.md ├── middle-man.md ├── module-alias.md ├── named-case-expression.md ├── nested-record-getter.md ├── pattern_matching.md ├── persistent-ephemeral-state ├── process-starter.md ├── process-state-initializer.md ├── rate-limiter.md ├── real-life-process.md ├── response-handler.erl ├── separation-of-concerns.md ├── service.md ├── shape-converter.md ├── short-functions.md ├── stats-sink.md ├── step-processor.md ├── step.md ├── supervisor.md ├── system-boundary-validation.md └── tagged-tuple.md ├── project.config ├── site.config ├── snippets ├── Makefile ├── gist.md └── goals.md └── template ├── LICENSE.txt ├── Makefile ├── README.txt ├── base.html ├── contributing.html ├── css ├── Makefile ├── ie9.css ├── images │ ├── banner.jpg │ ├── bg1.png │ ├── icon-bubble.png │ ├── ie │ │ ├── button-hover.svg │ │ ├── button.svg │ │ ├── header-wrapper.svg │ │ ├── header.svg │ │ ├── nav-a-hover.svg │ │ └── nav-a.svg │ └── mobileUI-site-nav-opener-bg.svg ├── main.css ├── style-0-1000px.css ├── style-0-desktop.css ├── style-0-mobile.css └── style-0.css ├── footer.html ├── header.html ├── images ├── creativecommons.png ├── favicon.png ├── pic1.jpg ├── pic2.jpg ├── pic3.jpg ├── pic4.jpg ├── pic5.jpg └── pic6.jpg ├── index.html ├── js ├── github.commits.widget.js ├── ie │ ├── html5shiv.js │ └── respond.min.js ├── jquery.min.js ├── main.js ├── skel-viewport.min.js ├── skel.min.js └── util.js ├── methodology.html ├── onecolumn.html ├── pattern.html ├── patterns.html ├── simplepage.html ├── threecolumn.html ├── topmenu.html ├── twocolumn1.html └── twocolumn2.html /.gitignore: -------------------------------------------------------------------------------- 1 | /site 2 | *.beam 3 | -------------------------------------------------------------------------------- /AUTHORS.md: -------------------------------------------------------------------------------- 1 | # Authors 2 | 3 | Garrett Smith 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | This project is hosted on Github: 4 | 5 | **[https://github.com/gar1t/erlang-patterns](https://github.com/gar1t/erlang-patterns)** 6 | 7 | This contribution policy has been adapted from 8 | [C4.1 - Collective Code Construction Contract](http://rfc.zeromq.org/spec:22) 9 | to meet the needs of this project. It is subject to change and 10 | suggested improvements are welcome. 11 | 12 | ## Language 13 | 14 | The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 15 | "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 16 | document are to be interpreted as described in RFC 2119. 17 | 18 | ## Goals 19 | 20 | - To maximize the scale of the community around the project by 21 | reducing the friction for new Contributors 22 | 23 | - To relieve dependencies on key individuals by separating different 24 | skill sets so that there is a larger pool of competence in any 25 | required domain 26 | 27 | - To support diversity of the contributions to the project 28 | 29 | - To enforce collective ownership of the project 30 | 31 | ## Design 32 | 33 | ### Preliminaries 34 | 35 | - The project SHALL use the git distributed revision control system. 36 | 37 | - The project SHALL be hosted on github.com or equivalent, herein 38 | called the "Platform". 39 | 40 | - The project SHALL use the Platform issue tracker. 41 | 42 | - A "Maintainer" is a person who merges patches to the 43 | project. Maintainers are not developers - their job is to enforce 44 | process. 45 | 46 | - Maintainers SHALL have commit access to the repository. 47 | 48 | - A "Contributor" is a person who wishes to provide a patch, being a 49 | set of commits that solve some clearly identified problem. 50 | 51 | - Contributors SHALL NOT have commit access to the repository unless 52 | they are also Maintainers. 53 | 54 | - Everyone without distinction or discrimination SHALL have an equal 55 | right to become a Contributor under the terms of this contract. 56 | 57 | ### Licensing and Ownership 58 | 59 | - The project SHALL use the Creative Commons Attribution 4.0 60 | International license. 61 | 62 | - All contributions to the project source code ("patches") SHALL use 63 | the same license as the project. 64 | 65 | - All patches are owned by their authors. There SHALL NOT be any 66 | copyright assignment process. 67 | 68 | - The copyrights in the project SHALL be owned collectively by all its 69 | Contributors. 70 | 71 | - Each Contributor SHALL be responsible for identifying themselves in 72 | the project Contributor list. 73 | 74 | ### Patch Requirements 75 | 76 | - Maintainers and Contributors MUST have a Platform account and SHOULD 77 | use their real names or a well-known alias. 78 | 79 | - A patch SHOULD be a minimal and accurate answer to exactly one 80 | identified and agreed upon problem. 81 | 82 | - A patch MUST adhere to the project Methodology (see METHODOLOGY.md). 83 | 84 | - A patch SHALL NOT include non-trivial code from other projects 85 | unless the Contributor is the original author of that code. 86 | 87 | - A patch commit message SHOULD consist of a single short (less than 88 | 50 character) line summarizing the change, optionally followed by a 89 | blank line and then a more thorough description. 90 | 91 | - A "Correct Patch" is one that satisfies the above requirements. 92 | 93 | ### Development Process 94 | 95 | - Change on the project SHALL be governed by the pattern of accurately 96 | identifying problems and applying minimal, sufficient solutions to 97 | these problems. 98 | 99 | - To request changes, a user SHOULD log an issue on the project 100 | Platform issue tracker. 101 | 102 | - The user or Contributor SHOULD write the issue by describing the 103 | problem they face or observe. 104 | 105 | - The user or Contributor SHOULD seek consensus on the accuracy of 106 | their observation, and the value of solving the problem. 107 | 108 | - Thus, the release history of the project SHALL be a list of 109 | meaningful issues logged and solved. 110 | 111 | - To work on an issue, a Contributor SHALL fork the project repository 112 | and then work on their forked repository. 113 | 114 | - To submit a patch, a Contributor SHALL create a Platform pull 115 | request back to the project. 116 | 117 | - A Contributor SHALL NOT commit changes directly to the project. 118 | 119 | - If the Platform implements pull requests as issues, a Contributor 120 | MAY directly send a pull request without logging a separate issue. 121 | 122 | - To discuss a patch, people MAY comment on the Platform pull request, 123 | on the commit, or elsewhere. 124 | 125 | - To accept or reject a patch, a Maintainer SHALL use the Platform 126 | interface. 127 | 128 | - Maintainers SHOULD NOT merge their own patches except in exceptional 129 | cases, such as non-responsiveness from other Maintainers for an 130 | extended period (more than 1-2 days). 131 | 132 | - Maintainers SHALL NOT make value judgments on correct patches. 133 | 134 | - Maintainers SHALL merge correct patches from other Contributors 135 | rapidly. 136 | 137 | - The Contributor MAY tag an issue as "Ready" after making a pull 138 | request for the issue. 139 | 140 | - The user who created an issue SHOULD close the issue after checking 141 | the patch is successful. 142 | 143 | - Maintainers SHOULD ask for improvements to incorrect patches and 144 | SHOULD reject incorrect patches if the Contributor does not respond 145 | constructively. 146 | 147 | - Any Contributor who has value judgments on a correct patch SHOULD 148 | express these via their own patches. 149 | 150 | - Maintainers MAY commit changes to non-source documentation directly 151 | to the project. 152 | 153 | ### Project Administration 154 | 155 | - The project founders SHALL act as Administrators to manage the set 156 | of project Maintainers. 157 | 158 | - The Administrators SHALL ensure their own succession over time by 159 | promoting the most effective Maintainers. 160 | 161 | - A new Contributor who makes a correct patch SHALL be invited to 162 | become a Maintainer. 163 | 164 | - Administrators MAY remove Maintainers who are inactive for an 165 | extended period of time, or who repeatedly fail to apply this 166 | process accurately. 167 | 168 | - Administrators SHOULD block or ban "bad actors" who cause stress and 169 | pain to others in the project. This should be done after public 170 | discussion, with a chance for all parties to speak. A bad actor is 171 | someone who repeatedly ignores the rules and culture of the project, 172 | who is needlessly argumentative or hostile, or who is offensive, and 173 | who is unable to self-correct their behavior when asked to do so by 174 | others. 175 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Attribution-ShareAlike 4.0 International 2 | 3 | ======================================================================= 4 | 5 | Creative Commons Corporation ("Creative Commons") is not a law firm and 6 | does not provide legal services or legal advice. Distribution of 7 | Creative Commons public licenses does not create a lawyer-client or 8 | other relationship. Creative Commons makes its licenses and related 9 | information available on an "as-is" basis. Creative Commons gives no 10 | warranties regarding its licenses, any material licensed under their 11 | terms and conditions, or any related information. Creative Commons 12 | disclaims all liability for damages resulting from their use to the 13 | fullest extent possible. 14 | 15 | Using Creative Commons Public Licenses 16 | 17 | Creative Commons public licenses provide a standard set of terms and 18 | conditions that creators and other rights holders may use to share 19 | original works of authorship and other material subject to copyright 20 | and certain other rights specified in the public license below. The 21 | following considerations are for informational purposes only, are not 22 | exhaustive, and do not form part of our licenses. 23 | 24 | Considerations for licensors: Our public licenses are 25 | intended for use by those authorized to give the public 26 | permission to use material in ways otherwise restricted by 27 | copyright and certain other rights. Our licenses are 28 | irrevocable. Licensors should read and understand the terms 29 | and conditions of the license they choose before applying it. 30 | Licensors should also secure all rights necessary before 31 | applying our licenses so that the public can reuse the 32 | material as expected. Licensors should clearly mark any 33 | material not subject to the license. This includes other CC- 34 | licensed material, or material used under an exception or 35 | limitation to copyright. More considerations for licensors: 36 | wiki.creativecommons.org/Considerations_for_licensors 37 | 38 | Considerations for the public: By using one of our public 39 | licenses, a licensor grants the public permission to use the 40 | licensed material under specified terms and conditions. If 41 | the licensor's permission is not necessary for any reason--for 42 | example, because of any applicable exception or limitation to 43 | copyright--then that use is not regulated by the license. Our 44 | licenses grant only permissions under copyright and certain 45 | other rights that a licensor has authority to grant. Use of 46 | the licensed material may still be restricted for other 47 | reasons, including because others have copyright or other 48 | rights in the material. A licensor may make special requests, 49 | such as asking that all changes be marked or described. 50 | Although not required by our licenses, you are encouraged to 51 | respect those requests where reasonable. More considerations 52 | for the public: 53 | wiki.creativecommons.org/Considerations_for_licensees 54 | 55 | ======================================================================= 56 | 57 | Creative Commons Attribution-ShareAlike 4.0 International Public 58 | License 59 | 60 | By exercising the Licensed Rights (defined below), You accept and agree 61 | to be bound by the terms and conditions of this Creative Commons 62 | Attribution-ShareAlike 4.0 International Public License ("Public 63 | License"). To the extent this Public License may be interpreted as a 64 | contract, You are granted the Licensed Rights in consideration of Your 65 | acceptance of these terms and conditions, and the Licensor grants You 66 | such rights in consideration of benefits the Licensor receives from 67 | making the Licensed Material available under these terms and 68 | conditions. 69 | 70 | 71 | Section 1 -- Definitions. 72 | 73 | a. Adapted Material means material subject to Copyright and Similar 74 | Rights that is derived from or based upon the Licensed Material 75 | and in which the Licensed Material is translated, altered, 76 | arranged, transformed, or otherwise modified in a manner requiring 77 | permission under the Copyright and Similar Rights held by the 78 | Licensor. For purposes of this Public License, where the Licensed 79 | Material is a musical work, performance, or sound recording, 80 | Adapted Material is always produced where the Licensed Material is 81 | synched in timed relation with a moving image. 82 | 83 | b. Adapter's License means the license You apply to Your Copyright 84 | and Similar Rights in Your contributions to Adapted Material in 85 | accordance with the terms and conditions of this Public License. 86 | 87 | c. BY-SA Compatible License means a license listed at 88 | creativecommons.org/compatiblelicenses, approved by Creative 89 | Commons as essentially the equivalent of this Public License. 90 | 91 | d. Copyright and Similar Rights means copyright and/or similar rights 92 | closely related to copyright including, without limitation, 93 | performance, broadcast, sound recording, and Sui Generis Database 94 | Rights, without regard to how the rights are labeled or 95 | categorized. For purposes of this Public License, the rights 96 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 97 | Rights. 98 | 99 | e. Effective Technological Measures means those measures that, in the 100 | absence of proper authority, may not be circumvented under laws 101 | fulfilling obligations under Article 11 of the WIPO Copyright 102 | Treaty adopted on December 20, 1996, and/or similar international 103 | agreements. 104 | 105 | f. Exceptions and Limitations means fair use, fair dealing, and/or 106 | any other exception or limitation to Copyright and Similar Rights 107 | that applies to Your use of the Licensed Material. 108 | 109 | g. License Elements means the license attributes listed in the name 110 | of a Creative Commons Public License. The License Elements of this 111 | Public License are Attribution and ShareAlike. 112 | 113 | h. Licensed Material means the artistic or literary work, database, 114 | or other material to which the Licensor applied this Public 115 | License. 116 | 117 | i. Licensed Rights means the rights granted to You subject to the 118 | terms and conditions of this Public License, which are limited to 119 | all Copyright and Similar Rights that apply to Your use of the 120 | Licensed Material and that the Licensor has authority to license. 121 | 122 | j. Licensor means the individual(s) or entity(ies) granting rights 123 | under this Public License. 124 | 125 | k. Share means to provide material to the public by any means or 126 | process that requires permission under the Licensed Rights, such 127 | as reproduction, public display, public performance, distribution, 128 | dissemination, communication, or importation, and to make material 129 | available to the public including in ways that members of the 130 | public may access the material from a place and at a time 131 | individually chosen by them. 132 | 133 | l. Sui Generis Database Rights means rights other than copyright 134 | resulting from Directive 96/9/EC of the European Parliament and of 135 | the Council of 11 March 1996 on the legal protection of databases, 136 | as amended and/or succeeded, as well as other essentially 137 | equivalent rights anywhere in the world. 138 | 139 | m. You means the individual or entity exercising the Licensed Rights 140 | under this Public License. Your has a corresponding meaning. 141 | 142 | 143 | Section 2 -- Scope. 144 | 145 | a. License grant. 146 | 147 | 1. Subject to the terms and conditions of this Public License, 148 | the Licensor hereby grants You a worldwide, royalty-free, 149 | non-sublicensable, non-exclusive, irrevocable license to 150 | exercise the Licensed Rights in the Licensed Material to: 151 | 152 | a. reproduce and Share the Licensed Material, in whole or 153 | in part; and 154 | 155 | b. produce, reproduce, and Share Adapted Material. 156 | 157 | 2. Exceptions and Limitations. For the avoidance of doubt, where 158 | Exceptions and Limitations apply to Your use, this Public 159 | License does not apply, and You do not need to comply with 160 | its terms and conditions. 161 | 162 | 3. Term. The term of this Public License is specified in Section 163 | 6(a). 164 | 165 | 4. Media and formats; technical modifications allowed. The 166 | Licensor authorizes You to exercise the Licensed Rights in 167 | all media and formats whether now known or hereafter created, 168 | and to make technical modifications necessary to do so. The 169 | Licensor waives and/or agrees not to assert any right or 170 | authority to forbid You from making technical modifications 171 | necessary to exercise the Licensed Rights, including 172 | technical modifications necessary to circumvent Effective 173 | Technological Measures. For purposes of this Public License, 174 | simply making modifications authorized by this Section 2(a) 175 | (4) never produces Adapted Material. 176 | 177 | 5. Downstream recipients. 178 | 179 | a. Offer from the Licensor -- Licensed Material. Every 180 | recipient of the Licensed Material automatically 181 | receives an offer from the Licensor to exercise the 182 | Licensed Rights under the terms and conditions of this 183 | Public License. 184 | 185 | b. Additional offer from the Licensor -- Adapted Material. 186 | Every recipient of Adapted Material from You 187 | automatically receives an offer from the Licensor to 188 | exercise the Licensed Rights in the Adapted Material 189 | under the conditions of the Adapter's License You apply. 190 | 191 | c. No downstream restrictions. You may not offer or impose 192 | any additional or different terms or conditions on, or 193 | apply any Effective Technological Measures to, the 194 | Licensed Material if doing so restricts exercise of the 195 | Licensed Rights by any recipient of the Licensed 196 | Material. 197 | 198 | 6. No endorsement. Nothing in this Public License constitutes or 199 | may be construed as permission to assert or imply that You 200 | are, or that Your use of the Licensed Material is, connected 201 | with, or sponsored, endorsed, or granted official status by, 202 | the Licensor or others designated to receive attribution as 203 | provided in Section 3(a)(1)(A)(i). 204 | 205 | b. Other rights. 206 | 207 | 1. Moral rights, such as the right of integrity, are not 208 | licensed under this Public License, nor are publicity, 209 | privacy, and/or other similar personality rights; however, to 210 | the extent possible, the Licensor waives and/or agrees not to 211 | assert any such rights held by the Licensor to the limited 212 | extent necessary to allow You to exercise the Licensed 213 | Rights, but not otherwise. 214 | 215 | 2. Patent and trademark rights are not licensed under this 216 | Public License. 217 | 218 | 3. To the extent possible, the Licensor waives any right to 219 | collect royalties from You for the exercise of the Licensed 220 | Rights, whether directly or through a collecting society 221 | under any voluntary or waivable statutory or compulsory 222 | licensing scheme. In all other cases the Licensor expressly 223 | reserves any right to collect such royalties. 224 | 225 | 226 | Section 3 -- License Conditions. 227 | 228 | Your exercise of the Licensed Rights is expressly made subject to the 229 | following conditions. 230 | 231 | a. Attribution. 232 | 233 | 1. If You Share the Licensed Material (including in modified 234 | form), You must: 235 | 236 | a. retain the following if it is supplied by the Licensor 237 | with the Licensed Material: 238 | 239 | i. identification of the creator(s) of the Licensed 240 | Material and any others designated to receive 241 | attribution, in any reasonable manner requested by 242 | the Licensor (including by pseudonym if 243 | designated); 244 | 245 | ii. a copyright notice; 246 | 247 | iii. a notice that refers to this Public License; 248 | 249 | iv. a notice that refers to the disclaimer of 250 | warranties; 251 | 252 | v. a URI or hyperlink to the Licensed Material to the 253 | extent reasonably practicable; 254 | 255 | b. indicate if You modified the Licensed Material and 256 | retain an indication of any previous modifications; and 257 | 258 | c. indicate the Licensed Material is licensed under this 259 | Public License, and include the text of, or the URI or 260 | hyperlink to, this Public License. 261 | 262 | 2. You may satisfy the conditions in Section 3(a)(1) in any 263 | reasonable manner based on the medium, means, and context in 264 | which You Share the Licensed Material. For example, it may be 265 | reasonable to satisfy the conditions by providing a URI or 266 | hyperlink to a resource that includes the required 267 | information. 268 | 269 | 3. If requested by the Licensor, You must remove any of the 270 | information required by Section 3(a)(1)(A) to the extent 271 | reasonably practicable. 272 | 273 | b. ShareAlike. 274 | 275 | In addition to the conditions in Section 3(a), if You Share 276 | Adapted Material You produce, the following conditions also apply. 277 | 278 | 1. The Adapter's License You apply must be a Creative Commons 279 | license with the same License Elements, this version or 280 | later, or a BY-SA Compatible License. 281 | 282 | 2. You must include the text of, or the URI or hyperlink to, the 283 | Adapter's License You apply. You may satisfy this condition 284 | in any reasonable manner based on the medium, means, and 285 | context in which You Share Adapted Material. 286 | 287 | 3. You may not offer or impose any additional or different terms 288 | or conditions on, or apply any Effective Technological 289 | Measures to, Adapted Material that restrict exercise of the 290 | rights granted under the Adapter's License You apply. 291 | 292 | 293 | Section 4 -- Sui Generis Database Rights. 294 | 295 | Where the Licensed Rights include Sui Generis Database Rights that 296 | apply to Your use of the Licensed Material: 297 | 298 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 299 | to extract, reuse, reproduce, and Share all or a substantial 300 | portion of the contents of the database; 301 | 302 | b. if You include all or a substantial portion of the database 303 | contents in a database in which You have Sui Generis Database 304 | Rights, then the database in which You have Sui Generis Database 305 | Rights (but not its individual contents) is Adapted Material, 306 | 307 | including for purposes of Section 3(b); and 308 | c. You must comply with the conditions in Section 3(a) if You Share 309 | all or a substantial portion of the contents of the database. 310 | 311 | For the avoidance of doubt, this Section 4 supplements and does not 312 | replace Your obligations under this Public License where the Licensed 313 | Rights include other Copyright and Similar Rights. 314 | 315 | 316 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 317 | 318 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 319 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 320 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 321 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 322 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 323 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 324 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 325 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 326 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 327 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 328 | 329 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 330 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 331 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 332 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 333 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 334 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 335 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 336 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 337 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 338 | 339 | c. The disclaimer of warranties and limitation of liability provided 340 | above shall be interpreted in a manner that, to the extent 341 | possible, most closely approximates an absolute disclaimer and 342 | waiver of all liability. 343 | 344 | 345 | Section 6 -- Term and Termination. 346 | 347 | a. This Public License applies for the term of the Copyright and 348 | Similar Rights licensed here. However, if You fail to comply with 349 | this Public License, then Your rights under this Public License 350 | terminate automatically. 351 | 352 | b. Where Your right to use the Licensed Material has terminated under 353 | Section 6(a), it reinstates: 354 | 355 | 1. automatically as of the date the violation is cured, provided 356 | it is cured within 30 days of Your discovery of the 357 | violation; or 358 | 359 | 2. upon express reinstatement by the Licensor. 360 | 361 | For the avoidance of doubt, this Section 6(b) does not affect any 362 | right the Licensor may have to seek remedies for Your violations 363 | of this Public License. 364 | 365 | c. For the avoidance of doubt, the Licensor may also offer the 366 | Licensed Material under separate terms or conditions or stop 367 | distributing the Licensed Material at any time; however, doing so 368 | will not terminate this Public License. 369 | 370 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 371 | License. 372 | 373 | 374 | Section 7 -- Other Terms and Conditions. 375 | 376 | a. The Licensor shall not be bound by any additional or different 377 | terms or conditions communicated by You unless expressly agreed. 378 | 379 | b. Any arrangements, understandings, or agreements regarding the 380 | Licensed Material not stated herein are separate from and 381 | independent of the terms and conditions of this Public License. 382 | 383 | 384 | Section 8 -- Interpretation. 385 | 386 | a. For the avoidance of doubt, this Public License does not, and 387 | shall not be interpreted to, reduce, limit, restrict, or impose 388 | conditions on any use of the Licensed Material that could lawfully 389 | be made without permission under this Public License. 390 | 391 | b. To the extent possible, if any provision of this Public License is 392 | deemed unenforceable, it shall be automatically reformed to the 393 | minimum extent necessary to make it enforceable. If the provision 394 | cannot be reformed, it shall be severed from this Public License 395 | without affecting the enforceability of the remaining terms and 396 | conditions. 397 | 398 | c. No term or condition of this Public License will be waived and no 399 | failure to comply consented to unless expressly agreed to by the 400 | Licensor. 401 | 402 | d. Nothing in this Public License constitutes or may be interpreted 403 | as a limitation upon, or waiver of, any privileges and immunities 404 | that apply to the Licensor or You, including from the legal 405 | processes of any jurisdiction or authority. 406 | 407 | 408 | ======================================================================= 409 | 410 | Creative Commons is not a party to its public licenses. 411 | Notwithstanding, Creative Commons may elect to apply one of its public 412 | licenses to material it publishes and in those instances will be 413 | considered the “Licensor.” The text of the Creative Commons public 414 | licenses is dedicated to the public domain under the CC0 Public Domain 415 | Dedication. Except for the limited purpose of indicating that material 416 | is shared under a Creative Commons public license or as otherwise 417 | permitted by the Creative Commons policies published at 418 | creativecommons.org/policies, Creative Commons does not authorize the 419 | use of the trademark "Creative Commons" or any other trademark or logo 420 | of Creative Commons without its prior written consent including, 421 | without limitation, in connection with any unauthorized modifications 422 | to any of its public licenses or any other arrangements, 423 | understandings, or agreements concerning use of licensed material. For 424 | the avoidance of doubt, this paragraph does not form part of the public 425 | licenses. 426 | 427 | Creative Commons may be contacted at creativecommons.org. 428 | -------------------------------------------------------------------------------- /METHODOLOGY.md: -------------------------------------------------------------------------------- 1 | # Methodology 2 | 3 | ## Acceptance Criteria 4 | 5 | - A pattern SHOULD be used and something you can observe. 6 | 7 | - A pattern SHOULD be repeated and over enough time to inform one's 8 | experience. 9 | 10 | - A pattern MUST feel good when used. 11 | 12 | - In some cases a pattern MAY be based on abstract thought without experience. 13 | 14 | ## Defining a Pattern 15 | 16 | Each pattern MUST define the following: 17 | 18 | - Name 19 | - Scope (see below) 20 | - One line summary of the pattern 21 | - Detailed description of the pattern including why the pattern is 22 | good and where it should be used 23 | 24 | A pattern MAY additionally define: 25 | 26 | - Illustrations to clarify the pattern 27 | - Sample source code 28 | - References to supporting matterial 29 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PORT = 8000 2 | 3 | gen: 4 | rm -f site/*.html 5 | lpad-gen 6 | 7 | clean: 8 | rm -rf site/* 9 | 10 | serve: gen 11 | cd site && python -m SimpleHTTPServer $(PORT) 12 | 13 | publish: gen 14 | s3cmd sync -P --no-mime-magic --delete-removed site/* s3://www.erlangpatterns.org 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Erlang Patterns 2 | 3 | Please note that 4 | [http://erlangpatterns.org](http://erlangpatterns.org) is no longer 5 | maintained. Don't look for actual Erlang patterns there - it's 6 | something else now. 7 | 8 | This repo should be migrated to use GitHub pages so it can be viewed 9 | as a proper website. The original site was generated with LambdaPad, 10 | which is also no longer maintained. 11 | 12 | If anyone wants to migrate this to GitHub pages, that would be 13 | extremely helpful! 14 | 15 | ## Contributing to the Patterns 16 | 17 | Refer to [CONTRIBUTING.md](CONTRIBUTING.md) for the project 18 | contribution policy. 19 | 20 | If you want to add a pattern, simply add a file to the `patterns` 21 | directory that follows the conventions of the other pattern documents 22 | in that directory. 23 | 24 | To modify a pattern, simply edit the applicable file. 25 | 26 | Please submit a pull request to the project to apply your changes. 27 | 28 | Currently erlangpatterns.org is updated manually by the project 29 | administrator using the master branch of this repository. 30 | 31 | If you'd like to ask a question or raise an issue about a pattern, 32 | please use the project's 33 | [issue tracking system](https://github.com/gar1t/erlang-patterns/issues). 34 | 35 | ## View the Presentation 36 | 37 | You can view the presentation by simply opening the file: 38 | 39 | `erlang-patterns/site/index.html` 40 | 41 | Or by running: 42 | 43 | ``` 44 | make serve 45 | ``` 46 | 47 | and opening [http://localhost:8000](http://localhost:8000) 48 | -------------------------------------------------------------------------------- /examples/Makefile: -------------------------------------------------------------------------------- 1 | modules := $(patsubst %.erl,%.beam,$(wildcard *.erl)) 2 | 3 | compile: $(modules) 4 | 5 | shell: compile 6 | erl 7 | 8 | %.beam: %.erl 9 | erlc $< 10 | 11 | clean: 12 | rm -f $(modules) 13 | -------------------------------------------------------------------------------- /examples/accumulator.erl: -------------------------------------------------------------------------------- 1 | -module(accumulator). 2 | 3 | -export([seq/2]). 4 | 5 | seq(Start, Finish) -> seq(Start, Finish, []). 6 | 7 | seq(Start, Finish, Acc) when Start =< Finish -> 8 | seq(Start + 1, Finish, [Start|Acc]); 9 | seq(_, _, Acc) -> 10 | lists:reverse(Acc). 11 | -------------------------------------------------------------------------------- /examples/flow_control.erl: -------------------------------------------------------------------------------- 1 | -module(flow_control). 2 | -export([report_result/1, report_result_via_case/1]). 3 | -include_lib("eunit/include/eunit.hrl"). 4 | 5 | % An example with case 6 | report_result_via_case(Response) -> 7 | case Response of 8 | {ok, Msg} -> report_success(Msg); 9 | {error, Msg} -> report_failure(Msg) 10 | end. 11 | 12 | % An example with pattern matching 13 | report_result({ok, Msg}) -> report_success(Msg); 14 | report_result({error, Msg}) -> report_failure(Msg). 15 | 16 | % private/hidden functions 17 | % Real code would do something meaningful with the argument. 18 | report_success(_Msg) -> success. 19 | report_failure(_Msg) -> failure. 20 | 21 | %% TESTS 22 | success_via_case_test() -> ?assertEqual(success, report_result_via_case({ok, anything})). 23 | failure_via_case_test() -> ?assertEqual(failure, report_result_via_case({error, anything})). 24 | 25 | success_via_pm_test() -> ?assertEqual(success, report_result({ok, anything})). 26 | failure_via_pm_test() -> ?assertEqual(failure, report_result({error, anything})). 27 | -------------------------------------------------------------------------------- /index.erl: -------------------------------------------------------------------------------- 1 | -module(index). 2 | 3 | data(_) -> 4 | #{project => {eterm, "project.config"}, 5 | site => {eterm, "site.config"}, 6 | snippets => {markdown, "snippets/*.md"}, 7 | contributing => {markdown, "CONTRIBUTING.md"}, 8 | methodology => {markdown, "METHODOLOGY.md"}, 9 | patterns => {markdown, "patterns/*.md"}}. 10 | 11 | site(Data) -> 12 | #{"site/index.html" => {template, "template/index.html"}, 13 | "site/methodology.html" => {template, "template/methodology.html"}, 14 | "site/patterns.html" => {template, "template/patterns.html"}, 15 | "site/contributing.html" => {template, "template/contributing.html"}, 16 | "site/{{pattern|basename}}.html" => 17 | {template_map, "template/pattern.html", 18 | {pattern, plist:value(patterns, Data)}}, 19 | "site/css" => {dir, "template/css"}, 20 | "site/js" => {dir, "template/js"}, 21 | "site/images" => {dir, "template/images"}}. 22 | 23 | recent_patterns(Patterns) -> 24 | Patterns. 25 | 26 | %%=================================================================== 27 | %% Custom tag - example 28 | %% 29 | %% Reads example source code for use in fenced markdown examples. 30 | %% 31 | %% For example: 32 | %% 33 | %% ```erlang 34 | %% {% example file="accumulator.erl" lines="5-10" %} 35 | %% ``` 36 | %%=================================================================== 37 | 38 | example(Vars) -> 39 | read_file_lines(example_file(Vars), example_lines(Vars)). 40 | 41 | example_file(Vars) -> 42 | Name = plist:value(file, Vars), 43 | Path = example_file_path(Name), 44 | handle_file_open(file:open(Path, [read]), Path). 45 | 46 | example_file_path(Name) -> 47 | filename:join([lpad_session:root(), "examples", Name]). 48 | 49 | handle_file_open({ok, F}, _File) -> F; 50 | handle_file_open({error, Err}, File) -> 51 | error({file_open, Err, File}). 52 | 53 | example_lines(Vars) -> 54 | parse_lines(plist:value(lines, Vars)). 55 | 56 | parse_lines(Lines) -> 57 | Pattern = "^([0-9]+)-([0-9]+)$", 58 | Opts = [{capture, all_but_first, list}], 59 | handle_lines_match(re:run(Lines, Pattern, Opts), Lines). 60 | 61 | handle_lines_match({match, [Start, Stop]}, _Lines) -> 62 | {list_to_integer(Start), list_to_integer(Stop)}; 63 | handle_lines_match(nomatch, Lines) -> 64 | error({lines, Lines}). 65 | 66 | read_file_lines(In, {Start, Stop}) -> 67 | file_seek(In, Start - 1), 68 | Lines = file_acc_lines(In, (Stop - Start + 1)), 69 | file:close(In), 70 | Lines. 71 | 72 | file_seek(In, Count) -> file_seek(In, 0, Count). 73 | 74 | file_seek(In, Cur, Stop) when Cur < Stop -> 75 | io:get_line(In, ""), 76 | file_seek(In, Cur + 1, Stop); 77 | file_seek(_In, _Cur, _Stop) -> 78 | ok. 79 | 80 | file_acc_lines(In, Count) -> file_acc_lines(In, 0, Count, []). 81 | 82 | file_acc_lines(In, Cur, Count, Acc) when Cur < Count -> 83 | Line = io:get_line(In, ""), 84 | file_acc_lines(In, Cur + 1, Count, [Line|Acc]); 85 | file_acc_lines(_In, _Cur, _Count, [Last|Rest]) -> 86 | lists:reverse([strip_trailing_cr(Last)|Rest]). 87 | 88 | strip_trailing_cr(Line) -> 89 | lists:sublist(Line, length(Line) - 1). 90 | 91 | %%=================================================================== 92 | %% Code as Verbatim 93 | %% 94 | %% Erlang code samples might land with '{{' or '}}' which will 95 | %% be treated as template markup. This filter wraps code blocks 96 | %% with {% verbatim %} 97 | %%=================================================================== 98 | 99 | code_as_verbatim(Html) -> 100 | re:replace( 101 | re:replace(Html, "", "{% endverbatim %}", [global]). 103 | -------------------------------------------------------------------------------- /notes-20151112-chicago-erlang/README.md: -------------------------------------------------------------------------------- 1 | # Mailboxes - Messaging 2 | 3 | Ideas of message buses. Simple constructs related to messaging, 4 | mailboxes. Ability to signal. 5 | 6 | Familiarity of the constructs from experience with OS constructs. 7 | 8 | # Congruence with System Coordination 9 | 10 | Semantics didn't work against instinct of messaging / signal bases systems. 11 | 12 | # Fault Tolerance via Fault -> Death -> Restart 13 | 14 | The central premise of Erlang's fault tolerance. 15 | 16 | # Discoverability of root causes 17 | 18 | Uncertainty of "let it crash" and "restart" as a correct solution for 19 | all cases demands a facility to discover root causes in support of 20 | "correct software". 21 | 22 | # Ability to ignore errors freeing 23 | 24 | Like not having to spend days on tracking down a bug that may never 25 | occur again, or is hard to reproduce. 26 | 27 | # Learning from Experience 28 | 29 | How to put code into production that isn't "done" or 100% tested, 30 | correct, etc. and learn from real world experience without killing 31 | your app. 32 | 33 | "The perfect being the enemy of the good." 34 | 35 | # Syntax Different 36 | 37 | Different from more familiar languages. 38 | 39 | # Spatial Relationships in Erlang 40 | 41 | Who's calling what and where? What's going on? 42 | 43 | # Incongruence between code structure and runtime behavior 44 | 45 | Looking for some cues in the code - the modules, files, functions, 46 | etc. to understand what happens at runtime. Consider classes, which 47 | isolate state and functions, which corresponds to the runtime 48 | behavior. 49 | 50 | # Records are too thin as an abstraction 51 | 52 | "The compiler should be helping me more." 53 | 54 | # What is the standard way of doing this? 55 | 56 | Uncertainty and nervousness about an approach that works but may not 57 | be "the right way" in Erlang. 58 | 59 | # Process abstraction as finite state machine 60 | 61 | Use case is a "debouncer". A process allows a focus on input and 62 | output with isolated logic for maintaining associated state. 63 | 64 | Simplifies signal processing. 65 | 66 | # Natural application of processes to experience 67 | 68 | Comparable to "classes" and objects. 69 | 70 | # Strict vs Flexible 71 | 72 | This is related to message passing and handling. The decoupling of 73 | "calls" by way of messages passed via queues, allows for a more 74 | flexible communication scheme. 75 | 76 | Being flexible in how you handle messages allows for lose coupling 77 | and, possibly, more resilient behavior. 78 | -------------------------------------------------------------------------------- /patterns/Makefile: -------------------------------------------------------------------------------- 1 | gen: 2 | cd ..; make gen 3 | -------------------------------------------------------------------------------- /patterns/abstract-execution.md: -------------------------------------------------------------------------------- 1 | Name: Abstract Execution Scope: Principle Summary: Describe impure logic as abstract data representing that logic, to be executed separately. 2 | 3 | Sometimes a function needs to perform side-effectful or otherwise complicated logic (making network requests, reading / writing to a database, manipulating the filesystem, caching, batching, etc). This can make the function difficult to reason about by conflating its purpose with its implementation. For example, while caching and batching may make a function more efficient, they may not be required in order for the function to be correct. 4 | 5 | Instead, write the function as two separate functions: 6 | 1) A function that returns a high-level, declarative description of the desired logic 7 | 2) A function that interprets that description and executes it 8 | 9 | It then becomes possible to separately reason about the high-level goals of a program and the mechanism by which those goals are achieved. Moreover, it becomes possible to test both concerns in isolation, and to increase the complexity of the interpreter without increasing the complexity of the functions which make use of it. 10 | 11 | Examples: 12 | - `Ecto.Multi` - https://hexdocs.pm/ecto/Ecto.Multi.html 13 | - `Haxl` - https://github.com/facebook/Haxl 14 | -------------------------------------------------------------------------------- /patterns/acceptor-pool.md: -------------------------------------------------------------------------------- 1 | Name: Acceptor Pool 2 | Scope: Application Level Facility 3 | Summary: A pool of acceptors can be used to reduce the latency of 4 | inbound connections. 5 | 6 | Given a collection of workers, usually started as part of the socket listening module: 7 | 8 | ```erlang 9 | -record(state, {workers}). 10 | 11 | init([NumWorkers]) -> 12 | {ok, #state{workers = make_workers(queue:new(), NumWorkers)}}. 13 | 14 | make_workers(Queue, NumWorkers) -> 15 | make_workers(Queue, NumWorkers, 1). 16 | make_workers(Queue, NumWorkers, N) -> 17 | case N < NumWorkers of 18 | true -> 19 | {ok, WorkerPid} = ?WORKER:start_link([]), 20 | make_workers(queue:in(WorkerPid, Queue), NumWorkers, N + 1); 21 | false -> 22 | Queue 23 | end. 24 | ``` 25 | 26 | The function that handles inbound packets may delegate to a worker: 27 | 28 | ```erlang 29 | handle_request(Socket, Host, Port, Bin, State) -> 30 | case queue:out(State#state.workers) of 31 | {{value, Worker}, Queue} -> 32 | gen_server:cast(Worker, {udp_query, Socket, Host, Port, Bin}), 33 | {noreply, State#state{workers = queue:in(Worker, Queue)}}; 34 | {empty, _Queue} -> 35 | % Drop the packet 36 | {noreply, State} 37 | end. 38 | ``` 39 | -------------------------------------------------------------------------------- /patterns/accumulator.md: -------------------------------------------------------------------------------- 1 | Name: Accumulator 2 | Scope: Function Type 3 | Summary: A recursive function can be used to build a list. 4 | 5 | Creating a list is one of the more common functions in a program. The 6 | _accumulator_ pattern uses a recursive function to build a list by 7 | adding items to the head of a list. It's common to reverse the list as 8 | a final step in the process. 9 | 10 | Here's an example that creates a sequential list of integers. 11 | 12 | ```erlang 13 | {% example file="accumulator.erl" lines="5-10" %} 14 | ``` 15 | 16 | The _accumulator_ has an exit condition that indicates when the 17 | accumulation is finished. In this case, the list is finished when 18 | `Start` is greater than or equal to `Finish`. 19 | -------------------------------------------------------------------------------- /patterns/behavior.md: -------------------------------------------------------------------------------- 1 | Name: Behavior 2 | Scope: Erlang/OTP Construct 3 | Summary: Generic process behavior can be customized with callback functions. 4 | -------------------------------------------------------------------------------- /patterns/broker.md: -------------------------------------------------------------------------------- 1 | Name: Broker 2 | Scope: Application Level Facility 3 | Summary: A process can broker the sending of messages from publishers 4 | to subscribers. 5 | -------------------------------------------------------------------------------- /patterns/case-expression.md: -------------------------------------------------------------------------------- 1 | Name: Case Expression 2 | Scope: Erlang/OTP Construct 3 | Summary: Use a case expression to define a conditional value based on 4 | a term. 5 | 6 | A case expression evaluates an expression against a series of patterns and optional guard sequences. The body of the first pattern/guard sequence that matches is evaluated and is the result of the case expression. 7 | 8 | In the following example, if Dir is a directory, the return from the function will be the count of its files. Otherwise, the return will be 0. 9 | 10 | ``` 11 | count_files(Dir) -> 12 | case filelib:is_dir(Dir) of 13 | true -> 14 | {ok, Files} = file:list_dir(Dir), 15 | length(Files); 16 | false -> 17 | 0 18 | end. 19 | ``` 20 | -------------------------------------------------------------------------------- /patterns/chain.md: -------------------------------------------------------------------------------- 1 | Name: Chain 2 | Scope: Function/Wrapper 3 | Summary: Connect a bunch of functions passing the returned value of each 4 | function to the next one. The last function's return value is 5 | the chain's return value. 6 | 7 | There are different possible ways of breaking from the chain: 8 | 9 | * Throw an exception. 10 | 11 | * Shortcut by returning some special value. For example, return 12 | ```{ok, Value}``` or ```{error, Error}``` in each function inside 13 | the chain. 14 | 15 | * Just let any values pass through and let the code crash if some 16 | garbage gets into a function. 17 | 18 | Examples: 19 | 20 | ``` 21 | -module(chain). 22 | 23 | -export([naive/2, error_monad/2]). 24 | 25 | naive([], Arg) -> 26 | Arg; 27 | naive([Fun | Funs], Arg) -> 28 | naive(Funs, Fun(Arg)). 29 | 30 | error_monad([], Arg) -> 31 | Arg; 32 | error_monad([Fun | Funs], Arg) -> 33 | case Fun(Arg) of 34 | {ok, V} -> 35 | error_monad(Funs, V); 36 | {error, E} -> 37 | {error, E} 38 | end. 39 | ``` 40 | -------------------------------------------------------------------------------- /patterns/circuit_breaker.md: -------------------------------------------------------------------------------- 1 | Name: Circuit Breaker 2 | Scope: Application Level Facility 3 | Summary: A mechanism to prevent queue overflow and allow the system to fail fast. Circuit breaker is used to detect failures and encapsulates logic of preventing a failure to reoccur constantly (during maintenance, temporary external system failure or unexpected system difficulties). This pattern can be useful for graceful degradation of a service. 4 | 5 | A circuit breaker usually has a 3 values (but could be more advanced). 6 | A number of retries before melting the fuse. A time period to reset 7 | the number of retries and a cooldown period to reset the fuse. 8 | 9 | For examples see the https://github.com/jlouis/fuse library. 10 | 11 | -------------------------------------------------------------------------------- /patterns/clarifying-variable.md: -------------------------------------------------------------------------------- 1 | Name: Clarifying Variable 2 | Scope: Not Sure 3 | Summary: Use a variable to order sequential code from top-to-bottom 4 | and name the result of an operation. 5 | -------------------------------------------------------------------------------- /patterns/cleanup-crew.md: -------------------------------------------------------------------------------- 1 | Name: Cleanup Crew 2 | Scope: Application Level Facility 3 | Summary: Use a separate process to cleanup up after other processes, 4 | freeing those processes from those additional duties. 5 | -------------------------------------------------------------------------------- /patterns/connection-pool.md: -------------------------------------------------------------------------------- 1 | Name: Connection Pool 2 | Scope: Application Level Facility 3 | Summary: Manage access to a network resource using a controlled pool of 4 | connection. 5 | -------------------------------------------------------------------------------- /patterns/crash-by-default.md: -------------------------------------------------------------------------------- 1 | Name: Crash by Default 2 | Scope: Principle 3 | Summary: Avoid complicating error handling logic by default and allow 4 | a process to crash, relying on Erlang's process isolation to 5 | protect the integrity of the system as a whole. 6 | -------------------------------------------------------------------------------- /patterns/data-service.md: -------------------------------------------------------------------------------- 1 | Name: Data Service 2 | Scope: Application Level Facility 3 | Summary: Provide access to a data using service. 4 | -------------------------------------------------------------------------------- /patterns/department.md: -------------------------------------------------------------------------------- 1 | Name: Department 2 | Scope: Application Level Facility 3 | Summary: A common setup for supervisor, worker that allows proper escalation of failures. 4 | 5 | The department pattern consists of a supervisor for the department (subsystem) with a one for all strategy (AND tree). Under this department supervisor are two children a manager process responsible for orchestrating what happens in the department and a worker supervisor which can have either a one for one (OR tree) or a one for all (AND tree) strategy. The manager asks its sibling process (the worker supervisor) to spawn new workers as needed and potentially to restart them automatically should something fail. 6 | 7 | This pattern supports Agile software development because it defers implementation of monitoring in the manager process. It also ensures the failures are properly escalated. 8 | 9 | In order to select the initial intensity (MaxR) and period (MaxT) values for the supervisors. It is a good idea to manually crash the processes and observe the behavior and to tweak the values accordingly. 10 | 11 | -------------------------------------------------------------------------------- /patterns/dispatch.md: -------------------------------------------------------------------------------- 1 | Name: Dispatch 2 | Scope: Function Type 3 | Summary: Use a function to dispatch a to other functions according 4 | to its arguments. 5 | -------------------------------------------------------------------------------- /patterns/explicit-text-encoding.md: -------------------------------------------------------------------------------- 1 | Name: Explicit Text Encoding 2 | Scope: Not Sure 3 | Summary: TODO - From Fred's observation about dealing with text during 4 | Mostly Erlang podcast. 5 | -------------------------------------------------------------------------------- /patterns/finite-state-machine.md: -------------------------------------------------------------------------------- 1 | Name: Finite State Machine 2 | Scope: Process/Behavior Type 3 | Summary: Use a process to implement a finite state machine, where process 4 | state is modified in response to events. 5 | -------------------------------------------------------------------------------- /patterns/function.md: -------------------------------------------------------------------------------- 1 | Name: Function 2 | Scope: Erlang/OTP Construct 3 | Summary: A function does the work in Erlang. It can be used to implement 4 | behavior and things. 5 | -------------------------------------------------------------------------------- /patterns/getopt-arguments.md: -------------------------------------------------------------------------------- 1 | Name: Getopt Arguments 2 | Scope: Not Sure 3 | Summary: Simplify function arguments using the getopt pattern of separating 4 | arguments into a minimal set of required arguments and a set of 5 | optional arguments, representing the optional arguments with an 6 | Erlang property list. 7 | -------------------------------------------------------------------------------- /patterns/group-leader.md: -------------------------------------------------------------------------------- 1 | Name: Group Leader 2 | Scope: ???? 3 | Summary: Represent IO generically and let the facility deal with distribution of it across nodes/processes 4 | -------------------------------------------------------------------------------- /patterns/higher-order-function.md: -------------------------------------------------------------------------------- 1 | Name: Higher Order Function 2 | Scope: Not Sure 3 | Summary: Implement generic algorithms using higher order functions, which 4 | accept function arguments that implement functionality used 5 | by the algorithm. 6 | -------------------------------------------------------------------------------- /patterns/hunt-gather.md: -------------------------------------------------------------------------------- 1 | Name: Hunt Gather 2 | Scope: Vanilla Erlang 3 | Summary: Use them cores. Parallelizing a list of work with the goal 4 | of avoiding sequentiality. 5 | 6 | This pattern parallelizes work which can save time and utilize 7 | hardware. Wherever there is work to be done which has no restriction 8 | for the order of operations, the hunt-gather pattern can be employed. 9 | 10 | ``` 11 | -module(foo). 12 | 13 | -export([start/0]). 14 | 15 | start() -> 16 | Work = lists:seq(1, 999), % proxy for a list of actual data 17 | Cnt = length(Work), 18 | hunt(Work), 19 | gather(Cnt, []). 20 | 21 | hunt(L) -> 22 | Parent = self(), 23 | Fn = fun faux_expensive_routine/2, 24 | [ spawn(fun() -> Fn(Parent, X) end) || X <- L ]. 25 | 26 | gather(0, Acc) -> Acc; 27 | gather(K, Acc) -> 28 | receive 29 | {bounty, R} -> gather(K - 1, [R|Acc]) 30 | end. 31 | 32 | faux_expensive_routine(Parent, _X) -> 33 | timer:sleep(3000), 34 | R = gathered, % usually do something with _X 35 | Parent ! {bounty, R}. 36 | ``` 37 | -------------------------------------------------------------------------------- /patterns/if-expression.md: -------------------------------------------------------------------------------- 1 | Name: If Expression 2 | Scope: Erlang/OTP Construct 3 | Summary: Use an if expression to define a condition value based on 4 | Erlang guards. 5 | -------------------------------------------------------------------------------- /patterns/iolist.md: -------------------------------------------------------------------------------- 1 | Name: IO List 2 | Scope: Erlang/OTP Construct 3 | Summary: Use deeply nested lists of integers and binaries to represent IO data 4 | to avoid copying when concatenating strings or binaries. 5 | 6 | IO lists are typically used to build output to a port e.g. a file or network 7 | socket. 8 | 9 | ``` 10 | file:write_file("myfile.txt", ["Hi " [<<"there">>], $\n]). 11 | ``` 12 | 13 | They are efficient even when combining large amounts of data. For 14 | example combining two fifty kilobyte binaries using binary syntax 15 | `<>` would typically require reallocating both into a new 16 | 100kb binary. Using IO lists `[B1, B2]` only allocates the list, in this case three 17 | words. A list uses one word and another word per element, see [here](http://www.erlang.org/doc/efficiency_guide/advanced.html#id68923) for 18 | more information. 19 | 20 | Another benefit of using IO lists is that they can combine data from functions 21 | that produce strings or binaries without converting the type. This cuts down on 22 | errors mistakenly converting to or from the wrong type. 23 | 24 | **Add** the allowed data types to the front of an IO list, creating a new one. 25 | 26 | ``` 27 | ["Guten Tag " | [<<"Hello">>]]. 28 | [<<"Guten Tag ">> | [<<"Hello">>]]. 29 | [$G, $u, $t, $e, $n , $T, $a, $g | [<<"Hello">>]]. 30 | [71,117,116,101,110,84,97,103,<<"Hello">>]. 31 | ``` 32 | 33 | IO data can be efficiently added to the **end** of a list. 34 | 35 | ``` 36 | Data_1 = [<<"Hello">>]. 37 | Data_2 = [Data_1,<<" Guten Tag ">>]. 38 | ``` 39 | 40 | Using the `++` operator would have created a whole new list, instead 41 | of just a new two element list. Recreating lists to add elements to 42 | the end can become expensive when the list is long. 43 | 44 | Be careful not to create an **improper list**. 45 | 46 | ``` 47 | ["Guten tag " | <<"Hello">>]. 48 | ``` 49 | 50 | In the shell this will be printed as `["Guten tag "|<<"Hello">>]` instead of 51 | `["Guten tag ",<<"Hello">>]`. The pipe operator will create an improper list 52 | if the last element on the right is not a list. Improper lists can cause 53 | issues because many recursive functions expect an empty list to be the last 54 | element, and not, as in this case a binary. 55 | 56 | The **size** of an iolist can be calculated using the `iolist_size/1`. This snippet 57 | calculates the size of a message and creates and appends it to the front as a four 58 | byte binary. This is a typical operation in messaging protocols. 59 | 60 | ``` 61 | Data = ["Guten tag ",<<"Hello">>], 62 | Len = iolist_size(Data), 63 | [<> | Data]. 64 | ``` 65 | 66 | An IO list can be converted to a binary using the `iolist_to_binary/1` function. 67 | If the data is going to be stored for a long period or sent as a message to other 68 | processes then it may make sense to convert it to a binary. The one off cost of 69 | converting to a binary can be cheaper than copying the IO list many times, in 70 | garbage collection of a single process or in message passing to others. 71 | 72 | ``` 73 | <<"Guten tag, Hello">> = iolist_to_binary(["Guten tag, ",<<"Hello">>]). 74 | ``` 75 | 76 | In cases where the binary data is small, allocating IO lists can be greater than 77 | appending the binaries. If the binary data can either be small or large it is often 78 | better to accept the consistent cost of IO lists. 79 | 80 | Note that appending binaries is optimised as described 81 | [here](http://www.erlang.org/doc/efficiency_guide/binaryhandling.html). In 82 | short, a binary can have extra, hidden space allocated. This will be filled if another 83 | binary is appended to it that fits in the free space. This means that not every 84 | binary append will cause a full copy of both binaries. -------------------------------------------------------------------------------- /patterns/mailbox.md: -------------------------------------------------------------------------------- 1 | Name: Mailbox 2 | Scope: ???? 3 | Summary: A familiar pattern for processing messages - computing between disparate entities 4 | -------------------------------------------------------------------------------- /patterns/main-loop.md: -------------------------------------------------------------------------------- 1 | Name: Main Loop 2 | Scope: State Management 3 | Summary: Use a recursive function mostly called loop to simulate state, e.g: [https://github.com/erlang/otp/blob/6d4fa3013653082f7ff6db6d75fb648b49de2d67/lib/stdlib/src/gen_server.erl#L357](https://github.com/erlang/otp/blob/6d4fa3013653082f7ff6db6d75fb648b49de2d67/lib/stdlib/src/gen_server.erl#L357) 4 | -------------------------------------------------------------------------------- /patterns/maybe.md: -------------------------------------------------------------------------------- 1 | Name: Maybe 2 | Scope: Function Type 3 | Summary: Perform an operation only if its arguments meets some criteria. 4 | 5 | One way to implement this is using pattern matching with the criteria executed in the caller: 6 | 7 | ```erlang 8 | maybe_cache(Key, Value, true) -> 9 | cache:put(Key, Value), 10 | Value; 11 | maybe_cache(Key, Value, false) -> 12 | Value. 13 | 14 | %% Elsewhere 15 | handle(Message) -> 16 | maybe_cache(Message#id, Message, Message#cacheable). 17 | ``` 18 | -------------------------------------------------------------------------------- /patterns/message-handler.md: -------------------------------------------------------------------------------- 1 | Name: Message Handler 2 | Scope: Function Type 3 | Summary: Handle a received message using a callback function. 4 | -------------------------------------------------------------------------------- /patterns/middle-man.md: -------------------------------------------------------------------------------- 1 | Name: Middle Man 2 | Scope: Application Level Facility 3 | Summary: Translate something (IO) from the outside world into Erlang messages 4 | 5 | Benefit - use Erlang to broker data structures and protocols across 6 | different systems. Reduces the permutations of system interactions. 7 | -------------------------------------------------------------------------------- /patterns/module-alias.md: -------------------------------------------------------------------------------- 1 | Name: Function Alias 2 | Description: Joe's idea about aliasing modules for use in other contexts 3 | -------------------------------------------------------------------------------- /patterns/named-case-expression.md: -------------------------------------------------------------------------------- 1 | Name: Named Case Expression 2 | Scope: Function Type 3 | Summary: Isolate and clarify the logic performed by a case expression 4 | by replacing it with a function (i.e. named case expression). 5 | -------------------------------------------------------------------------------- /patterns/nested-record-getter.md: -------------------------------------------------------------------------------- 1 | Name: Nested Record Getter 2 | Scope: ???? 3 | Summary: Deal with nasty ol' nested records using a fold 4 | -------------------------------------------------------------------------------- /patterns/pattern_matching.md: -------------------------------------------------------------------------------- 1 | Name: Pattern Matching 2 | Scope: Function Type 3 | Summary: Control flow via pattern matching, rather than if/case/cond. 4 | 5 | Rather than taking in one or more parameters to a function and then 6 | determining how to handle them using traditional flow control constructs 7 | inside a given function, when feasible, use multiple function definitions 8 | with pattern matching (and/or guard expressions) to allow the internal 9 | logic of each function definition to be simpler and clearer. 10 | 11 | Here's an example that accomplishes flow control with a _case_ construct 12 | inside a single function definition: 13 | 14 | ```erlang 15 | {% example file="flow_control.erl" lines="6-10" %} 16 | ``` 17 | 18 | Here's an example that instead splits the same logic into multiple function 19 | definitions, making use of pattern matching: 20 | 21 | ```erlang 22 | {% example file="flow_control.erl" lines="13-14" %} 23 | ``` 24 | 25 | -------------------------------------------------------------------------------- /patterns/persistent-ephemeral-state: -------------------------------------------------------------------------------- 1 | Name: Persistent Ephemeral State 2 | Scope: Anti Pattern 3 | Description: Use a process, not a db 4 | -------------------------------------------------------------------------------- /patterns/process-starter.md: -------------------------------------------------------------------------------- 1 | Name: Process Starter 2 | Scope: Function Type 3 | Summary: Provide a function `start_link` to start new processes. 4 | -------------------------------------------------------------------------------- /patterns/process-state-initializer.md: -------------------------------------------------------------------------------- 1 | Name: Process Initializer 2 | Scope: Function Type 3 | Summary: Improve the reliability of an Erlang system by performing any 4 | potentially risky process state initialization within the process 5 | itself. 6 | -------------------------------------------------------------------------------- /patterns/rate-limiter.md: -------------------------------------------------------------------------------- 1 | Name: Rate Limiter 2 | Scope: Application Level Facility 3 | Summary: Guard against overload by limiting the rate of processing messages 4 | or function calls. 5 | -------------------------------------------------------------------------------- /patterns/real-life-process.md: -------------------------------------------------------------------------------- 1 | Name: Real Life Process 2 | Scope: Principle 3 | Summary: Use one process per real life concurrent activity. 4 | -------------------------------------------------------------------------------- /patterns/response-handler.erl: -------------------------------------------------------------------------------- 1 | Name: Response Handler 2 | Scope: Function Type 3 | -------------------------------------------------------------------------------- /patterns/separation-of-concerns.md: -------------------------------------------------------------------------------- 1 | Name: Separation of Concerns 2 | Scope: Principle 3 | Summary: Manage complexity by separating a system into separate, easily 4 | understandable pieces that work together as a whole. 5 | -------------------------------------------------------------------------------- /patterns/service.md: -------------------------------------------------------------------------------- 1 | Name: Service 2 | Scope: Process/Behavior Type 3 | Summary: Use a process to provide a long running service. 4 | -------------------------------------------------------------------------------- /patterns/shape-converter.md: -------------------------------------------------------------------------------- 1 | Name: Shape Converter 2 | Scope: Function Type 3 | Summary: Use a function to convert the shape of one term to another. 4 | -------------------------------------------------------------------------------- /patterns/short-functions.md: -------------------------------------------------------------------------------- 1 | Name: Short Functions 2 | Scope: Principle 3 | Summary: Short functions that have a single purpose that is easily 4 | understood are easier to understand and therefore maintain 5 | than long functions. 6 | -------------------------------------------------------------------------------- /patterns/stats-sink.md: -------------------------------------------------------------------------------- 1 | Name: Stats Sink 2 | Scope: Application Level Facility 3 | Summary: Processes can send statistics to a collector, which in turn can 4 | provide those statics at large. 5 | -------------------------------------------------------------------------------- /patterns/step-processor.md: -------------------------------------------------------------------------------- 1 | Name: Step Processor 2 | Scope: Function Type 3 | Summary: Orchestrate a series of operations, each as a step. 4 | -------------------------------------------------------------------------------- /patterns/step.md: -------------------------------------------------------------------------------- 1 | Name: Step 2 | Scope: Function Type 3 | Summary: A function can perform a step in a chain of operations 4 | orchestrated by a step processor. 5 | -------------------------------------------------------------------------------- /patterns/supervisor.md: -------------------------------------------------------------------------------- 1 | Name: Supervisor 2 | Scope: Erlang/OTP Construct 3 | Summary: Use a process to start and monitor a process, optionally restarting 4 | the monitored process if it exits. 5 | -------------------------------------------------------------------------------- /patterns/system-boundary-validation.md: -------------------------------------------------------------------------------- 1 | Name: System Boundary Validation 2 | Scope: Principle 3 | Summary: TODO - From observations in Mostly Erlang about how to validate 4 | payload. 5 | -------------------------------------------------------------------------------- /patterns/tagged-tuple.md: -------------------------------------------------------------------------------- 1 | Name: Tagged Tuple 2 | Scope: Not Sure 3 | Summary: TODO - From Mostly Erlang podcast - on a convention for representing 4 | types in Erlang. 5 | -------------------------------------------------------------------------------- /project.config: -------------------------------------------------------------------------------- 1 | %-*-erlang-*- 2 | #{ 3 | site_url => "http://www.erlangpatterns.org", 4 | license_url => "https://creativecommons.org/licenses/by/4.0/", 5 | license_title => "Creative Commons Attribution 4.0 International", 6 | github_url => "https://github.com/gar1t/erlang-patterns", 7 | gitrepo_url => "https://github.com/gar1t/erlang-patterns" 8 | }. 9 | -------------------------------------------------------------------------------- /site.config: -------------------------------------------------------------------------------- 1 | %-*-erlang-*- 2 | #{title => "Erlang Patterns", 3 | tagline => "The timeless way of building... Erlang apps!", 4 | subtagline => ""}. 5 | -------------------------------------------------------------------------------- /snippets/Makefile: -------------------------------------------------------------------------------- 1 | gen: 2 | cd ..; make gen 3 | -------------------------------------------------------------------------------- /snippets/gist.md: -------------------------------------------------------------------------------- 1 | Erlang Patterns is an experimental project to apply 2 | [Christopher Alexander's](http://en.wikipedia.org/wiki/Christopher_Alexander) 3 | pattern language method, as outlined in 4 | [The Timeless Way of Building](http://en.wikipedia.org/wiki/The_Timeless_Way_of_Building), 5 | to Erlang programming. Unlike traditional 6 | [software design pattern](http://en.wikipedia.org/wiki/Software_design_pattern) 7 | efforts, which tend to emphasize the importance of code reuse, this 8 | project emphasizes patterns that *feel good to humans*. For more 9 | information, see the project [Methodology](methodology.html). 10 | -------------------------------------------------------------------------------- /snippets/goals.md: -------------------------------------------------------------------------------- 1 | - Develop a living pattern language that can be used by Erlang programmers to 2 | build better software 3 | - Support a community wide effort to define Erlang patterns 4 | - Experiment, refine, mature --- and have fun! 5 | -------------------------------------------------------------------------------- /template/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Creative Commons Attribution 3.0 Unported 2 | http://creativecommons.org/licenses/by/3.0/ 3 | 4 | License 5 | 6 | THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. 7 | 8 | BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. 9 | 10 | 1. Definitions 11 | 12 | 1. "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License. 13 | 2. "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined above) for the purposes of this License. 14 | 3. "Distribute" means to make available to the public the original and copies of the Work or Adaptation, as appropriate, through sale or other transfer of ownership. 15 | 4. "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License. 16 | 5. "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast. 17 | 6. "Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work. 18 | 7. "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation. 19 | 8. "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images. 20 | 9. "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium. 21 | 22 | 2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws. 23 | 24 | 3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below: 25 | 26 | 1. to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections; 27 | 2. to create and Reproduce Adaptations provided that any such Adaptation, including any translation in any medium, takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original Work. For example, a translation could be marked "The original work was translated from English to Spanish," or a modification could indicate "The original work has been modified."; 28 | 3. to Distribute and Publicly Perform the Work including as incorporated in Collections; and, 29 | 4. to Distribute and Publicly Perform Adaptations. 30 | 5. 31 | 32 | For the avoidance of doubt: 33 | 1. Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; 34 | 2. Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor waives the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; and, 35 | 3. Voluntary License Schemes. The Licensor waives the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License. 36 | 37 | The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved. 38 | 39 | 4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions: 40 | 41 | 1. You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(b), as requested. If You create an Adaptation, upon notice from any Licensor You must, to the extent practicable, remove from the Adaptation any credit as required by Section 4(b), as requested. 42 | 2. If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and (iv) , consistent with Section 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). The credit required by this Section 4 (b) may be implemented in any reasonable manner; provided, however, that in the case of a Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties. 43 | 3. Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. Licensor agrees that in those jurisdictions (e.g. Japan), in which any exercise of the right granted in Section 3(b) of this License (the right to make Adaptations) would be deemed to be a distortion, mutilation, modification or other derogatory action prejudicial to the Original Author's honor and reputation, the Licensor will waive or not assert, as appropriate, this Section, to the fullest extent permitted by the applicable national law, to enable You to reasonably exercise Your right under Section 3(b) of this License (right to make Adaptations) but not otherwise. 44 | 45 | 5. Representations, Warranties and Disclaimer 46 | 47 | UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. 48 | 49 | 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 50 | 51 | 7. Termination 52 | 53 | 1. This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Adaptations or Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License. 54 | 2. Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above. 55 | 56 | 8. Miscellaneous 57 | 58 | 1. Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License. 59 | 2. Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License. 60 | 3. If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. 61 | 4. No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent. 62 | 5. This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You. 63 | 6. The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law. 64 | -------------------------------------------------------------------------------- /template/Makefile: -------------------------------------------------------------------------------- 1 | gen: 2 | cd ..; make gen 3 | -------------------------------------------------------------------------------- /template/README.txt: -------------------------------------------------------------------------------- 1 | Minimaxing by HTML5 UP 2 | html5up.net | @n33co 3 | Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 4 | 5 | 6 | The very first responsive site template I ever made on 5grid (now upgraded to skelJS). 7 | It's clean, minimal, and so generic you can use it for pretty much anything. 8 | 9 | Feedback, bug reports, and comments are not only welcome, but strongly encouraged :) 10 | 11 | AJ 12 | n33.co @n33co dribbble.com/n33 13 | 14 | 15 | Credits: 16 | 17 | Demo Images: 18 | Unsplash (unsplash.com) 19 | 20 | Other: 21 | jQuery (jquery.com) 22 | html5shiv.js (@afarkas @jdalton @jon_neal @rem) 23 | skel (n33.co) -------------------------------------------------------------------------------- /template/base.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | {{site.title}} 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | {% block header %}{% include "header.html" %}{% endblock %} 23 | {% block banner %}{% endblock %} 24 | {% block main %}{% endblock %} 25 | {% block footer %}{% include "footer.html" %}{% endblock %} 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | {% block scripts %}{% endblock %} 34 | 35 | 36 | -------------------------------------------------------------------------------- /template/contributing.html: -------------------------------------------------------------------------------- 1 | {% extends "simplepage.html" %} 2 | 3 | {% block content %} 4 |
5 | {{ contributing|markdown_to_html }} 6 |
7 | {% endblock %} 8 | -------------------------------------------------------------------------------- /template/css/Makefile: -------------------------------------------------------------------------------- 1 | gen: 2 | cd ../..; make gen 3 | -------------------------------------------------------------------------------- /template/css/ie9.css: -------------------------------------------------------------------------------- 1 | /* 2 | Minimaxing by HTML5 UP 3 | html5up.net | @n33co 4 | Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | */ 6 | 7 | /* Reusable */ 8 | 9 | .button { 10 | background-image: url("images/ie/button.svg"); 11 | } 12 | 13 | .button:hover { 14 | background-image: url("images/ie/button-hover.svg"); 15 | } 16 | 17 | /* Header */ 18 | 19 | #header-wrapper { 20 | background-image: url("images/ie/header-wrapper.svg"); 21 | } 22 | 23 | #header { 24 | background-image: url("images/ie/header.svg"); 25 | } 26 | 27 | #header nav a.current-page-item { 28 | background-image: url("images/ie/nav-a.svg"); 29 | } 30 | 31 | #header nav a:hover { 32 | background-image: url("images/ie/nav-a-hover.svg"); 33 | } -------------------------------------------------------------------------------- /template/css/images/banner.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gar1t/erlang-patterns/ef2bfe2d2a215d7ec6071d53501c68e1a0a71e24/template/css/images/banner.jpg -------------------------------------------------------------------------------- /template/css/images/bg1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gar1t/erlang-patterns/ef2bfe2d2a215d7ec6071d53501c68e1a0a71e24/template/css/images/bg1.png -------------------------------------------------------------------------------- /template/css/images/icon-bubble.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gar1t/erlang-patterns/ef2bfe2d2a215d7ec6071d53501c68e1a0a71e24/template/css/images/icon-bubble.png -------------------------------------------------------------------------------- /template/css/images/ie/button-hover.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /template/css/images/ie/button.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /template/css/images/ie/header-wrapper.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /template/css/images/ie/header.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /template/css/images/ie/nav-a-hover.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /template/css/images/ie/nav-a.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /template/css/images/mobileUI-site-nav-opener-bg.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /template/css/style-0-1000px.css: -------------------------------------------------------------------------------- 1 | /* 2 | Minimaxing by HTML5 UP 3 | html5up.net | @n33co 4 | Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | */ 6 | 7 | /*********************************************************************************/ 8 | /* 1000px (> 480px && < 1200px) */ 9 | /*********************************************************************************/ 10 | 11 | /* Basic */ 12 | 13 | body { 14 | min-width: 1000px; 15 | } 16 | 17 | /* Reusable */ 18 | 19 | ul.small-image-list img { 20 | width: 50px; 21 | } 22 | 23 | ul.big-image-list img { 24 | width: 75px; 25 | } 26 | 27 | /* Header */ 28 | 29 | #header { 30 | height: 76px; 31 | } 32 | 33 | #header h1 { 34 | font-size: 2em; 35 | line-height: 76px; 36 | } 37 | 38 | #header nav { 39 | line-height: 74px; 40 | font-size: 1.1em; 41 | } 42 | 43 | #header nav a { 44 | padding: 0 20px 0 20px; 45 | } 46 | 47 | /* Banner */ 48 | 49 | #banner { 50 | width: 960px; 51 | height: 220px; 52 | background-size: 960px 220px; 53 | } 54 | 55 | #banner h2 { 56 | font-size: 3em; 57 | top: 80px; 58 | } 59 | 60 | #banner span { 61 | font-size: 1.4em; 62 | bottom: 85px; 63 | } 64 | 65 | /* Footer */ 66 | 67 | #footer-wrapper { 68 | padding: 5% 0 5% 0; 69 | } 70 | 71 | /* Copyright */ 72 | 73 | #copyright { 74 | padding: 3em 0 0 0; 75 | margin: 5% 0 0 0; 76 | } -------------------------------------------------------------------------------- /template/css/style-0-desktop.css: -------------------------------------------------------------------------------- 1 | /* 2 | Minimaxing by HTML5 UP 3 | html5up.net | @n33co 4 | Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | */ 6 | 7 | /*********************************************************************************/ 8 | /* Desktop (>= 480px) */ 9 | /*********************************************************************************/ 10 | 11 | /* Basic */ 12 | 13 | body { 14 | min-width: 1200px; 15 | } 16 | 17 | section, article { 18 | margin: 0 0 60px 0; 19 | } 20 | 21 | section:last-child, article:last-child { 22 | margin-bottom: 0; 23 | } 24 | 25 | section.left-content { 26 | padding-right: 30px; 27 | } 28 | 29 | section.right-content { 30 | padding-left: 30px; 31 | } 32 | 33 | section.middle-content { 34 | padding: 0 30px 0 30px; 35 | } 36 | 37 | ul.small-image-list img { 38 | width: 78px; 39 | } 40 | 41 | ul.big-image-list img { 42 | width: 178px; 43 | } 44 | 45 | /* Reusable */ 46 | 47 | .blog-post-image { 48 | width: 100%; 49 | } 50 | 51 | /* Header */ 52 | 53 | #header-wrapper { 54 | background-color: #007294; 55 | background-image: -moz-linear-gradient(top, #008dab, #007294); 56 | background-image: -webkit-linear-gradient(top, #008dab, #007294); 57 | background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#008dab), to(#007294)); 58 | background-image: -ms-linear-gradient(top, #008dab, #007294); 59 | background-image: -o-linear-gradient(top, #008dab, #007294); 60 | background-image: linear-gradient(top, #008dab, #007294); 61 | } 62 | 63 | #header { 64 | position: relative; 65 | margin: 2.5% 0 2.5% 0; 66 | padding: 0 40px 0 40px; 67 | border-radius: 10px; 68 | border: solid 1px #006e8b; 69 | box-shadow: inset 0px 0px 0px 1px #12a0bf, 0px 1px 4px 0px rgba(0,0,0,0.10); 70 | background-color: #007b9d; 71 | background-image: -moz-linear-gradient(top, #008ead, #007b9d); 72 | background-image: -webkit-linear-gradient(top, #008ead, #007b9d); 73 | background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#008ead), to(#007b9d)); 74 | background-image: -ms-linear-gradient(top, #008ead, #007b9d); 75 | background-image: -o-linear-gradient(top, #008ead, #007b9d); 76 | background-image: linear-gradient(top, #008ead, #007b9d); 77 | height: 86px; 78 | -moz-box-sizing:content-box;-webkit-box-sizing:content-box;-o-box-sizing:content-box;-ms-box-sizing:content-box;box-sizing:content-box 79 | } 80 | 81 | #header h1 { 82 | position: absolute; 83 | left: 40px; 84 | top: 0; 85 | color: #fff; 86 | font-size: 2.4em; 87 | letter-spacing: -2px; 88 | line-height: 86px; 89 | } 90 | 91 | #header h1 a { 92 | color: #fff; 93 | text-decoration: none; 94 | } 95 | 96 | #header nav { 97 | position: absolute; 98 | right: 40px; 99 | top: 1px; 100 | line-height: 84px; 101 | text-transform_xxx: lowercase; 102 | font-size: 1.3em; 103 | letter-spacing: -1px; 104 | } 105 | 106 | #header nav a { 107 | display: inline-block; 108 | text-decoration: none; 109 | color: #fff; 110 | padding: 0 25px 0 25px; 111 | outline: 0; 112 | } 113 | 114 | #header nav a.current-page-item { 115 | background-color: #007897; 116 | background-image: -moz-linear-gradient(top, #007b99, #007897); 117 | background-image: -webkit-linear-gradient(top, #007b99, #007897); 118 | background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#007b99), to(#007897)); 119 | background-image: -ms-linear-gradient(top, #007b99, #007897); 120 | background-image: -o-linear-gradient(top, #007b99, #007897); 121 | background-image: linear-gradient(top, #007b99, #007897); 122 | box-shadow: inset 0px 1px 5px 1px rgba(0,0,0,0.1), 0px 0px 5px 1px rgba(255,255,255,0.1); 123 | } 124 | 125 | #header nav a:hover { 126 | background-color: #0882a1; 127 | background-image: -moz-linear-gradient(top, #0782a0, #077d9b); 128 | background-image: -webkit-linear-gradient(top, #0782a0, #077d9b); 129 | background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#0782a0), to(#077d9b)); 130 | background-image: -ms-linear-gradient(top, #0782a0, #077d9b); 131 | background-image: -o-linear-gradient(top, #0782a0, #077d9b); 132 | background-image: linear-gradient(top, #0782a0, #077d9b); 133 | box-shadow: inset 0px 1px 5px 1px rgba(0,0,0,0.05), 0px 0px 5px 1px rgba(255,255,255,0.05); 134 | } 135 | 136 | /* Banner */ 137 | 138 | #banner-wrapper { 139 | background: #c8d2bc url(images/bg1.png); 140 | padding: 2em 0; 141 | } 142 | 143 | #banner { 144 | position: relative; 145 | width: 1160px; 146 | height: 265px; 147 | box-shadow: 0px 2px 4px 0px rgba(0,0,0,0.10); 148 | border-radius: 10px; 149 | padding: 20px; 150 | background: #fff url(images/banner.jpg) no-repeat 20px 20px; 151 | background-size: 1160px 265px; 152 | -moz-box-sizing:content-box;-webkit-box-sizing:content-box;-o-box-sizing:content-box;-ms-box-sizing:content-box;box-sizing:content-box 153 | } 154 | 155 | #banner h2 { 156 | position: absolute; 157 | z-index: 1; 158 | width: 100%; 159 | top: 117px; 160 | left: 0; 161 | font-size: 3.3em; 162 | color: #fff; 163 | text-align: center; 164 | letter-spacing: -2px; 165 | } 166 | 167 | #banner span { 168 | display: block; 169 | position: absolute; 170 | z-index: 1; 171 | width: 100%; 172 | bottom: 105px; 173 | left: 0; 174 | font-size: 1.6em; 175 | color: #fff; 176 | text-align: center; 177 | letter-spacing: -1px; 178 | text-transform_xxx: lowercase; 179 | opacity: 0.8; 180 | } 181 | 182 | /* Main */ 183 | 184 | #main { 185 | background: #fff; 186 | padding: 4em 0; 187 | } 188 | 189 | /* Footer */ 190 | 191 | #footer-wrapper { 192 | padding: 4em 0; 193 | } 194 | 195 | /* Copyright */ 196 | 197 | #copyright { 198 | text-align: center; 199 | color: #A6A88F; 200 | border-top: solid 1px #ced0b7; 201 | padding: 3em 0 0 0; 202 | margin: 1% 0 0 0; 203 | } 204 | 205 | #copyright a { 206 | color: #A6A88F; 207 | } 208 | -------------------------------------------------------------------------------- /template/css/style-0-mobile.css: -------------------------------------------------------------------------------- 1 | /* 2 | Minimaxing by HTML5 UP 3 | html5up.net | @n33co 4 | Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | */ 6 | 7 | /*********************************************************************************/ 8 | /* Mobile (<= 480px) */ 9 | /*********************************************************************************/ 10 | 11 | /* Basic */ 12 | 13 | body { 14 | font-size: 13pt; 15 | } 16 | 17 | h2 { 18 | font-size: 1.4em; 19 | } 20 | 21 | h3 { 22 | font-size: 1.2em; 23 | } 24 | 25 | h4 { 26 | font-size: 1em; 27 | } 28 | 29 | /* Reusable */ 30 | 31 | ul.small-image-list img { 32 | width: 75px; 33 | } 34 | 35 | ul.big-image-list img { 36 | width: 75px; 37 | } 38 | 39 | ul.link-list { 40 | margin: 0 0 2em 0; 41 | } 42 | 43 | section, article { 44 | padding: 40px 20px 40px 20px; 45 | } 46 | 47 | #main section, #main article { 48 | background: #fff; 49 | } 50 | 51 | article.blog-post .comments { 52 | display: block; 53 | position: relative; 54 | top: -0.5em; 55 | margin: 0 0 0.5em 0; 56 | } 57 | 58 | article.blog-post h2 { 59 | } 60 | 61 | .button { 62 | font-size: 1em; 63 | } 64 | 65 | .blog-post-image { 66 | width: 100%; 67 | } 68 | 69 | /* Header */ 70 | 71 | #header-wrapper { 72 | background-color: #007294; 73 | background-image: -moz-linear-gradient(top, #008dab, #007294); 74 | background-image: -webkit-linear-gradient(top, #008dab, #007294); 75 | background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#008dab), to(#007294)); 76 | background-image: -ms-linear-gradient(top, #008dab, #007294); 77 | background-image: -o-linear-gradient(top, #008dab, #007294); 78 | background-image: linear-gradient(top, #008dab, #007294); 79 | } 80 | 81 | #header { 82 | display: none; 83 | } 84 | 85 | /* Banner */ 86 | 87 | #banner-wrapper { 88 | background: #c8d2bc url(images/bg1.png); 89 | display: none; 90 | } 91 | 92 | #banner { 93 | position: relative; 94 | width: 100%; 95 | height: 240px; 96 | background: #fff url(images/banner.jpg) no-repeat; 97 | background-size: 100% 100%; 98 | } 99 | 100 | #banner { 101 | position: relative; 102 | } 103 | 104 | #banner h2 { 105 | position: absolute; 106 | z-index: 1; 107 | width: 100%; 108 | bottom: 80px; 109 | left: 0; 110 | font-size: 2em; 111 | color: #fff; 112 | text-align: center; 113 | letter-spacing: -2px; 114 | } 115 | 116 | #banner span { 117 | display: block; 118 | position: absolute; 119 | z-index: 1; 120 | width: 100%; 121 | top: 135px; 122 | left: 0; 123 | font-size: 1em; 124 | color: #fff; 125 | text-align: center; 126 | letter-spacing: -1px; 127 | text-transform: lowercase; 128 | opacity: 0.8; 129 | } 130 | 131 | /* Main */ 132 | 133 | #main { 134 | margin-top: 44px; 135 | } 136 | 137 | /* Footer */ 138 | 139 | #footer-wrapper section, #footer-wrapper article { 140 | border-bottom: solid 1px #ced0b7; 141 | } 142 | 143 | /* Copyright */ 144 | 145 | #copyright { 146 | text-align: center; 147 | color: #A6A88F; 148 | padding: 40px; 149 | font-size: 0.8em; 150 | line-height: 1.5em; 151 | } 152 | 153 | #copyright a { 154 | color: #A6A88F; 155 | } 156 | 157 | /* Mobile UI */ 158 | 159 | #titleBar { 160 | text-align: center; 161 | color: #fff; 162 | font-size: 1.25em; 163 | background-color: #007294; 164 | background-image: -moz-linear-gradient(top, #008dab, #007294); 165 | background-image: -webkit-linear-gradient(top, #008dab, #007294); 166 | background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#008dab), to(#007294)); 167 | background-image: -ms-linear-gradient(top, #008dab, #007294); 168 | background-image: -o-linear-gradient(top, #008dab, #007294); 169 | background-image: linear-gradient(top, #008dab, #007294); 170 | } 171 | 172 | #titleBar .title { 173 | line-height: 44px; 174 | } 175 | 176 | #titleBar .toggle { 177 | position: absolute; 178 | top: 0; 179 | left: 0; 180 | width: 80px; 181 | height: 60px; 182 | } 183 | 184 | #titleBar .toggle:after { 185 | content: ''; 186 | position: absolute; 187 | left: 4px; 188 | top: 4px; 189 | color: #fff; 190 | text-align: center; 191 | line-height: 31px; 192 | font-size: 0.8em; 193 | width: 50px; 194 | height: 35px; 195 | border-radius: 5px; 196 | box-shadow: inset 0px 0px 0px 1px rgba(0,0,0,0.25), inset 0px 1px 2px 0px rgba(0,0,0,0.5), inset 0px 6px 13px 0px rgba(255,255,255,0.2), 0px 2px 2px 0px rgba(255,255,255,0.1); 197 | } 198 | 199 | #titleBar .toggle:before { 200 | content: ''; 201 | position: absolute; 202 | width: 20px; 203 | height: 30px; 204 | background: url('images/mobileUI-site-nav-opener-bg.svg'); 205 | top: 16px; 206 | left: 19px; 207 | } 208 | 209 | #titleBar .toggle:active:after { 210 | background: rgba(0,0,0,0.2); 211 | } 212 | 213 | #navPanel { 214 | background: #00536F; 215 | color: #fff; 216 | box-shadow: inset -10px 0px 40px 0px rgba(0,0,0,0.5); 217 | } 218 | 219 | #navPanel .link { 220 | display: block; 221 | color: #fff; 222 | border-top: solid 1px rgba(255,255,255,0.1); 223 | border-bottom: solid 1px rgba(0,0,0,0.2); 224 | height: 55px; 225 | line-height: 55px; 226 | padding: 0 15px 0 15px; 227 | text-decoration: none; 228 | } 229 | 230 | #navPanel .link:first-child { 231 | border-top: 0; 232 | } 233 | 234 | #navPanel .link:last-child { 235 | border-bottom: 0; 236 | } -------------------------------------------------------------------------------- /template/css/style-0.css: -------------------------------------------------------------------------------- 1 | /* 2 | Minimaxing by HTML5 UP 3 | html5up.net | @n33co 4 | Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | */ 6 | 7 | /*********************************************************************************/ 8 | /* Global */ 9 | /*********************************************************************************/ 10 | 11 | /* Basic */ 12 | 13 | body { 14 | font-size: 13.5pt; 15 | font-family: sans-serif; 16 | background-color: #e3e9dc; 17 | font-family: 'Ubuntu Condensed', sans-serif; 18 | color: #878e83; 19 | letter-spacing: -1px; 20 | } 21 | 22 | h1,h2,h3,h4 { 23 | color: #007897; 24 | font-weight: normal; 25 | } 26 | 27 | h1,h2 { 28 | text-transform_xxx: lowercase; 29 | } 30 | 31 | h1 { 32 | font-size: 2em; 33 | letter-spacing: -1px; 34 | margin-bottom: 1em; 35 | } 36 | 37 | h2 { 38 | font-size: 1.6em; 39 | letter-spacing: -1px; 40 | margin-bottom: 0.75em; 41 | } 42 | 43 | h3,h4 { 44 | color: #283121; 45 | margin-bottom: 0.5em; 46 | } 47 | 48 | h3 { 49 | font-size: 1.2em; 50 | margin-bottom: 0.8em; 51 | } 52 | 53 | h4 { 54 | font-size: 1em; 55 | } 56 | 57 | p, ul { 58 | margin-bottom: 1.1em; 59 | } 60 | 61 | p { 62 | line-height: 1.5em; 63 | } 64 | 65 | pre { 66 | margin-bottom: 1.1em; 67 | } 68 | 69 | strong { 70 | color: #474e43; 71 | font-weight: bold; 72 | } 73 | 74 | em { 75 | font-style: italic; 76 | } 77 | 78 | img.left { 79 | float: left; 80 | margin: 2px 1.25em 0 0; 81 | } 82 | 83 | img.top { 84 | margin: 4px 0 2.25em 0; 85 | } 86 | 87 | ul { 88 | padding: 0 0 0 0; 89 | } 90 | 91 | a { 92 | color: #5d93a2; 93 | text-decoration: underline; 94 | } 95 | 96 | a:hover { 97 | text-decoration: none; 98 | } 99 | 100 | * > p:last-child { 101 | margin-bottom: 0 !important; 102 | } 103 | 104 | /* Reusable */ 105 | 106 | article.blog-post { 107 | position: relative; 108 | } 109 | 110 | article.blog-post .comments { 111 | position: absolute; 112 | top: 0; 113 | right: 0; 114 | height: 32px; 115 | line-height: 24px; 116 | padding-left: 40px; 117 | background: url('images/icon-bubble.png') no-repeat; 118 | } 119 | 120 | ul.small-image-list { 121 | } 122 | 123 | ul.small-image-list li { 124 | overflow: hidden; 125 | margin-bottom: 1.5em; 126 | } 127 | 128 | ul.big-image-list { 129 | } 130 | 131 | ul.big-image-list li { 132 | overflow: hidden; 133 | margin-bottom: 2em; 134 | } 135 | 136 | ul.link-list { 137 | } 138 | 139 | ul.link-list li { 140 | border-top: solid 1px #ced0b7; 141 | padding: 0.75em 0 0 0; 142 | margin: 0.75em 0 0 0; 143 | } 144 | 145 | ul.link-list li:first-child { 146 | padding-top: 0; 147 | margin-top: 0; 148 | border-top: 0; 149 | } 150 | 151 | div.goals li { 152 | } 153 | 154 | div.goals li { 155 | border-top: solid 1px #ced0b7; 156 | padding: 0.75em 0 0 0; 157 | margin: 0.75em 0 0 0; 158 | line-height: 1.4em; 159 | } 160 | 161 | div.goals li:first-child { 162 | padding-top: 0; 163 | margin-top: 0; 164 | border-top: 0; 165 | } 166 | 167 | .button { 168 | display: inline-block; 169 | padding: 15px 25px 15px 25px; 170 | background-color: #007b9d; 171 | background-image: -moz-linear-gradient(top, #008dad, #007b9d); 172 | background-image: -webkit-linear-gradient(top, #008dad, #007b9d); 173 | background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#008dad), to(#007b9d)); 174 | background-image: -ms-linear-gradient(top, #008dad, #007b9d); 175 | background-image: -o-linear-gradient(top, #008dad, #007b9d); 176 | background-image: linear-gradient(top, #008dad, #007b9d); 177 | border-radius: 10px; 178 | text-transform: lowercase; 179 | text-decoration: none; 180 | color: #fff; 181 | font-size: 1.2em; 182 | letter-spacing: -1px; 183 | border: solid 1px #006e8b; 184 | box-shadow: inset 0px 0px 0px 1px #18a8c8; 185 | } 186 | 187 | .button:hover { 188 | background-color: #118eb1; 189 | background-image: -moz-linear-gradient(top, #1b9fbe, #118eb1); 190 | background-image: -webkit-linear-gradient(top, #1b9fbe, #118eb1); 191 | background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#1b9fbe), to(#118eb1)); 192 | background-image: -ms-linear-gradient(top, #1b9fbe, #118eb1); 193 | background-image: -o-linear-gradient(top, #1b9fbe, #118eb1); 194 | background-image: linear-gradient(top, #1b9fbe, #118eb1); 195 | box-shadow: inset 0px 0px 0px 1px #3ecceb; 196 | } 197 | 198 | .recent-patterns h3 { 199 | display: inline; 200 | font-size: 1em; 201 | font-weight: bold; 202 | margin-right: 0.3em; 203 | } 204 | 205 | .recent-patterns p { 206 | display: inline; 207 | line-height: 1.4em; 208 | } 209 | 210 | .recent-patterns li { 211 | border-top: solid 1px #ced0b7; 212 | padding: 0.75em 0 0 0; 213 | margin: 0.75em 0 0 0; 214 | } 215 | 216 | .recent-patterns li:first-child { 217 | padding-top: 0; 218 | margin-top: 0; 219 | border-top: 0; 220 | } 221 | 222 | .real-lists ul { 223 | list-style-type: circle; 224 | list-style-type: square; 225 | padding: 0 1.5em; 226 | } 227 | 228 | .real-lists ul li { 229 | margin-top: 0.3em; 230 | } 231 | 232 | .real-lists ul li p { 233 | line-height: 1.4em; 234 | } 235 | 236 | ul.github-commits-list li { 237 | margin-top: 1em; 238 | display: table; 239 | } 240 | 241 | ul.github-commits-list li>* { 242 | display: table-cell; 243 | vertical-align: middle; 244 | } 245 | 246 | span.github-user { 247 | padding-right: 0.4em; 248 | } 249 | 250 | span.github-user img { 251 | border-radius: 15px; 252 | } 253 | 254 | a.github-commit { 255 | text-decoration: none; 256 | line-height: 1.2em; 257 | } 258 | 259 | .pattern-row div { 260 | line-height: 1.4em; 261 | } 262 | 263 | code { 264 | font-family: monospace, Courier; 265 | font-size: 80%; 266 | } 267 | -------------------------------------------------------------------------------- /template/footer.html: -------------------------------------------------------------------------------- 1 | 35 | -------------------------------------------------------------------------------- /template/header.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 | 9 |
10 |
11 |
12 |
13 | -------------------------------------------------------------------------------- /template/images/creativecommons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gar1t/erlang-patterns/ef2bfe2d2a215d7ec6071d53501c68e1a0a71e24/template/images/creativecommons.png -------------------------------------------------------------------------------- /template/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gar1t/erlang-patterns/ef2bfe2d2a215d7ec6071d53501c68e1a0a71e24/template/images/favicon.png -------------------------------------------------------------------------------- /template/images/pic1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gar1t/erlang-patterns/ef2bfe2d2a215d7ec6071d53501c68e1a0a71e24/template/images/pic1.jpg -------------------------------------------------------------------------------- /template/images/pic2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gar1t/erlang-patterns/ef2bfe2d2a215d7ec6071d53501c68e1a0a71e24/template/images/pic2.jpg -------------------------------------------------------------------------------- /template/images/pic3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gar1t/erlang-patterns/ef2bfe2d2a215d7ec6071d53501c68e1a0a71e24/template/images/pic3.jpg -------------------------------------------------------------------------------- /template/images/pic4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gar1t/erlang-patterns/ef2bfe2d2a215d7ec6071d53501c68e1a0a71e24/template/images/pic4.jpg -------------------------------------------------------------------------------- /template/images/pic5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gar1t/erlang-patterns/ef2bfe2d2a215d7ec6071d53501c68e1a0a71e24/template/images/pic5.jpg -------------------------------------------------------------------------------- /template/images/pic6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gar1t/erlang-patterns/ef2bfe2d2a215d7ec6071d53501c68e1a0a71e24/template/images/pic6.jpg -------------------------------------------------------------------------------- /template/index.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block banner %} 4 | 14 | {% endblock %} 15 | 16 | {% block main %} 17 |
18 |
19 |
20 | 21 |
22 |
23 |

About

24 | {{ snippets|get:'gist'|markdown_to_html }} 25 |
26 |
27 | 28 |
29 |
30 |

Goals

31 |
32 | {{ snippets|get:'goals'|markdown_to_html }} 33 |
34 |
35 |
36 | 37 |
38 |
39 |

Project Activity

40 |
41 | See 42 | all project commits 43 |
44 |
45 | 46 |
47 |
48 |
49 | {% endblock %} 50 | 51 | {% block scripts %} 52 | 53 | 62 | {% endblock %} 63 | -------------------------------------------------------------------------------- /template/js/github.commits.widget.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | https://github.com/alexanderbeletsky/github-commits-widget 4 | 5 | # Legal Info (MIT License) 6 | 7 | Copyright (c) 2012 Alexander Beletsky 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in 17 | all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | THE SOFTWARE. 26 | 27 | */ 28 | 29 | (function ($) { 30 | function widget(element, options, callback) { 31 | this.element = element; 32 | this.options = options; 33 | this.callback = $.isFunction(callback) ? callback : $.noop; 34 | } 35 | 36 | widget.prototype = (function() { 37 | 38 | function getCommits(user, repo, branch, callback) { 39 | $.ajax({ 40 | url: "https://api.github.com/repos/" + user + "/" + repo + "/commits?sha=" + branch, 41 | dataType: 'jsonp', 42 | success: callback 43 | }); 44 | } 45 | 46 | function _widgetRun(widget) { 47 | if (!widget.options) { 48 | widget.element.append('Options for widget are not set.'); 49 | return; 50 | } 51 | var callback = widget.callback; 52 | var element = widget.element; 53 | var user = widget.options.user; 54 | var repo = widget.options.repo; 55 | var branch = widget.options.branch; 56 | var avatarSize = widget.options.avatarSize || 30; 57 | var last = widget.options.last === undefined ? 10 : widget.options.last; 58 | var limitMessage = widget.options.limitMessageTo === undefined ? 0 : widget.options.limitMessageTo; 59 | 60 | getCommits(user, repo, branch, function (data) { 61 | 62 | var commits = data.data; 63 | var totalCommits = (last < commits.length ? last : commits.length); 64 | 65 | element.empty(); 66 | 67 | var list = $('