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 <iostream> | |
#include "type_checker.h" | |
typedef struct payload {} payload; | |
typedef struct payload2 { | |
static std::string id; | |
} payload2; | |
std::string payload2::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
import importlib | |
import pkgutil | |
def import_submodules(package, recursive=True): | |
""" Import all submodules of a module, recursively, including subpackages | |
:param recursive: bool | |
:param package: package (name or actual module) | |
:type package: str | module |
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
window.globalVar = 0; | |
function eventHandler() { // handler | |
if (window.globalVar == 0) { | |
setTimeout(function() { // inside callback | |
window.globalVar = window.globalVar + 1; | |
}); | |
} | |
} | |
// Intuitively window.globalVar won't exceed 1 no matter how many times the eventHandler is triggered | |
// But consider the case: the eventHandler is attached to click event and two consecutive clicks happen so fast that |
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 \2... can refer to matched subgroup and be used in regex | |
// $1 $2... can refer to matched subgroup and be used in newString | |
// | |
"abba".replace(/(a)(b)\2\1/g,"$2$2$1$1$1") // =="bbaaa" | |
// What if I want to insert "$1" literally in newString | |
// $$ can be used | |
"abba".replace(/(a)(b)\2\1/g,"$$1$2$1") // =="$1ba" |
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
comb lst = [0..(length lst-1)] >>= \i -> drop (i+1) lst >>= \j -> return (lst !! i, j) |
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 ( | |
"fmt" | |
) | |
type Fetcher interface { | |
// Fetch returns the body of URL and | |
// a slice of URLs found on that page. | |
Fetch(url string) (body string, urls []string, err error) |