自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

BrownWong的专栏

数据科学爱好者。Github: https://github.com/wangjiang0624

  • 博客(362)
  • 资源 (8)
  • 收藏
  • 关注

原创 英伟达Jetson AGX Xavier装torch

系统为arm64架构,区别于一般的x86,很多软件安装起来较为繁琐。下面是一个dockerfile,安装transformers:FROM nvcr.io/nvidia/l4t-pytorch:r32.6.1-pth1.9-py3RUN rm /usr/bin/python && ln -s /usr/bin/python3.6 /usr/bin/python && ln -s /usr/bin/pip3 /usr/bin/pipRUN apt-get update

2021-12-24 16:19:43 630

转载 Github代理

git config --global url."https://hub.fastgit.org/".insteadOf "https://github.com/"git config protocol.https.allow always

2021-12-21 15:53:50 631

原创 内网IP地址段

tcp/ip协议中,专门保留了三个IP地址区域作为私有地址,其地址范围如下:10.0.0.0/8:10.0.0.0~10.255.255.255172.16.0.0/12:172.16.0.0~172.31.255.255192.168.0.0/16:192.168.0.0~192.168.255.255

2020-11-02 11:17:56 2346

原创 传密码方式ssh登录

sshpass -p your_password ssh user@hostname

2020-10-28 14:26:14 773

原创 常用k8s命令kubectl

查看某个namespace下的所有服务kubectl get svc --namespace default查看某个namespace下的所有podkubectl get pod --namespace default查看某个pod的详情kubectl describe pod <pod-name>查看某个pod的logkubectl logs -f <pod-name>...

2020-10-21 13:37:28 450

原创 使用代理brew安装

http_proxy=http://127.0.0.1:1087 https_proxy=http://127.0.0.1:1087 brew install <pkg>

2020-10-21 10:26:36 878

原创 查看CPU数、核数

查看逻辑CPU核数cat /proc/cpuinfo| grep "processor"| wc -l查看CPU信息(型号)cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -cRef:linux查看cpu核数和内存指令

2020-09-10 12:11:26 217

原创 测试tensorflow是否检测到GPU

测试tensorflow是否检测到GPUimport tensorflow as tftf.test.is_gpu_available()tf.test.gpu_device_name()

2020-09-08 18:10:37 445

原创 (LeetCode)字符串

1. 实现 Trie (前缀树)208. implement-trie-prefix-treeclass Trie(object): def __init__(self): """ Initialize your data structure here. 用dict嵌套构造字典树 如果一个节点包含空的子节点, 说明其可以作为终止符 """ self.tree = {} def ins

2020-06-21 16:44:20 191

原创 (LeetCode)排序

1. 排序链表148. sort-list# Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next = Noneclass Solution(object): def sortList(self, head): """ :type head: Lis

2020-06-21 16:41:13 217

原创 (LeetCode)位运算

1. 汉明距离461. hamming-distanceclass Solution(object): def hammingDistance(self, x, y): """ :type x: int :type y: int :rtype: int 思路 先异或, 再使用bin函数统计1的个数 bin(xor).count('1') 先

2020-06-21 16:36:02 264

原创 (LeetCode)全排列, 回溯法

1. 子集78. subsetsclass Solution(object): def subsets(self, nums): """ :type nums: List[int] :rtype: List[List[int]] 方法 回溯法, 循环内递归, 即DFS https://pic.leetcode-cn.com/a4f4acf7177b6a1131b1ef5da97c1

2020-06-21 16:31:37 321

原创 (LeetCode)栈

1. 最小栈155. min-stackclass MinStack(object): def __init__(self): """ initialize your data structure here. 分析 单纯地用数组实现一个栈很容易,但要实现常数时间检索到最小值就麻烦了; """ self.data = [] self.mins = [] s

2020-06-21 16:25:37 183

原创 (LeetCode)双指针

1. 移动零283. move-zeroesclass Solution(object): def moveZeroes(self, nums): """ :type nums: List[int] :rtype: None Do not return anything, modify nums in-place instead. 聪明解法 1. 两个指针,i指针迭代,j指针表示(从左往右)非零元素个数的

2020-06-21 16:17:09 410

原创 (LeetCode)哈希表

1. 两数之和1. two-sumclass Solution(object): def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] 笨办法 暴力求解 聪明办法 利用dict存储 "

2020-06-21 16:05:25 133

原创 (LeetCode)动态规划

1. 买卖股票的最佳时机121. best-time-to-buy-and-sell-stockclass Solution(object): def maxProfit(self, prices): """ :type prices: List[int] :rtype: int 笨办法 暴力求解,两重循环 聪明法 动态规划,前n天最大利润=max

2020-06-21 16:01:20 252

原创 (LeetCode)数组

