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
    
  
  
    
  | function getLeafNodes(data) { | |
| const leafNodes = []; | |
| function traverse(node) { | |
| if (node.children.length === 0) { | |
| leafNodes.push(node.name); | |
| } else { | |
| for (let i = 0; i < node.children.length; i++) { | |
| traverse(node.children[i]); | |
| } | 
  
    
      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
    
  
  
    
  | tumbons = [ | |
| {"province":"Bangkok", "aumper": "thonburi", "tumbon": "klong san" }, | |
| {"province":"Songkhla", "aumper": "hatyai", "tumbon": "swan neck" }, | |
| {"province":"Songkhla", "aumper": "hatyai", "tumbon": "something" } | |
| ] | |
| selectable_provinces = ko.computed(function(){ | |
| return tumbons.map(e => e.province) | |
| .distinct | 
  
    
      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
    
  
  
    
  | tumbons = [ | |
| {"province":"Bangkok", "aumper": "thonburi", "tumbon": "klong san" }, | |
| {"province":"Songkhla", "aumper": "hatyai", "tumbon": "swan neck" }, | |
| {"province":"Songkhla", "aumper": "hatyai", "tumbon": "something" } | |
| ] | |
| selectable_provinces = ko.computed(function(){ | |
| return tumbons.map(e => e.province) | |
| .distinct | 
  
    
      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
    
  
  
    
  | function getSensors(callback) { | |
| var sensorList = [1, 2, 3]; | |
| setTimeout(function(){ | |
| callback(sensorList); | |
| }, 3000); | |
| } | |
| function getSensorData(id, callback) { | |
| setTimeout(function(){ | |
| callback("Sensor data for id:" + id); | 
  
    
      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
    
  
  
    
  | def toDict(network): | |
| result = {} | |
| for c in network: | |
| left, right = c.split("-") | |
| if left in result: | |
| result[left].append(right) | |
| else: | |
| result[left] = [right] | |
  
    
      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
    
  
  
    
  | def golf(n): | |
| while True: | |
| n+=1 | |
| if not p(n)and str(n)[::-1]==str(n):return n | |
| def p(n): | |
| for i in range(2,n): | |
| if n%i==0:return True | 
  
    
      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
    
  
  
    
  | def min(*args, **kwargs): | |
| key = kwargs.get("key", None) | |
| iterable = args if len(args) > 1 else list(args[0]) | |
| minValue = iterable[0] | |
| for e in iterable: | |
| if (e if not key else key(e)) < (minValue if not key else key(minValue)): | |
| minValue = e | |