This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var keys = { | |
| 'a': 2, 'b': 2, 'c': 2, | |
| 'd': 3, 'e': 3, 'f': 3, | |
| 'g': 4, 'h': 4, 'i': 4, | |
| 'j': 5, 'k': 5, 'l': 5, | |
| 'm': 6, 'n': 6, 'o': 6, | |
| 'p': 7, 'q': 7, 'r': 7, 's': 7, | |
| 't': 8, 'u': 8, 'v': 8, | |
| 'w': 9, 'x': 9, 'y': 9, 'z': 9 | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var createObservedObject = function(callback) { | |
| var obj = {}; | |
| var args = [].slice.call(arguments, 1); | |
| obj.addObservedProperty = function(propertyName) { | |
| obj['_' + propertyName] = undefined; | |
| Object.defineProperty(obj, propertyName, { | |
| get: function() { | |
| return obj['_' + propertyName]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var mergeSort = function(array) { | |
| function merge(left, right) { | |
| // merge two lists, which are assumed to be sorted. | |
| left || (left = []); | |
| right || (right = []); | |
| var result = []; | |
| while (left.length > 0 || right.length > 0) { | |
| if (left.length > 0 && right.length > 0) { | |
| // if both lists have values |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ysql> describe users; | |
| +------------+--------------+------+-----+---------+----------------+ | |
| | Field | Type | Null | Key | Default | Extra | | |
| +------------+--------------+------+-----+---------+----------------+ | |
| | id | int(11) | NO | PRI | NULL | auto_increment | | |
| | name | varchar(255) | NO | | NULL | | | |
| | created_at | datetime | NO | | NULL | | | |
| | updated_at | datetime | NO | | NULL | | | |
| +------------+--------------+------+-----+---------+----------------+ | |
| 4 rows in set (0.01 sec) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Node: | |
| def __init__(self, val = None): | |
| self.value = val | |
| self.next = None | |
| def printValues(self): | |
| n = self | |
| values = [n.value] | |
| while n.next: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var externalObj = {key: 'value'}; | |
| var items = { | |
| obj: { | |
| 'string prop': 'string val', | |
| 5: 10, | |
| nested: [[3, [5, 2]]], | |
| 'function': function(){return true;}, | |
| reference: externalObj | |
| }, |
NewerOlder