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
| /** | |
| * Wait for a selector (CSS) that launches a pseudo-debugger. | |
| * | |
| * This builds on top of `waitForElementPresent()` that comes with Nightwatch | |
| * and works as a drop in replacement. The major difference is that if the | |
| * selector does not appear in the specified time it will act like a breakpoint | |
| * where the state is paused and a Continue button appears to proceed manually. | |
| * | |
| * @param selector The CSS entity to wait for - e.g. '#something' | |
| * @param [timeout] The maximum time we should wait. If this isn't provided 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
| next_xid = 1 | |
| active_xids = set() | |
| records = [] | |
| def new_transaction(): | |
| global next_xid | |
| next_xid += 1 | |
| active_xids.add(next_xid) | |
| return Transaction(next_xid) |
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
| package main | |
| import ( | |
| "bufio" | |
| "fmt" | |
| "net" | |
| ) | |
| ``` | |
| This is helper method |
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
| package main | |
| import ( | |
| "bufio" | |
| "fmt" | |
| "net" | |
| ) | |
| func check(err error, message string) { | |
| if err != nil { |
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
| import sys | |
| import ply.yacc as yacc | |
| import ply.lex as lex | |
| tokens = ( | |
| 'INCREMENT', | |
| 'DECREMENT', | |
| 'SHIFT_LEFT', | |
| 'SHIFT_RIGHT', | |
| 'OUTPUT', |
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
| func main() { | |
| str := "abc foo:bar def baz:qux ghi" | |
| re := regexp.MustCompile("([a-z]+):([a-z]+)") | |
| result := ReplaceAllStringSubmatchFunc(re, str, func(groups []string) string { | |
| return groups[1] + "." + groups[2] | |
| }) | |
| fmt.Printf("'%s'\n", result) | |
| } |
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
| import unittest | |
| import re | |
| class RomanToNumberConverter: | |
| # Validate that the input may even be processed. | |
| def validate(self, roman): | |
| if type(roman) is not str: | |
| raise ValueError("You must provide a string.") | |
| if roman == '': | |
| raise ValueError("An empty string was provided.") |
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. Modules are always lowercase, one word. | |
| // 2. They can be nested in any level of directories, but the name of the module | |
| // always reflects the file name (not including the path). | |
| // Private | |
| let counter = 0; | |
| function addition(a, b) { | |
| return a + b; | |
| } |
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
| import re | |
| def mapper(emit, text): | |
| words = re.split('[^\w]', text.lower()) | |
| for word in words: | |
| if word: | |
| emit(word, 1) | |
| def reducer(key, 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
| import pytest | |
| class Game: | |
| def __init__(self): | |
| self.frames = [[]] | |
| self.allow_bonus_roll = False | |
| @property | |
| def last_frame(self): | |
| return self.frames[-1] |