- 博客(30)
- 问答 (2)
- 收藏
- 关注
转载 单例模式(Singleton)
单例模式(Singleton)的6种实现转自 http://www.cnblogs.com/rush/archive/2011/10/30/2229565.html1.1.1 摘要 在我们日常的工作中经常需要在应用程序中保持一个唯一的实例,如:IO处理,数据库操作等,由于这些对象都要占用重要的系统资源,所以我们必须限制这些实例的创建或始终使用一个公用
2016-03-08 07:32:53
576
转载 Shell脚本统计文件行数的8种方法
转自 http://www.jb51.net/article/61943.htm获取单个文件行数文件:test1.sh行数:20方法一复制代码代码如下:awk '{print NR}' test1.sh|tail -n1如图所示:方法二复制代码代码如下:awk 'END{
2016-01-20 09:13:16
30186
转载 Linux养成计划:sed详解
原文出自 http://www.cnblogs.com/ggjucheng/archive/2013/01/13/2856901.html sed命令详解简介sed 是一种在线编辑器,它一次处理一行内容。处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的内容送往屏幕。接着处理下
2016-01-18 06:51:55
456
原创 java多线程
创建任务和线程为任务定义一个类,这个类必须实现runnable接口,runnable接口只包含一个run办法,这个方法告诉系统线程将如何运行。>>> TaskClass task = new TaskClass(…); 创建任务的线程>>> Thread thread = new Thread(task); 用start()方法告诉java虚拟机该线程准
2016-01-17 17:22:02
499
转载 Linux养成计划:grep详解
原文来自http://www.cnblogs.com/ggjucheng/archive/2013/01/13/2856896.html简介grep (global search regular expression(RE) and print out the line,全面搜索正则表达式并把行打印出来)是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行打印出来。U
2016-01-17 12:40:23
332
原创 Linux养成计划:awk
1. 基本用法>>> awk '{pattern + action}' {filenames}>>> awk [-F field-separator] 'commands' input-file(s)指定分隔符 -F, 默认域分隔符是"空白键" 或 "[tab]键"pattern,正则表达式,用斜杠括起来 / /commands或者action{}有多
2016-01-17 11:35:58
382
原创 Linux养成计划:文件搜索命令
1. 文件搜索命令locate(搜索速度快,功能单一,只能搜文件名)>>> locate文件名locate是后台数据库搜索,搜索速度快。locate 使用要点:注数据库默认是每天更新一次,可以用updatedb 命令来立刻更新数据库。 速度最快。只能按照文件名来搜索。locate缺点只能按照文件名来搜索优点是搜索速度快 因为在他在自己的数据库搜索locate搜索配置文件/
2016-01-17 08:34:02
460
转载 How to disable SSH timeout
Inactiveor idle SSH connections are normally disconnected by the server after a certainperiod of time. This depends on how the SSH server is configured, and upondisconnection the SSH client will be pr
2016-01-16 19:40:28
721
原创 云计算aws系列:benchmarking
1. install sysbench>>>sudo apt-get update>>>sudo apt-get install sysbench2. CPU testing>>> sysbench --test=cpu--cpu-max-prime=40000 run>>> sysbench --test=cpu --cpu-max-prime=50000 --n
2016-01-16 19:31:38
729
原创 云计算aws系列:ssh登陆aws
PrerequisitesBeforeyou connect to your Linux instance, complete the following prerequisites:Install an SSH clientYour Linux computer most likely includes an SSH client by default. You can chec
2016-01-16 19:05:52
817
原创 云计算aws系列:Permission denied (publickey)
ssh连接aws时出现问题;192-168-1-4:Downloads stella$ ssh -i 0112.pem shuangxu@ec2-52-91-206-97.compute-1.amazonaws.com @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ WARNING: UNP
2016-01-16 18:51:32
8416
原创 云计算aws系列:scp上传下载文件
注意:在本机终端进行…1. 从本地拷贝文件到远程主机scp -i 0112.pem rootkey.csv ec2-user@ec2-52-91-206-97.compute-1.amazonaws.com:/home/ec2-user/test-i identity_file 从指定文件中读取传输时使用的密钥文件,此参数直接传递给ssh。2. 从远程主机
2016-01-16 18:42:06
11867
原创 Linux养成计划: 用户管理
1、用户和用户组 用户:使用操作系统的人 用户组:具有相同系统权限的一组用户 2、 group:存储当前系统中所有用户组信息;gshadow:存储当前系统中用户组的密码信息;passwd:存储当前系统中所有用户信息;shadow:存储当前系统中用户密码信息; /etc/group存储当前系统中所有用户组信息 组名:组密码占位
2016-01-13 05:08:25
450
原创 Appstore proj: Calculate an App's Top-5 related apps(2)
Save data into MongoDBinstead of print, we do persistpersist top 5 recommended apps in app_info1. Persist top 5 apps in MongoDB2. Do it for all apps loop through all apps, ge
2016-01-12 11:55:23
515
原创 Appstore proj: Calculate an App's Top-5 related apps(1)
How to calculate similarity?use cosine similarity!Edit helper.py.So you can call the function in helper class when needed>>> helper = Helper()similarity = helper.cosine_simil
2016-01-12 11:01:57
664
原创 Linux养成计划: vi编辑器
VI,即 visual interface,可视化接口,类似于windows中的记事本,但相对于记事本强大很多。 VI -->VIM:vi中ctrl+u撤销(只能)一步vim可以撤销多步vi只能运行在Unix系统中vim还可以在windows版本中vim可以用不同字体颜色标出,有图形界面VI编辑器的操作模式:命令模式、输入模式、底行模式;有时将底行模
2016-01-12 09:31:21
414
原创 python isinstance(), stack,判断list, dict, tuple为空
Problem:Nikola likes to categorize everything in sight. One time Stephan gave him a label maker for his birthday, and the robots were peeling labels off of every surface in the ship for weeks. H
2016-01-12 07:16:19
10646
原创 Using Databases with Python - Many students in many courses (produce database from json file)
This application will read roster data in JSON format, parse the file, and then produce an SQLite database that contains a User, Course, and Member table and populate the tables from the data file.D
2016-01-11 19:08:01
3051
原创 Using Databases with Python -Musical Track Database (produce database from XML file)
This application will read an iTunes export file in XML and produce a properly normalized database with this structure:CREATE TABLE Artist ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE
2016-01-11 18:55:25
6620
原创 Using Databases with Python-Counting Organizations
Counting OrganizationsThis application will read the mailbox data (mbox.txt) count up the number email messages per organization (i.e. domain name of the email address) using a database with the fol
2016-01-11 18:40:02
6814
转载 MongoDB 基础知识
转自pantao :http://segmentfault.com/a/1190000002694268?_ea=184402#articleHeader8基本概念文档是 MongoDB 中数据的基本单元,非常类似于关系型数据库中的行,但更具有表现力;集合 Collection 可以看作是一个动态模式(Dynamic Schema)的表;MongoDB 的一个实例可
2016-01-11 13:53:56
483
原创 Mac OS install mongodb
1. install mongodb>>> brew install mongodb2. create data directory>>> sudo mkdir -p /data/db3. set permission for data directory>>> sudo chmod -R 777/data4. run mongodb in frond ground(会停在
2016-01-10 20:22:04
506
原创 Crawler爬虫实例:huawei appstore
1. create a scrapy project>>> scrapy startproject appstore2. define extracted data schemaedit appstore/appstore/items.py, add the following:import scrapyclass AppstoreItem(scrapy.Item):
2016-01-09 17:40:38
2774
转载 Scrapy 示例 —— Web 爬虫框架
英文原文:Scrapy demo译者:skyim原文:http://www.oschina.net/translate/scrapy-demo在这个教材中,我们假定你已经安装了Scrapy。假如你没有安装,你可以参考这个安装指南。我们将会用开放目录项目(dmoz)作为我们例子去抓取。这个教材将会带你走过下面这几个方面:创造一个新的Scrapy项目定义您将提取的Item编写一个蜘
2016-01-09 14:33:03
1146
原创 在Mac OS El Capitan下用pip安装Scrapy 失败
环境:同时安装了Python 2.7,Python 3.4使用 安装命令 pip install Scrapy下载正常安装时出错:Installing collected packages: Scrapy, six, queuelib, lxml, w3lib, cssselectCleaning up...Exception:Traceback (most recen
2016-01-09 13:18:08
2339
原创 python join(), bool(), strip(), dict()
Question:Stephen's speech module is broken. Thismodule is responsible for his number pronunciation. He has to click to inputall of the numerical digits in a figure, so when there are big numbers it
2016-01-09 08:33:31
776
原创 python zip(), map()
Question:Tic-Tac-Toe, sometimes also known as Xs andOs, is a game for two players (X and O) who take turns marking the spaces in a3×3 grid. The player who succeeds in placing three respective marks
2016-01-07 09:47:51
575
原创 python count(), lower(), ord(), chr(), isalpha()
Question:You are given a text, which contains different english letters and punctuation symbols. You should find the most frequent letter in the text. The letter returned must be in lower case.
2016-01-06 14:20:51
1683
原创 linux达人养成计划:Linux简介
Imooc.com下 linux达人养成计划I课程笔记 一、版本介绍内核官网地址:www.kernal.org不要追求最新的版本内核版本(eg.2.6.18)(主版本.次版本.末版本)Linux不同的发行版本使用的内核版本是一样的(版本微微有些差别),只是他们加入了一些自己的图形化界面,发行版本要考虑稳定性和安全性Re
2016-01-02 13:50:55
1477
原创 虚拟机Linux配置网络
1. cd /etc/sysconfig/network-scripts2. lsvi ifcfg-eno1 (第一个文件)3 3.把onboot改为yes,保存,重启网络service network restart4.检验 ping 8.8.8.8 (google ip)
2015-12-29 21:46:37
506
空空如也
[JAVA]数组 求代码解释
2015-05-27
新手问题 JAVA for语句
2015-05-01
TA创建的收藏夹 TA关注的收藏夹
TA关注的人