自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(116)
  • 资源 (6)
  • 收藏
  • 关注

原创 Redis lua usage

lua usagebasic command127.0.0.1:6379> EVAL "return redis.call('set', KEYS[1], ARGV[1])" 1 name zhangsan127.0.0.1:6379> EVAL "return redis.call('get', KEYS[1])" 1 namehash to memory127.0.0.1:6379> SCRIPT LOAD "return 'hello world'""5332031c

2022-02-23 07:19:31 407

原创 unittest source code learning

Structure#mermaid-svg-g3PbzysQX9n4xNTU .label{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);fill:#333;color:#333}#mermaid-svg-g3PbzysQX9n4xNTU .label text{fill:#333}#mermaid-svg-g3PbzysQX9n4xNTU .node rect,#mermaid-svg-

2021-06-09 10:20:03 306 4

原创 第二个MacBook,继续加油!

2020-10-10 11:31:56 174

原创 leetcode 122. Best Time to Buy and Sell Stock II

QuestionSay you have an array prices for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multip

2020-10-10 09:02:45 122

原创 leetcode 463. Island Perimeter

class Solution: def islandPerimeter(self, grid: List[List[int]]) -> int: """ grid = [[0,1,0,0], [1,1,1,0], [0,1,0,0], [1,1,0,0]] """ ...

2020-09-02 09:01:42 91

原创 自动为 Gatsby网站中的 Markdown 页面添加 sidebar

我想在Gatsby网站上创建Markdown页面时自动添加侧边栏。有一个 starter “ gatsby-gitbook-starter” 可以支持markdown文件的侧边栏,但仅支持1级。 我希望能够支持更多级别。

2020-08-18 17:51:31 358

原创 binary search - leetcode 33. Search in Rotated Sorted Array

1. questionSuppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).You are given a target value to search. If found in the array return its index, otherwise ret

2020-08-12 09:43:38 121

原创 quick sort

"""step 1 : maintain the following structurea[l] ...... ,,,,,, < a[l] > a[l] j istep 2: in the end, swap(l, j), return j. .....a[l] ,,,,,, < a[l] > a[l] j iFor examp

2020-07-15 08:42:13 118

原创 Python slice notation [:] - leetcode 189. Rotate Array

1. a[start:stop:step]q = "12345"w = q[0:2:1] # [0, 2)print(f"w: {w}")# w: 12w = q[::-1] # if step is negative, reverse traverseprint(f"w's type: {type(w)} w: {w}")# w's type: <class 'str'> w: 54321w = q[::-2]print(f"w: {w}") # w: 5312.

2020-06-29 15:11:39 123

原创 python 模块导入注意事项

入口文件不能使用相对导入。import .module1if __name__ == '__main__': print("hello")ImportError: attempted relative import with no known parent package相对导入不能超过顶层包。app||----module1| |---f1.py||----module2| |---f2.py||----main.py# f2.p.

2020-06-19 13:38:07 181

原创 slide window & +Counter() : leetcode 438. Find All Anagrams in a String

def findAnagrams_leetcode(self, s: str, p: str) -> List[int]: if len(s) < len(p): return [] p_chars = Counter(p) i = 0 j = len(p) window = Counter(s[i:j]) results = [] while j &...

2020-06-12 15:21:29 161

原创 subsets : zero left padding : leetcode 78

leetcode 78求解序列的所有子集。例如: [1, 2, 3].所有子集为:[ [ ], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3] ]其中一种解题思路为:使用2进制来表示,组合中是否包含某个元素。例如 001–> [3], 101–>[1, 3], 111–>[1, 2, 3]因此只有列出 [0, 2n) 的2进制表示,就可以求出所有的子集。求解2进制表示时,有一个“zero left padd

2020-06-02 07:37:11 102

原创 regular expression examples

import rea = "java|Python|c0123tttyyyuu9"res = re.search("java\|Python\|c([0-9]+)tttyyyuu9", a)print(res.group(0)) # whole stringprint(res.groups()) # matched string in ()print(res.group(1)) # matched string in ()print(res.span(1)) # span of group 1

2020-05-29 10:00:55 109

原创 backtrace&usage of slice notation[:] - leetcode 77. Combinations

def combine(self, n: int, k: int) -> List[List[int]]: """ Input: n = 4, k = 2 Output: [ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ] :param n:...

