Skip to content

四号程序员

Keep It Simple and Stupid

  • Home
  • 读过的书
  • 从0到1实战微服务架构(第2版)

BeautifulSoup中文乱码解决问题

Leave a reply

import urllib2
from BeautifulSoup import BeautifulSoup

page = urllib2.urlopen('http://www.leeon.me');
soup = BeautifulSoup(page,fromEncoding="gb18030")

print soup.originalEncoding
print soup.prettify()
如果中文页面编码是gb2312,gb[......]

继续阅读

This entry was posted in Python and tagged BeautifulSoup, Python, 中文, 乱码 on 2012-09-13 by coder4.

Linux不通过SSH传输文件

Leave a reply

以下命令需要Modem模式支持,如SecureCRT,putty中不行。

从服务器下载文件(到我的文档):
sz file
向服务器上传文件:
rz -be[......]

继续阅读

This entry was posted in Linux on 2012-09-06 by coder4.

Python中的笛卡尔乘积(任意维度)

Leave a reply

现在的需求是,有若干个List,假设2个:

[1, 3, 5]

[4, 6]

我们要输出(1, 4), (1, 6), (3, 4), (3, 6), (5, 4), (5, 6)

Python中直接提供了笛卡尔乘积,很给力:
a = [1, 3, 5]
b = [4, 6]
import itertools
for x in itertools.product(a, b):
print x
(1, 4)
(1, 6)
(3, 4)
(3, 6)
([......]

继续阅读

This entry was posted in Python and tagged Python, 乘积, 笛卡尔 on 2012-09-05 by coder4.

Hadoop执行时输出无法重定向

Leave a reply

执行Hadoop任务时,会输出很多东西,没法重定向,貌似是stderr,不是stdout。

以下方法:
hadoop xxxx 1>0 2>file_name[......]

继续阅读

This entry was posted in Linux and tagged Hadoop, 日志, 输出, 重定向 on 2012-08-27 by coder4.

Java实现生产者、消费者的几种方法

Leave a reply

先说下同步原语。

我们假设有两个信号量full(表示slots中有货),empty(表示slots中有空闲)

生产者:
producer:

wait(empty)

mutex_lock

put an item

mutex_unlock

signal(full)
消费者:
consumer:

wait(full)

mutex_lock

get an item

mutex_unlock

signal(empty)
上述同[......]

继续阅读

This entry was posted in Java on 2012-08-24 by coder4.

Post navigation

← Older posts
Newer posts →

Categories

  • Android
  • C && C++
  • Go
  • iOS
  • Java
  • Linux
  • Mac
  • NLP
  • opencv
  • Perl
  • PHP
  • Python
  • RPC
  • Ruby
  • Visual C++ && C#
  • Windows
  • Wordpress
  • 前端技术
  • 大数据技术
  • 心情随笔
  • 搜索技术
  • 数据库技术
  • 未分类
  • 机器学习
  • 笔面题
  • 算法&数据结构
  • 网络&网络模拟
  • 计算机技术
  • 设计

Tags

  • Android
  • C
  • CentOS
  • c语言
  • Debian
  • docker
  • go
  • gtk
  • Hadoop
  • Hive
  • ios
  • Java && J2EE
  • Java && J2EE
  • Java核心技术
  • KVM
  • Linux
  • MySQL
  • nginx
  • Oracle
  • PHP
  • Python
  • Python Essential Reference
  • shell
  • socket
  • Ubuntu
  • VC
  • windows
  • 严蔚敏
  • 中文
  • 乱码
  • 卷2
  • 字符串
  • 安装
  • 实现
  • 排序
  • 教程
  • 数据结构
  • 核心技术
  • 算法
  • 算法技术手册
  • 编译
  • 读书笔记
  • 递归
  • 配置
  • 重读
Proudly powered by WordPress