This file contains 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
# ref: https://apt.llvm.org/ | |
# 8 | |
deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main | |
deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main | |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add - | |
# LLVM | |
apt-get install libllvm-8-ocaml-dev libllvm8 llvm-8 llvm-8-dev llvm-8-doc llvm-8-examples llvm-8-runtime | |
# Clang and co | |
apt-get install clang-8 clang-tools-8 clang-8-doc libclang-common-8-dev libclang-8-dev libclang1-8 clang-format-8 python-clang-8 |
This file contains 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 <codecvt> | |
#include <locale> | |
#include <iostream> | |
#include <string> | |
int main() | |
{ | |
std::u32string input = U"这是中文"; | |
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> converter; |
This file contains 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 Sample: | |
def __init__(self): | |
pass | |
def __enter__(self): | |
return self | |
def __exit__(self, type, value, trace): | |
# 如果语句体的退出是由异常导致的,并且来自 __exit__() 方法的返回值为假,则该异常会被重新引发。 | |
# 如果返回值为真,则该异常会被抑制,并会继续执行 with 语句之后的语句。 |
This file contains 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
pragma solidity ^0.5.0; | |
// see https://solidity.readthedocs.io/en/v0.5.9/control-structures.html#error-handling-assert-require-revert-and-exceptions | |
// When exceptions happen in a sub-call, they “bubble up” (i.e. exceptions are rethrown) automatically. | |
// Exceptions to this rule are send and the low-level functions call, delegatecall and staticcall – | |
// those return false as their first return value in case of an exception instead of “bubbling up”. | |
contract Caller { | |
constructor() public {} | |
This file contains 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
from abc import ABC, ABCMeta, abstractmethod | |
class Reader(ABC): | |
@abstractmethod | |
def read(self): ... | |
class Writer(metaclass=ABCMeta): | |
@abstractmethod |
This file contains 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 requests | |
import json | |
from httmock import HTTMock, response | |
def get_mock(*args, **kwarg): | |
content = json.dumps({"mock": "test"}) | |
return response(status_code=200, content=content) | |
This file contains 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
> db.test.remove({}) | |
WriteResult({ "nRemoved" : 3 }) | |
> db.test.insert({data:[1,2,3,1]}) | |
WriteResult({ "nInserted" : 1 }) | |
> db.test.insert({data:[2,3,4,5]}) | |
WriteResult({ "nInserted" : 1 }) | |
> db.test.insert({data:[1,2,3,1]}) | |
WriteResult({ "nInserted" : 1 }) | |
> db.test.insert({data:[1,2,3,1]}) | |
WriteResult({ "nInserted" : 1 }) |
This file contains 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" | |
"log" | |
"github.com/jinzhu/gorm" | |
_ "github.com/jinzhu/gorm/dialects/mysql" | |
) |
This file contains 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" | |
"log" | |
"time" | |
"github.com/jinzhu/gorm" | |
_ "github.com/jinzhu/gorm/dialects/mysql" | |
) |
This file contains 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" | |
"log" | |
"github.com/jinzhu/gorm" | |
_ "github.com/jinzhu/gorm/dialects/mysql" | |
) |