2020-05-26 09:07:52 153 1

原创 build tree & sum path (usage of list[0]) - 404. Sum of Left Leaves

from collections import dequeclass TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = rightclass Solution: def printTreeCore(self, root, preorder=True): if not

2020-05-22 06:37:11 135 2

原创 算法-计算1的个数及python sort函数的多层排序

leetcode: 1356.Sort Integers by The Number of 1 Bits1. 计算数字中bit1的个数在这里,计算1 bit 的个数使用的是 减1再 bit and的方式。例如 9的二进制表示为 1001:(1)减1 后为 1000, 1001&1000 = 1000.(2)1000 减1 后为 0111, 1000&...

2020-04-07 07:37:11 249

原创 算法-动态规划3

根据在算法-动态规划2里提到的思路,让我们来解决一个组合问题 :leetcode 第77题。0 问题描述给定2个整数n,k,求出从[1,…,n]中取k个数字的所有组合。例如 n=4, k=2就是从[1,2,3,4]中取2个数字的所有组合。结果为:[[1, 2], [1, 3], [2, 3], [1, 4], [2, 4], [3, 4]]1 递归解法(1)假设组合中不包含 第n个...

2020-04-03 11:57:04 124

原创 算法-动态规划2

记得5年前写过一篇关于动态规划的博客。最近重新学习基本算法,对动态规划有了更深入的体会。感谢慕课网上《玩转算法面试-- Leetcode真题分门别类讲解》这门课程的老师liuyubobobo,这门课真的不错。对于“背包问题”,现在可以按照自己的思路写出来代码了,虽然运行一下发现有问题,经过修改调试,最终可以完成。这样的过程,我认为比记住一些代码,然后一遍把代码写对,是要好很多了。要把动态规划的...

2020-04-02 08:52:37 123

原创 design pattern

1 adapterclass Cat: def __init__(self): self.name = "cat" def mom(self): print("mom!")class Dog: def __init__(self): self.name = "dog" def bark(self): ...

2020-02-23 09:00:11 103

原创 sort & search algorithm

