Life as a middle-aged Geek
Summer break is but a fading memory, but Tim Bray’s last post made me realize it might be worthwhile to try to capture some of the stuff I did over the past month or so, partly because I’ve had little...
View ArticleRichard Tew: Mixing iteration and read methods would lose data
I just upgraded to python 2.7.12 and my code is now erroring with rather unhelpful Mixing iteration and read methods would lose data errors. Googling for this yields a number of StackOverflow posts...
View ArticlePython全栈之路系列之线程与进程
What is a Thread? 线程是操作系统能够进行运算调度的最小单位,它被包含在进程之中,是进程中的实际运作单位,一条线程指的是进程中一个单一顺序的控制流,一个进程中可以并发多个线程,每条线程并行执行不同的任务。 在同一个进程内的线程的数据是可以进行互相访问的。...
View ArticlePython批量扫描服务器80端口状态
用python写了一个简陋的端口扫描脚本,其简单的逻辑如下: 1. python DetectHostPort.py iplist.txt(存放着需要扫描的IP地址列表的文本,每行一个地址) 2. 输入扫描端口、扫描时间和扫描间隔。 3. 输出扫描信息。 下面贴上源码,欢迎拍砖。 #!/usr/bin/env pythonimport sysimport timeimport socketdef...
View ArticleFormatting cells in Google Sheets with Python
Introduction One of the critical things that developers have not been able to do in previous versions of the Google Sheets API is to format cells... that's a big deal! Anyway, the past is the past, and...
View ArticlePython获取服务端口存活状态并报警
最近发现公司的测试环境中有个Socket服务的端口总是莫名其妙Down掉,但是服务却正常运行着,看样子是僵死了。 虽然是测试环境,但是也不能这样放着不管,于是连夜写了一个简单的监控脚本。因为服务器是windows的,所以要用到wmi模块。逻辑如下: 1、用wmi模块获取系统中处于停止状态的服务,生成一个字典。...
View Article使用Python对全角字符半角字符互转
在文本处理的时候,经常会遇到全角半角不一致的问题。于是需要程序能够快速的在两者之间互转。由于全角半角本身存在着映射关系,所以处理起来并不复杂。具体规则为: 全角字符unicode编码从65281~65374 (十六进制 0xFF01 ~ 0xFF5E) 半角字符unicode编码从33~126 (十六进制 0x21~ 0x7E) 空格比较特殊,全角为 12288(0x3000),半角为...
View ArticleOverhead of Go's Generic Sort
Overhead of Go's Generic Sort This started while prototyping an idea to make faster external merge sorts through additional bookkeeping and introspection. I began with a fairly naive, top-down merge...
View Articlepython之Socket网络编程
什么是网络? 网络是由节点和连线构成,表示诸多对象及其相互联系。在数学上,网络是一种图,一般认为专指加权图。网络除了数学定义外,还有具体的物理含义,即网络是从某种相同类型的实际问题中抽象出来的模型。在计算机领域中,网络是信息传输、接收、共享的虚拟平台,通过它把各个点、面、体的信息联系到一起,从而实现这些资源的共享。网络是人类发展史来最重要的发明,提高了科技和人类社会的发展。 网络通信的三要素...
View ArticlePython笔记(一)――函数
什么是函数: 函数就是一段具有特定功能、被封装、可重用的程序。相当于一个黑箱,输入一些数据,经过它的处理后,输出我们想要的信息。 函数定义格式: def 函数名(参数): .......(函数体) 函数调用:在另一段程序中使用已经写好的函数成为调用。 实参:在调用函数时,通过参数将一些值传递给函数处理,这些在调用函数时提供给函数处理的值成为实参。...
View ArticleTutorial for a First Project Using Django
Install python Pip is python installation and dependency packages management tool. Before installation anything, the best practice is for all time to keep updated ubuntu packages....
View ArticleNeovim with Python on OSX
Want to use plugins like Deoplete ,Hyperstyle and other python plugins on OSX, you need a working installation of both Python2 and Python3 managed by Homebrew (ie, system default Python isn’t enough)....
View Article绝对的Geek!!用 Python 写了个机器人,租到了满意的房子
今天分享的这篇译文,讲述的是硅谷的一位工程师利用编程技能帮助自己又快又好地租房的故事。 数月前,我从波士顿搬到了湾区。我和 Priya(我女朋友)都听说了各种关于租房市场的恐怖故事。事实是,找房子是一个痛苦的过程。在 Google 上搜索“怎样在旧金山租公寓”,得到的 许多 建议的页面就是很好的证明。 波士顿很冷,但在旧金山找房子很可怕 我们了解到一些房东会举行开放日(open...
View Article怎样使用Scrapy
参考: http://scrapy-chs.readthedocs.io/zh_CN/latest/intro/tutorial.html 创建一个项目: scrapy startproject tutorial 输出: New Scrapy project 'tutorial', using template directory...
View ArticleHow I Feel When I Learn To Code
I’ve started learning how to code many times over again. It began with HTML and CSS when I was 14. Then Delphi in high school. Processing, javascript & jQuery in university. R on Code School ,...
View ArticleZope Resurrection: Part 1 Reanimation
Now weare helping Zope in the python 3 wonderland :Almost 20 people started with the reanimation of Zope. We are working mostly on porting important dependencies of Zope to Python 3: RestrictedPython...
View ArticleImplementing the "Soft Delete" Pattern with Flask and SQLAlchemy
Every time I find myself writing code to delete data from a database I get nervous. What if I later determine that I needed this piece of information, after all? For example, what if having access to...
View ArticleInstagram 基于 Python 语言的 Web Service 效率提升之道
Instagram 基于 python 语言的 Web Service 效率提升之道 昨天来源:linux中国 Instagram 目前部署了世界上最大规模的 Django Web 框架(该框架完全使用 Python 编写)。我们最初选用 Python 是因为它久负盛名的简洁性与实用性,这非常符合我们的哲学思想――“先做简单的事情”。但简洁性也会带来效率方面的折衷。Instagram...
View ArticleBuilding ACI images with Nix
First a big thank you to all the organisers of systemd conference . You did an amazing job and I can not wait for 2016 edition. I do wish there would be some place in the program for lightning/ignate...
View ArticleOutput RGB Bytes From Any Source
True Story Follows So I’m on the grind, straight hustling on an interesting side project. I’m exploring the whacky world of microcontrollers and C blogs that have no CSS on them. And by the time I’ve...
View Article