1. 多数元素169. majority-elementclass Solution(object): def majorityElement(self, nums): """ :type nums: List[int] :rtype: int 1. Counter return Counter(nums).most_common(1)[0][0] 2. 统计频次,取最大 **

2020-06-21 15:50:30 149

原创 (LeetCode)链表

1. 反转链表206. reverse-linked-list# Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next = Noneclass Solution(object): def reverseList(self, head): """ :t

2020-06-21 14:41:59 142

原创 (LeetCode)二叉树

1. 合并二叉树617. merge-two-binary-trees# Definition for a binary tree node.# class TreeNode(object):# def __init__(self, x):# self.val = x# self.left = None# self.right = Noneclass Solution(object): def mergeTrees(sel

2020-06-21 14:27:28 2715 3

原创 设置全局pip源

我们都知道使用pip的时候声明-i选项可以指定pip源,但是如果要全局设置呢?输入以下命令即可:pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/...

2020-02-29 19:24:40 3277

原创 一个标准的setup.py和requirements.txt

setup.pyimport osfrom setuptools import setup, find_packagesdef _process_requirements(): packages = open('requirements.txt').read().strip().split('\n') requires = [] for pkg in packa...

2020-02-24 16:01:23 2140

原创 gevent实现异步

test_gevent.pyimport geventimport requestsimport timefrom gevent import monkeymonkey.patch_all()def f(url, i): print('{} GET: {}'.format(i, url)) resp = requests.get(url) time.slee...

2019-12-26 19:50:48 452

原创 Python setuptools自动安装git私有库

install_requires=[ 'private_package_name==1.1', ], dependency_links=[ 'git+ssh://[email protected]/username/private_repo.git#egg=private_package_name-1.1', ]注意:egg名后面必须有版本号,否则可能找不到包,...

2019-12-26 19:47:38 325

原创 服务多分片下的文件log问题

1. 常见错误当你的服务开了多个分片,并且这多个分片打同一个log文件时,经常会出一些问题,比如:log打串,分片之间产生的请求log相互交叉,阅读起来极为困难;甚至会出现行内串掉的情况,比如一个分片一行还没打完,另外一个分片就将内容插入到这一行了;2. rotate带来的错误如果你的log文件使用了rotate,并且所有分片都有rotate的逻辑,那更糟糕,还可能报错,比如下面的错...

2019-11-09 14:11:45 179

原创 docker的stack和service

1. 关系关系如下:stack --&amp;gt; service --&amp;gt; task(container)2. 常用命令用compose部署或更新:docker stack deploy -c docker-compose.yml -c docker-compose.override.yml &amp;lt;stack_name&amp;gt;查看stack下的所有服务:docker st...

2018-10-24 21:48:49 5094

原创 python操作yaml

1. 安装PyYAMLpip install PyYAML2. 加载yaml文件直接使用yaml.load()函数demo.yml :kind: DeploymentapiVersion: apps/v1metadata: name: podinfo namespace: yaml-demospec: replicas: 1 selector: match...

2018-10-12 13:54:55 4053

原创 git修改分支

修改本地分支 git branch -m &amp;lt;old_branch&amp;gt; &amp;lt;new_branch&amp;gt;删除远程分支 git push origin :&amp;lt;old_branch&amp;gt;切换到本地新分支,将本地新分支推到远程 git checkout &amp;lt;new_branch&amp;gt; git push --set-u

2018-09-09 11:59:22 3707

原创 删除swap文件vim不高亮显示

问题描述好几次删除了vim打开过的某个文件的swap文件,然后再打开此文件,颜色丢失了(文件不高亮显示)排查用vim打开此文件,输入:se ft?,查看当前文件编码。会发现filetype为空,标明此文件并没有被vim识别为正确的文件类型,因此不能相应高亮显示。解决方案用vim打开此文件,设置filetype: :set filetype=&amp;lt;filetype&amp;gt;。比...

2018-06-21 00:56:48 832 1

转载 各种开源协议比较

按照严格程度排序:GPL &gt; LGPL &gt; Apache &gt; BSD3 &gt; BSD2 = MIT 开源许可证GPL、BSD、MIT、Mozilla、Apache和LGPL的区别

2018-05-06 14:57:44 867

原创 python代码变成so

1. 使用cythonize函数新建如下目录结构:test/├── hello.py└── setup.py文件内容如下:hello.py :def hello(): print('hello!')setup.py :from distutils.core import setupfrom Cython.Build import cythoniz...

2018-05-01 23:41:52 5498

原创 python代码打包发布

1. distutils VS setuptoolspython打包(packaging)常用的两个工具:distutils和setuptools。distutils是标准打包工具,被包含在标准库中,可以用作简单的python发布。setuptools并不是python标准库的一部分,它的诞生是为了克服distutils的不足,是distutils的增强版。这里只介绍distutils的使用2