def quick_sort(array): if len(array) < 2: return array else: pivot_index = 0 pivot = array[pivot_index] less_part = [i for i in array[pivot_index+1:] if i &...

2020-02-17 17:49:16 108

原创 parameter passing

print("""There is only one type of parameter passing in Python, which is object reference passing.In the function body, mutable and immutable objects have different behaviours.""")def fl(l): ...

2020-02-10 12:36:43 197

原创 GIL & coroutine & performance

GILone byte code instruction is thread safe.The following code has 3 byte code instructions, so it’s not thread safe.import disdef incr_list(l): l[0] += 1if __name__ == '__main__': ...

2020-02-09 18:51:42 74

原创 exception

‘docs.python.org’ about ‘exception’def exception_example(): a = 0 try: a = 1/0 except Exception as e: print(e) else: a = 1 finally: print(a)cl...

2020-02-09 08:01:26 258

原创 unit test & mock

external_module.pydef multiply(x, y): return x*y+1main.pyimport unittestfrom unittest import mockfrom unittest.mock import patch#### pay attention to the way we import 'multiply'### in t...

2020-02-08 13:11:16 113

原创 shallow copy & deep copy

import copydef shallow_n_deep_copy(): a = {'a': [1, 2, 3]} b = a.copy() print('a:', a, 'b:', b) a['a'].append(4) print('a:', a, 'b:', b) c = copy.deepcopy(a) a['a'].appe...

2020-02-04 13:41:22 90

原创 collections

from collections import namedtuplefrom collections import dequefrom collections import OrderedDictdef nametuple_example(): Person = namedtuple("hahaha", "name, age, gender") alice = Perso...

2020-02-04 06:34:56 99

原创 python learning

https://www.cnblogs.com/vipchenwei/p/7239953.html

2019-09-22 11:12:21 135

原创 gdb debug summary

gdb attach programgdb -p $(pidof rcpd)gdb use symbolgdb att 2271 -s cips_app.symgdb create struct params(gdb) call malloc(sizeof(dps_l1xc_info_t))(gdb) p *(dps_l1xc_info_t *)$1$3 = {sr...

2019-09-19 16:12:00 130

原创 my docker tutorial

add mirrorfind exist imagefind an image in dock hub.https://hub.docker.com/r/fnndsc/ubuntu-python3/dockerfileget&run imagedocker pull fnndsc/ubuntu-python3docker run -itd --name ubu...

2019-09-01 12:51:13 157

原创 jenkins

use this plugin to store the parameters of your last build.https://wiki.jenkins.io/display/JENKINS/Persistent+Parameter+Plugin

2019-08-22 22:04:43 110

原创 mini program for suna 接口文档

微信公众号接口:http://18.220.98.204/wx_flask

2019-08-06 20:41:58 212 5

原创 报文数据的txt文件 转换成wireshark可以识别的k12文件

implement a python app which can covert hex raw packet data to k12 file.Wireshark can open the k12 file and parse the packet content.#########1.txt###########09002b00 00050020 8fca980d 81000...

2019-07-17 13:40:02 1499

原创 vscode related

If you want to find the older version of VScode, you can click the "updates" tag in its official web.like:https://code.visualstudio.com/updates/v1_27vscode installhttps://blog.csdn.net/bat...

2019-06-13 15:35:23 455

原创 axure design

axure designhttps://www.axureshop.com/https://www.iconfont.cn/

2019-06-06 14:51:33 156

原创 适配器模式(c语言实现)

在这里用c实现了类似于java的接口。#include <stdio.h>#include <stdlib.h>#include <cassert>typedef struct _Duck{ void (*fly)(struct _Duck* b); void (*quack)(struct _Duck* b);}...

2019-06-05 16:09:18 650

原创 command模式(c语言实现)

2014年写过一篇实现,重读一遍《设计模式》,参考网上的一篇文章,又重新写了一遍。我体会到,c++的类在c语言里面用struct代替之后,c++的this指针可以通过传入struct本身的指针来完成。而在command模式里的Command实际上既包含了对象(pData),又包含了命令接口(exe)。#include <stdio.h>#include <...

2019-06-01 14:22:44 1460

原创 yqzj微信公众号&小程序开发

《微信开发入门》文档中 list = [token, timestamp, nonce] list.sort() sha1 = hashlib.sha1() map(sha1.update, list)//此处错误 hashcode = sha1.hexdigest()应...

2019-01-23 21:15:18 725

原创 多台上网设备出现上网卡问题

更换路由器后还是解决不了,最后通过将MTU的默认设置1480修改为1024就解决了。估计是和报文分片导致重传有关。

2018-08-05 11:18:38 708

原创 a bug related with extern

in file  a.cunsigned int my_length = 0x12345678;**********************************************int file main.cextern unsigned short my_length;int main(){printf("0x%x\n", my_length);

2016-11-28 14:38:59 229

原创 struct union and endian

#pragma pack(push, 1)typedef union { struct {# ifdef CS_BIG_ENDIAN cs_uint16 rsrvd1 :4; cs_uint16 output_src_sel :3; cs_uint16 invert_output :1; cs_uint16 invert_input

2016-09-27 14:12:05 413

flappy_bird_pygame.zip

"flappy bird" Python code with pygame framework. Multi-scene structure.

2020-06-29

python-3.8.1-docs-html.zip

document for python3.8 HTML format You can use it to learn basic concept, api, debug, install and many topics related with python 3.8 enjoy it. ^_^

2020-02-09

axure3382.7z

原型图设计的工具。can be used for UI design and web design.

2019-06-06

哈佛公开课(构建动态网站)源码及课件

哈佛公开课中:构建动态网站中用到的源码及课件。

2015-05-17

联想G455安装xp-mac双系统

描述了自己成功在联想G455安装xp-mac双系统的步骤。

2012-03-03

微型计算机原理与应用

微型计算机原理与应用,是很好的学习计算机原理及汇编的PPT.

2010-02-23

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除