Given a forward linked list, define an iterator wich traverses
each node in the linked list calling next function repeatively?
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
| const wait = callback => new Promise((resolve, reject) => { | |
| const end = () => { | |
| try { | |
| if (callback()) { | |
| resolve(true); | |
| } else { | |
| setImmediate(end); | |
| } | |
| } catch (error) { | |
| reject(error); |
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 Foo { | |
| constructor(foo) { | |
| this.foo = foo | |
| } | |
| async execUntilStop(callback) { | |
| const timeoutLoopCallback = () => { | |
| if (this.stopExec) return; | |
| callback({ data: 'data' }); | |
| setTimeout(timeoutLoopCallback, 10); |
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
| > Node = function(){}; | |
| [Function] | |
| > Node.pro | |
| Node.propertyIsEnumerable | |
| Node.prototype | |
| > Node.prototype.foo = {bar: 'hello world'}; | |
| { bar: 'hello world' } | |
| > node = new Node(); |
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
| com.write_message( ("\x02" + 6.chr + "AE5X:W" + ("AE5X:W" ^ 6.chr) + "\x03").force_encoding("ASCII-8BIT")) | |
| class ::String | |
| ### | |
| # @return the first charater in the string as an integer | |
| def byte | |
| self.bytes[0] | |
| end | |
| ### |
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
| #include <stdio.h> | |
| #include <string.h> | |
| int main () | |
| { | |
| char str0[]="Hello world"; | |
| char str1[40]; | |
| int str0_length = strlen(str0); | |
| int i; | |
| for( i = 1 ; i <= str0_length ; 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
| >>> microAeth = serial.Serial('/dev/ttyUSB1', 500000, timeout=1, parity=serial.PARITY_MARK) | |
| Traceback (most recent call last): | |
| File "<stdin>", line 1, in <module> | |
| File "/usr/local/lib/python2.7/dist-packages/serial/serialutil.py", line 261, in __init__ | |
| self.open() | |
| File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 282, in open | |
| self._reconfigurePort() | |
| File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 376, in _reconfigurePort | |
| raise ValueError('Invalid parity: %r' % self._parity) | |
| ValueError: Invalid parity: 'M' |
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 link_to(text, address) | |
| "<a href='#{ address }'>#{ text }</a>" | |
| end | |
| def content_tag tag, &block | |
| "<#{ tag.to_s }>#{ block.call }</#{ tag.to_s}>" | |
| end |
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 translate string | |
| string.gsub( /((?:(?:qu))*[^aeiou]*)(\w*)/, '\2\1') + 'ay' | |
| end |
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
| [1] pry(main)> puts "hello world!" | |
| hello world! | |
| => nil | |
| [2] pry(main)> class << self | |
| [2] pry(main)* def puts string | |
| [2] pry(main)* print "overloaded! " + string + "\n" | |
| [2] pry(main)* end | |
| [2] pry(main)* end | |
| => nil | |
| [3] pry(main)> puts "hello world!" |