| // see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment | |
| // see: https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/ | |
| var a, b, c, x, y, z, key, foo, bar, baz; | |
| // destructuring arrays (and default values) | |
| [a, b, c=5] = [10, 20]; | |
| a // 10 | |
| b // 20 | |
| c // 5 |
| let base_url = 'https://apc.openbankproject.com'; | |
| let direct_login_endpoint = 'https://apc.openbankproject.com/my/logins/direct'; | |
| let api_base_url = 'https://apc.openbankproject.com/obp/v3.0.0'; | |
| let username = 'br3nt'; | |
| let password = 'password123456789'; | |
| let consumer_key = '4gvswztl1pbqyijiv4dffnhnvpyneiye43ekcno0'; | |
| let consumer_secret = 'ji5tnnxfywllhr24fgcdj3j5ycy4guywatflgtps'; | |
| var token = null; | |
| // get token |
| class Graph | |
| def initialize | |
| @vertices = Set.new | |
| @edges = [] | |
| end | |
| def add_edge(origin, destination) | |
| @vertices << origin << destination | |
| @edges << [origin, destination] | |
| end |
| // see: https://ariya.io/2013/08/searching-with-array-prototype-some | |
| // map function on an array (clasic syntax) | |
| [1, 2, 3].map(function (x) { return x * x}); | |
| // map function on an array (new syntax) | |
| [1, 2, 3].map((x) => x * x); | |
| // ensure array elements are populated (with undefined) | |
| Array.apply(0, Array(3)) // [undefined, undefined, undefined] |
This is copied from [this SO answer][1].
There is a difference between error codes and error return values. An error code is for the user and help desk. An error return value is a coding technique to indicate that your code has encountered an error.
One can implement error codes using error return values, but I would advice against that. Exceptions are the modern way to report errors, and there is no reason why they should not carry an error code within them.
This is how I would organize it (Note that points 2-6 are language agnostic):
- Use a custom exception type with an additional
ErrorCodeproperty. The catch in the main loop will report this field in the usual way (log file / error pop-up / error reply). Use the same exception type in all of your code. - Do not start at 1 and don't use leading zeros. Keep all error codes to the same length, so a wrong error code is easy to spot. Starting at 1000 usually is good enough. Maybe add a leading 'E' to make them clearly identifiable for users (especia
It's pretty easy to do polymorphic associations in Rails: A Picture can belong to either a BlogPost or an Article. But what if you need the relationship the other way around? A Picture, a Text and a Video can belong to an Article, and that article can find all media by calling @article.media
This example shows how to create an ArticleElement join model that handles the polymorphic relationship. To add fields that are common to all polymorphic models, add fields to the join model.
| <?xml version="1.0" encoding="utf-8"?> | |
| <xsl:stylesheet version="1.0" | |
| xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
| xmlns:fo="http://www.w3.org/1999/XSL/Format" | |
| xmlns:hsqueue="xalan://com.helpers.xsl.MessageQueue" | |
| xmlns:hshtml="xalan://com.helpers.xsl.HTML2FO"> | |
| <xsl:output method="xml" indent="yes"/> | |
| <xsl:variable name="correspondence" select="document(concat('/correspondence/', /request/id, '.xml'))"/> | |
| <xsl:variable name="letter" select="document(concat('/patients/', /request/patient_id, '/letters/', /request/letter_id, '.xml'))"/> |
| Custom | Default | Description | Plugin |
|---|---|---|---|
| ctrl+shift+t | ctrl+shift+t | Open previously closed tab | Sublime |
| ctrl+/ | ctrl+/ | Toggle code commenting on current line or selection | Sublime |
| ctrl+shift+v | ctrl+shift+v | Paste and indent contents of clipboard | Sublime |
| ctrl+shift+d | ctrl+shift+d | Duplicate current line onto next line | Sublime |
| ctrl+d | ctrl+d | Select current word or expand selection to include next occurence of word (miltiple word editing) | Sublime |
| alt+F3 | alt+F3 | Select all occurences of current word or selection (multiple word editing) | Sublime |
| ctrl+ku | ctrl+ku | Selected text to uppercase | Sublime |
| # Example of an Augmented Tree | |
| # | |
| # I have added an additional `lower_limit` method, which enables testing of overlapping children. | |
| # | |
| # See: | |
| # - https://en.wikipedia.org/wiki/Interval_tree#Augmented_tree | |
| # - http://www.davismol.net/2016/02/07/data-structures-augmented-interval-tree-to-search-for-interval-overlapping/ | |
| # - http://www.bowdoin.edu/~ltoma/teaching/cs231/fall08/Lectures/10-augmentedTrees/augtrees.pdf | |
| # |