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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
import "@openzeppelin/contracts/utils/Strings.sol"; | |
// @title The pet adption contract. | |
// @author tonsh | |
contract Adoption { | |
// The total number of pets should not exceed 15 | |
uint8 constant TOTAL_PETS = 15; |
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" | |
"encoding/json" | |
"fmt" | |
"os" | |
) | |
type ( |
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
<?php | |
function count_test($num) { | |
$arr = range(0, $num); | |
$start = microtime(); | |
while($i < count($arr)) { | |
$i += 1; | |
continue; | |
} | |
$end = microtime(); | |
echo 'Count '.$num.': '.($end - $start).PHP_EOL; |
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
# coding=utf-8 | |
import math | |
def prime(n): | |
if n == 1: | |
return True | |
# 优化1: 2, 3, 5 特殊值比较,可节约约 3/4 地计算量 | |
if n % 2 == 0: |
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
var = 'outer' | |
def A(): | |
global var | |
var = 'inner' | |
print var | |
# inner | |
var = 'outer' | |
def 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
# coding=utf-8 | |
import logging | |
import random | |
import threading | |
import time | |
class Counter(object): | |
_count = 0 |
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
* Ctrl-a 光标移至行首 | |
* Ctrl-e 光标移至行尾 | |
* Ctrl-b 光标向左移动一个字符(backward) | |
* Ctrl-f 光标向右移动一个字符(forward) | |
* Ctrl-k 删除从光标开始至行尾地所有字符 | |
* Ctrl-u 删除从光标开始至行首的所有字符 | |
* Ctrl-d 删除光标所在地字符 | |
* Ctrl-h 删除光标左侧的一个字符 | |
* Ctrl-w 删除光标右侧的单词 |
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> | |
int main() { | |
int a = 1; | |
printf("%p\n", &a); // --> 0x7fff614d1a74 | |
a++; | |
printf("%p\n", &a); // --> 0x7fff614d1a74 | |
int b = a; | |
printf("%p\n", &b); // --> 0x7fff658c8a70 | |
return 0; |
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
# coding=utf-8 | |
import datetime | |
import unittest | |
def strptime(date_str): | |
""" 不确定 date_str 格式的字符串与日期转换 """ | |
if isinstance(date_str, datetime.datetime): | |
return date_str |
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
<?php | |
/** | |
* @author tonsh | |
* | |
* A set of common used functions | |
*/ | |
/** | |
* 将数字字符串每3位添加一个逗号(从右向左) |
NewerOlder