2018-05-01 22:40:13 6788 1

原创 docker离线安装

安装docker 1. 复制local_repo到本机 2. 更改本地yum源为locol_repo:创建/etc/etc/yum.repos.d/local.repo 3. yum clean all && yum makecache 4. yum install docker 5. 启动docker:systemctl start docker安装docker-compose 1.

2018-03-31 12:12:30 620

原创 concurrent.futures

1. 关于 future在很多语言的并发编程中,你经常可以看到 future 的身影。future 的引入实际上是一种设计思想,它描述了一个替代 result 的对象,future 中的 result 通常是一开始未知,随着计算完成而变得已知。在并发启动计算与获得最终计算结果之间存在一段空隙,future 在这个空隙间架了座桥。通常的处理这段空隙的方法是传递一个同步队列到每个worker,...

2018-03-23 00:04:54 681

原创 并行编程

1. 并发与并行的区别并发是多个任务抢占相同的CPU(不同时);并行系统同时运行多个任务在不同的CPU上;2. 并行编程内的交流两种:共享状态(信号量等)和消息传递。共享状态:多个并行任务共享一个变量消息传递:尽管内存使用率高,但消息传递杜绝了并行获取共享变量的情况3. 并行编程的问题死锁 deadlock死锁是多个进程等待某个条件释放它们的任务,但是这种条件永远不会发生。饥饿 star

2018-03-18 16:24:14 310

原创 python -m 参数

-m参数告诉python以模块的方式运行某个脚本。命令格式:python -m package.script执行此命令,python会自动先帮你引入包package,然后执行脚本script。Ref https://stackoverflow.com/questions/22241420/execution-of-python-code-with-m-option-or-not...

2018-03-16 00:13:09 993

原创 用sysbench对linux进行基准测试

sysbench提供了针对linux的基准测试能力,它支持测试CPU、内存、文件IO、信号量、线程等的能力,甚至包括mysql的基准测试。1. 基本指令sysbench [common-options] --test=name [test-options] command2. 测试文件IO负载使用以下命令创建测试文件sysbench --test=fileio --...

2018-03-06 23:52:09 2587

原创 CRF++之txt模型详解

例子解析下面是一个crfpp训练出来的txt模型样例:version: 100cost-factor: 1maxid: 2978536xsize: 1BEMOU00:%x[-3,0]U01:%x[-2,0]U02:%x[-1,0]U03:%x[0,0]U04:%x[1,0]U05:%x[2,0]U06:%x[3,0]U07:%x[-3,0]/%x[-2

2018-01-30 21:14:25 805 2

原创 gensim训练词向量word2vec

1. gensim的word2vec简单使用Code Example:from gensim.models import word2vecsents = ['I am a good student'.split(),'Good good study day day up'.split()]model = word2vec.Word2Vec(sents, size=100,

2018-01-18 18:42:38 5512 2

原创 禁止keras预分配GPU内存

keras使用theano或者tensorflow作为后端时,都会预分配GPU内存,即先占满当前GPU的所有内存,而你使用nvidia-smi显示的就是预分配的GPU内存,往往是满的。如果你不想要程序预分配内存,即需要多少内存就动态分配多少内存时,你就需要如下设置:import tensorflow as tfimport keras.backend.tensorflow_backend as K

2018-01-16 11:20:08 1346

原创 vim配置

使用utf-8打开文件在.vimrc文件中添加set fileencodings=utf-8Ref https://stackoverflow.com/questions/5166652/how-to-view-utf-8-characters-in-vim-or-gvim

2018-01-15 12:02:12 222

邻接表存储的图的DFS,BFS遍历

邻接表存储的图的DFS,BFS遍历。文档描述: http://blog.csdn.net/qq_16912257/article/details/45848935

2017-04-06

AjaxServletDemo增强版

AjaxServletDemo增强版.

2015-09-19

AjaxServletDemo

利用Ajax获取控件内容发送给Servlet。然后servlet将相应值再通过ajax返回给浏览器刷新界面

2015-09-19

My First Hibernate APP

我的第一个Hibernate应用,保存数据到数据库。

2015-09-04

ImageBrowser

监听左右滑动事件实现一个图片浏览器。性能优于ViewPager,但并不如ViewPager美观。

2015-08-26

ShowImage_android小程序

一个很简单的Demo,实现从SD卡读取一张图片,并把它显示在APP中。

2015-07-23

数据结构代码

包含:顺序表,链表,栈,队列,回文,二叉树,图,二叉排序树源码,欢迎下载!

2015-05-31

java语言程序设计复习题和编程练习题答案.zip

本压缩包包含java语言程序设计这本书中2-20章复习题答案以及偶数编程题答案,欢迎下载。

2015-01-18

空空如也

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

TA关注的人

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