04 2018 档案

摘要:1. 查找节点 方法1. document.querySelector, document.querySelectorAll 方法2. document.getElementById, document.getElementsByClassName 2. 更新节点 前提是拿到要修改的DOM 方法1. 阅读全文
posted @ 2018-04-30 22:02 Rocin 阅读(158) 评论(0) 推荐(0)
摘要:分为10位数字(ten digit)和13位(thirteen digit)数字 1. Unix, Python为10 2. JavaScript为13位 10位的单位是秒,13位的是毫秒,一般开发默认单位为秒 阅读全文
posted @ 2018-04-29 23:19 Rocin 阅读(11904) 评论(0) 推荐(0)
摘要:问题: map parseInt 因为map()接收三个参数,parseInt()接收两个参数,所以map的第三个参数被parseInt忽略了。 现在来分析下程序,假如现在执行arr的第一个元素,即'1';对应到map参数可知,此时传入map的第一个参数即为被传递的元素'1';第二个参数即为其索引0 阅读全文
posted @ 2018-04-29 20:01 Rocin 阅读(570) 评论(0) 推荐(0)
摘要:同步和异步关注的是消息通信机制,阻塞/非阻塞是程序在等待调用结果(消息,返回值)时的状态 阅读全文
posted @ 2018-04-25 20:12 Rocin 阅读(696) 评论(0) 推荐(0)
摘要:留坑 参考: 1. https://en.wikipedia.org/wiki/Coroutine 2. https://zh.wikipedia.org/wiki/%E5%8D%8F%E7%A8%8B 3. http://www.cnblogs.com/xybaby/p/6323358.html 阅读全文
posted @ 2018-04-25 09:57 Rocin 阅读(421) 评论(0) 推荐(0)
摘要:1. 参考: 1. https://en.wikipedia.org/wiki/Callback_(computer_programming) 2. https://developer.mozilla.org/en US/docs/Glossary/Callback_function 3. http 阅读全文
posted @ 2018-04-24 14:16 Rocin 阅读(1553) 评论(0) 推荐(0)
摘要:多进程(multiprocessing) 参考: 1. https://docs.python.org/3.6/library/multiprocessing.html 1. 多进程概念 multiprocessing is a package that supports spawning proc 阅读全文
posted @ 2018-04-23 22:07 Rocin 阅读(1009) 评论(0) 推荐(0)
摘要:1. 缓冲区(此处用阻塞队列充当),解决消费者和生产者强耦合问题。(生产者和消费者不直接通信) 2. 通过平衡生产者线程和消费者线程,来提高程序整体处理数据速度。 3. 在并发编程中该模式能解决大多数并发问题。 4. 例子1. 生产者生产一次,每个消费者消费一次 5. 例子2. 生产者和消费者动态生 阅读全文
posted @ 2018-04-23 21:45 Rocin 阅读(541) 评论(0) 推荐(0)
摘要:参考: 1. https://stackoverflow.com/questions/49859287/what is the need of threading lock when cpython has gil 2. https://stackoverflow.com/questions/400 阅读全文
posted @ 2018-04-22 12:56 Rocin 阅读(742) 评论(0) 推荐(0)
摘要:1. 问题:很好奇为什么叫Join? 参考: 1. https://blog.csdn.net/frankarmstrong/article/details/55504161 2. https://stackoverflow.com/questions/15956231/what does this 阅读全文
posted @ 2018-04-22 11:02 Rocin 阅读(682) 评论(0) 推荐(0)
摘要:在c.py中 阅读全文
posted @ 2018-04-22 09:29 Rocin 阅读(6521) 评论(0) 推荐(0)
摘要:``` 1. shift + f10 2. cd oobe 3. Msoobe ``` 阅读全文
posted @ 2018-04-22 00:59 Rocin 阅读(543) 评论(0) 推荐(1)
摘要:```python import numpy as np import matplotlib.pyplot as plt #用最小距离法(minimum distance algorithm)去检测目标点属于哪一个set #the distance of point x and point y def dist(x,y): return np.sqrt(np.sum((x - y) ** 2... 阅读全文
posted @ 2018-04-22 00:54 Rocin 阅读(262) 评论(0) 推荐(0)
摘要:图片来自网上资料 阅读全文
posted @ 2018-04-22 00:51 Rocin 阅读(222) 评论(0) 推荐(0)
摘要:``` 1. 打开/etc/mysql/debian.cnf文件,在这个文件中有系统默认给我们分配的用户名和密码,通过这个密码就可以直接对MySQL进行操作了。 2. 以debian-sys-maint为用户名登录,密码就是debian.cnf里那个。使用mysql -u debian-sys-maint -p 进行登录。 3. 进入mysql之后修改MySQL的密码,具体的操作如下用命令:set... 阅读全文
posted @ 2018-04-22 00:48 Rocin 阅读(2697) 评论(0) 推荐(0)
摘要:``` 1. 在Windows上,安装时请选择UTF-8编码,以便正确地处理中文。 在Mac或Linux上,需要编辑MySQL的配置文件,把数据库默认的编码全部改为UTF-8。MySQL的配置文件默认存放在/etc/my.cnf或者/etc/mysql/my.cnf: [client] default-character-set = utf8 [mysqld] default-storage-e... 阅读全文
posted @ 2018-04-22 00:47 Rocin 阅读(1734) 评论(0) 推荐(0)
摘要:http://bindog.github.io/blog/2015/03/10/synchronization in multiplayer networked game lockstep/ 游戏的暴击几率是“假”的 阅读全文
posted @ 2018-04-22 00:43 Rocin 阅读(232) 评论(0) 推荐(0)
摘要:https://en.wikipedia.org/wiki/Scheduling_(computing) 在wiki的下面可以找到 阅读全文
posted @ 2018-04-22 00:33 Rocin 阅读(282) 评论(0) 推荐(0)
摘要:1. https://blog.csdn.net/wuyuegb2312/article/details/16359821 2. https://www.youtube.com/watch?v=YQ3Fep69CYM 阅读全文
posted @ 2018-04-22 00:31 Rocin 阅读(1909) 评论(0) 推荐(0)
摘要:42.zip A 42 kb zip file that contains 4.5 Petabytes of uncompressed data. 阅读全文
posted @ 2018-04-22 00:27 Rocin 阅读(236) 评论(0) 推荐(0)
摘要:1. Type %0|%0 2. Save the file to your desktop as anything.bat 阅读全文
posted @ 2018-04-22 00:25 Rocin 阅读(302) 评论(0) 推荐(0)
摘要:1. 显示port 22 refused, 输入 apt get install openssh server就可以解决 2. 关闭ssh服务 service ssh stop 3. 可以用 service status all查看 阅读全文
posted @ 2018-04-22 00:22 Rocin 阅读(159) 评论(0) 推荐(0)
摘要:1. recovery mode E 2. ro rw 3. plus init=/bin/bash 4. passwd root 阅读全文
posted @ 2018-04-22 00:21 Rocin 阅读(423) 评论(0) 推荐(0)
摘要:![](https://images2018.cnblogs.com/blog/1310818/201804/1310818-20180422001535649-661899025.jpg) 阅读全文
posted @ 2018-04-22 00:16 Rocin 阅读(169) 评论(0) 推荐(0)
摘要:1. lsof i : 2. nmap 127.0.0.1 3. sudo netstat tunlp (不加sudo看不见PID) 4. gufw 参考 https://askubuntu.com/questions/9368/how can i see what ports are open o 阅读全文
posted @ 2018-04-22 00:13 Rocin 阅读(567) 评论(0) 推荐(0)
摘要:1. ps p $$ 一个名为 "$$" (这是shell的特殊参数),表示当前你正在运行的 shell 实例的 PID 2. echo $0 3. echo $SHELL 永远points to 默认的shell 4. 找出当前 Shell 的版本 1. bash version 2. zsh v 阅读全文
posted @ 2018-04-21 23:50 Rocin 阅读(339) 评论(0) 推荐(0)
摘要:1. ls lsh 2. du sh du == disk usage (磁盘使用量,占用的磁盘空间) 一个文件占用的磁盘空间和一个文件的大小是两码事情。占用空间取决于文件系统的块(block)的大小,linux一般默认是4k(4096) ,因此,一个大小为1个字节的文件,最小也要占用4k,如果你创 阅读全文
posted @ 2018-04-21 23:46 Rocin 阅读(469) 评论(0) 推荐(0)
摘要:1. Shebang这个符号通常在Unix系统的脚本中第一行开头中写到,它指明了执行这个脚本文件的解释程序。 阅读全文
posted @ 2018-04-21 23:43 Rocin 阅读(187) 评论(0) 推荐(0)
摘要:1. lscpu ,cat /proc/cpuinfo 用于查询CPU信息 2. cat /proc/meminfo, free m 内存信息 3. lsblk 硬盘与分区分布 4. lshw 显示硬件信息表 这个命令应用普遍,它可通过个人需求而列出多种不同的硬件参数:CPU、内存、硬盘、USB控制 阅读全文
posted @ 2018-04-21 23:38 Rocin 阅读(242) 评论(0) 推荐(0)
摘要:1. ps aux 查看特定的进程 例如ps aux | grep apt 阅读全文
posted @ 2018-04-21 23:33 Rocin 阅读(144) 评论(0) 推荐(0)
摘要:1. gdebi -- 可以代替Ubuntu software安装软件 2. System monitor -- 监控流量 3. uget -- 下载软件 4. Okular -- pdf reader 5. Typora -- markdown editor 6. Anaconda 7. Pych 阅读全文
posted @ 2018-04-21 23:28 Rocin 阅读(1409) 评论(0) 推荐(0)
摘要:1. 上一页 ctrl + b 2. 下一页 空格 / ctrl + f 3. 上半页 ctrl + u 4. 下半页 ctrl + d 5. 上一行 k 6. 下一行 j 7. 向上查找 ?key 8. 向下查找 /key 9. 下一个匹配 n 10. 上一个匹配 N 11. 退出 q 阅读全文
posted @ 2018-04-21 23:20 Rocin 阅读(531) 评论(0) 推荐(0)
摘要:1. 可以通过解压后使用convmv来解决文件名乱码问题,通过iconv来解决文件内容的乱码问题 2. 用unar命令 阅读全文
posted @ 2018-04-21 23:19 Rocin 阅读(198) 评论(0) 推荐(0)
摘要:1. iwconfig 2. sudo ifconfig wlp4s0 down 3. sudo iwconfig wlp4s0 power off 4. sudo ifconfig wlp4s0 up 5. sudo service network manager restart wlp4s0为w 阅读全文
posted @ 2018-04-21 23:18 Rocin 阅读(3345) 评论(0) 推荐(0)
摘要:1. putty, 2. winscp(可下载文件) 3. SecureCRT 阅读全文
posted @ 2018-04-21 23:16 Rocin 阅读(545) 评论(0) 推荐(0)
摘要:ubuntu: service status all 例如可查看ssh, apache2等服务是否开启 阅读全文
posted @ 2018-04-21 23:15 Rocin 阅读(9884) 评论(0) 推荐(1)
摘要:第四部分第11章,接口:从协议到抽象基类(重点讲抽象基类) 1. 接口就是实现特定角色的方法集合。 2. 严格来说,协议是非正式的接口(只由文档约束),正式接口会施加限制(抽象基类对接口一致性的强制)。 3. 在Python中,“X类对象”、“X协议”、“X接口”都是一个意思。如“文件类对象”、“可 阅读全文
posted @ 2018-04-18 23:39 Rocin 阅读(906) 评论(0) 推荐(0)
摘要:1. 文件/文件夹处理 1.1 rm 1. 删除文件夹 1.2 mkdir 1. 创建多层文件夹 1.3 mkdir 1. 创建名为\的文件夹 2. 在Linux中不建议创建带有空格的文件名 1.4 cat 1. 带行数显示, /etc/issue为欢迎信息 1.5 tac 1. 倒转cat tac 阅读全文
posted @ 2018-04-18 15:32 Rocin 阅读(215) 评论(0) 推荐(0)
摘要:三. 文件系统中跳转 pwd Print name of current working directory cd Change directory ls List directory contents pwd — 打印出当前工作目录名 cd — 更改目录 ls — 列出目录内容 四. 探究操作系统 阅读全文
posted @ 2018-04-18 15:31 Rocin 阅读(190) 评论(0) 推荐(0)
摘要:1. zip函数生成一个由 元组构成的生成器 ,元组中的元素来自参数传入的各个可迭代对象。一旦有一个输入的可迭代对象耗尽,zip函数会立即停止生成值,而且不发出警告。使用zip_longest解决。 2. 使用for循环迭代元素不用处理索引变量,还能避免很多缺陷,需要一些特殊的使用函数来辅助。其中一 阅读全文
posted @ 2018-04-17 13:46 Rocin 阅读(235) 评论(0) 推荐(0)
摘要:例子1. python中实现hashable map函数是惰性的,和生成器表达式一样,创建一个生成器,按需产出结果,节省内存 另外: 例子2. 计算整数0~5累计异或的三种方式 2.1 for循环 2.2 reduce + lambda 2.3 reduce + operator(代替lambda) 阅读全文
posted @ 2018-04-17 13:18 Rocin 阅读(341) 评论(0) 推荐(0)
摘要:1. dir()查看类的方法和属性 查看slice类的方法和属性 2.help() 查看某个方法的文档 查看slice类中的indices方法 阅读全文
posted @ 2018-04-17 10:57 Rocin 阅读(13072) 评论(0) 推荐(1)
摘要:参考: 1. Fluent_Python P430 2. wiki 这里说的协议是什么?是让Python这种动态类型语言实现 多态 的方式。 1. 在面向对象编程中,协议是 非正式 的接口,是一组方法,但只是一种文档,语言不对施加特定的措施或者强制实现。 2. 虽然协议是非正式的, 在Python中 阅读全文
posted @ 2018-04-17 10:38 Rocin 阅读(2375) 评论(0) 推荐(0)
摘要:第四部分第10章,序列的修改、散列和切片 中文电子书P423 这一章接第1章、第9章,以第9章定义的Vector2d类为基础,定义表示多为向量的Vector类。这个类的行为与Python中标准的不可变扁平序列一样。Vector实例中的元素是浮点数,本章的Vector类将支持以下功能 1. 基本的序列 阅读全文
posted @ 2018-04-17 09:55 Rocin 阅读(157) 评论(0) 推荐(0)
摘要:第四部分第9章,Python风格的对象 这一章接第1章,说明常见的特殊方法实现。 本章包括以下话题: 1. 支持用于生成对象其它表示形式的内置函数(如repr()、bytes(),等等) 2. 使用一个类方法实现备选构造方法 3. 扩展内置的format()和str.format()使用的格式微语言 阅读全文
posted @ 2018-04-16 22:43 Rocin 阅读(119) 评论(0) 推荐(0)
摘要:px(像素)、em、% 百分比 1. em 1.1 本元素给定字体的 font size 值,如果元素的 font size 为 14px ,那么 1em = 14px;如果 font size 为 18px,那么 1em = 18px。 实现段落首行缩进 24px(也就是两个字体大小的距离) 1. 阅读全文
posted @ 2018-04-16 20:49 Rocin 阅读(309) 评论(0) 推荐(0)
摘要:1. 布局模型与盒模型一样都是 CSS 最基本、 最核心的概念。 2. 但布局模型是建立在盒模型基础之上,又不同于我们常说的 CSS 布局样式或 CSS 布局模板。 3. 布局模型是本质,CSS 布局模板是外在的表现形式。 在网页中,元素有三种布局模型: 1. 流动模型(Flow) 2. 浮动模型 阅读全文
posted @ 2018-04-16 18:06 Rocin 阅读(192) 评论(0) 推荐(0)
摘要:1.盒子模型 宽度和高度 盒模型是CSS布局的基石,它规定了网页元素如何显示以及元素间相互关系。 一个元素实际宽度(盒子的宽度)=左边界+左边框+左填充+内容宽度+右填充+右边框+右边界 CSS: HTML: 元素的实际长度为:10px+1px+20px+200px+20px+1px+10px=26 阅读全文
posted @ 2018-04-16 15:50 Rocin 阅读(274) 评论(0) 推荐(0)
摘要:1. 外部样式表 2. 内部样式表 3. 内嵌样式(可在动态效果中同 JavaScript 一同使用) 阅读全文
posted @ 2018-04-16 11:59 Rocin 阅读(152) 评论(0) 推荐(0)
摘要:在CSS中,html中的标签元素大体被分为三种不同的类型:块状元素(block)、内联元素(又叫行内元素,inline)和内联块状元素(inline block)。 1. 常用的块状元素有: 2. 常用的内联元素有: 3.常用的内联块状元素有: 4. 块级元素(block)特点 (1)总是从新行开始 阅读全文
posted @ 2018-04-16 11:01 Rocin 阅读(1692) 评论(0) 推荐(0)
摘要:第四部分第8章,对象引用、可变性和垃圾回收 1. 创建对象之后才会把变量分配给对象 变量是对象的标注,是对象的别名,是对象的引用,并不是对象存储的地方。 例子1. 证明赋值语句的右边先执行 2. 标识(id())、相等性(==)和别名 例子1. 两个变量指向同一个对象 例子2. chrles和lew 阅读全文
posted @ 2018-04-15 23:17 Rocin 阅读(211) 评论(0) 推荐(0)
摘要:第7章 函数装饰器和闭包 装饰器用于在源码中“标记”函数,动态地增强函数的行为。 了解装饰器前提是理解闭包。 闭包除了在装饰器中有用以外,还是回调式编程和函数式编程风格的基础。 1. 装饰器基础知识 1. 装饰器是callable对象,其参数是被装饰的函数。 2. 装饰器将被装饰的函数处理后返回,或 阅读全文
posted @ 2018-04-15 16:10 Rocin 阅读(267) 评论(0) 推荐(0)
摘要:使用一等函数实现设计模式 中文电子书P278 合理利用作为一等对象的函数,把模式中涉及的某些类的实例替换成简单的函数,从而简化代码。 1. 重构“策略”模式 1. 中文电子书P282 2. Python3.0 3.3中,声明抽象基类要使用metaclass=关键字:class Promotion(m 阅读全文
posted @ 2018-04-13 12:48 Rocin 阅读(137) 评论(0) 推荐(0)
摘要:参考: http://blog.jobbole.com/103290/ https://www.zhihu.com/question/19732473/answer/23434554 http://blog.huanghao.me/?p=95 1. 同步和异步关注的是 消息通信机制 。 2. 非阻塞 阅读全文
posted @ 2018-04-13 12:23 Rocin 阅读(388) 评论(0) 推荐(0)
摘要:参考 1. https://docs.python.org/3/library/copy.html?highlight=copy%20copy copy.copy 2. https://en.wikipedia.org/wiki/Object_copying Shallow_copy Fluent 阅读全文
posted @ 2018-04-12 09:25 Rocin 阅读(253) 评论(0) 推荐(0)
摘要:参考 https://docs.python.org/3/library/functions.html?highlight=int int If x is not a number or if base is given, then x must be a string, bytes, or byt 阅读全文
posted @ 2018-04-11 16:47 Rocin 阅读(260) 评论(0) 推荐(0)
摘要:参考 https://stackoverflow.com/questions/9189810/css display inline vs inline block An inline block element is placed as an inline element (on the same 阅读全文
posted @ 2018-04-11 10:26 Rocin 阅读(138) 评论(0) 推荐(0)
摘要:一等函数 一等函数即将函数看作一等对象。一等对象满足一下条件: 1. 在运行时创建 2. 能赋值给变量或数据结构中的元素 3. 能作为参数传给函数 4. 能作为函数的返回结果 1. 一等函数 例子1. 证明function是对象,调用__doc__属性,用type()检查它的类型 python de 阅读全文
posted @ 2018-04-11 08:58 Rocin 阅读(195) 评论(0) 推荐(0)
摘要:参考 https://stackoverflow.com/questions/2970608/what are named tuples in python 先上例子,用tuple和namedtuple分别表示点(x, y),然后计算两个点的距离 1. 用tuple表示点,从例子可见计算两个点的距离 阅读全文
posted @ 2018-04-10 23:28 Rocin 阅读(323) 评论(0) 推荐(0)
摘要:cd进要启动服务器的目录 python m http.server 7800 (Python 3.x) python m SimpleHTTPServer 7998 (Pyhton2.x) 阅读全文
posted @ 2018-04-09 13:13 Rocin 阅读(629) 评论(0) 推荐(0)
摘要:文本和字节序列 人使用文本,计算机使用字节序列 1. 大纲: 1. 字符、码位和字节表述 2. bytes、bytearray和memoryview等二进制序列的独特特性 3. 全部Unicode和陈旧字符集的编解码器 4. 避免和处理编码错误 5. 处理文本文件的最佳实践 6. 默认编码的陷阱和标 阅读全文
posted @ 2018-04-08 14:10 Rocin 阅读(190) 评论(0) 推荐(0)
摘要:字典和集合 dict和set都基于hash table实现 1. 大纲: 1. 常见的字典 方法 2. 如何处理查 找不到的键 3. 标准库中 dict 类型的 变种 4. set 和 fronzenset 类型 5. Hash table的工作原理 6. Hash table带来的潜在影响 字典d 阅读全文
posted @ 2018-04-05 23:17 Rocin 阅读(192) 评论(0) 推荐(0)
摘要:1. 序列数据 例如字符串、列表、字节序列、元组、XML元素、数据库查询结果等,在Python中用统一的风格去处理。例如,迭代、切片、排序、拼接等。 2. 容器序列与扁平序列 容器序列:容器对象包含任意类型对象的引用。如list、tuple和collections.deque. 但dict和set是 阅读全文
posted @ 2018-04-04 22:17 Rocin 阅读(174) 评论(0) 推荐(0)
摘要:列表推导式(list comprehension) Python2: Python2中for关键词之后的赋值操作可能会影响context中的同名变量。Python3不存在此问题。 Python3: 1. 原本context中的变量x的值被保留了。 2. 列表推导式也创建了正确的列表。 阅读全文
posted @ 2018-04-03 20:56 Rocin 阅读(251) 评论(0) 推荐(0)
摘要:01 data model/frenchdeck.py 1. Python解释器碰到特殊的句法时,会使用__特殊方法__去激活一些基本的对象操作。 特殊方法的存在是为了被解释器用的。没有my_object.len()这种写法,应该用len(my_object)。 比如my_collection[ke 阅读全文
posted @ 2018-04-03 20:10 Rocin 阅读(175) 评论(0) 推荐(0)
摘要:强类型与弱类型 如果一门语言很少隐式转换类型,说明它是强类型语言;如果经常这么做,说明它是弱类型语言。Java、C++和Python是强类型语言。PHP、JavaScript和Perl是弱类型语言。 概念参照Google等搜索引擎 这里的随笔举出例子:证明Python是强类型语言,JavaScrip 阅读全文
posted @ 2018-04-03 19:44 Rocin 阅读(353) 评论(0) 推荐(0)
摘要:dist packages 和 site packages的区别 Reference: https://stackoverflow.com/questions/9387928/whats the difference between dist packages and site packages h 阅读全文
posted @ 2018-04-03 11:38 Rocin 阅读(445) 评论(0) 推荐(0)