Rocket chat 项目结构

侧边栏文件 :

html
vim packages/rocketchat-ui-sidenav/client/sideNav.html

js
packages/rocketchat-ui-sidenav/client/sidebarItem.html

主页:
packages/rocketchat-ui-master/client/main.html

Home 页面
./packages/rocketchat-ui/client/views/app/home.js

文本设置:
vim packages/rocketchat-lib/server/startup/settings.js

CSS 路径
packages/rocketchat-theme/client/imports/fnkeep/

调用方式:
RocketChat.settings.get(‘Layout_Home_Content’)

Css Layout 调用
RocketChat.Layout
packages/rocketchat-lib/client/lib/Layout.js

URL 路由规则:
client/routes/router.js

Mongo DB 调用
new Mongo.Collection

Xpath 多级解析

selector = Selector(response)
divs = selector.xpath(‘//div[@class=”detials-title-cont”]’)
for div in divs:
h4divs = div.xpath(“./h4/text()”)
for h4div in h4divs:
print “——- “,h4div.extract()
uldivs = div.xpath(‘./following-sibling::ul[1]’)
for uldiv in uldivs:
uladivs = uldiv.xpath(“./li/div/div/a/text()”)
for uladiv in uladivs:
print “parse_tpo_lecture_select txt ——————” ,uladiv.extract()

Python 正则 处理网页

# -*- coding: utf-8-*-
import re
##过滤HTML中的标签
#将HTML中标签等信息去掉
#@param htmlstr HTML字符串.
def filter_tags(htmlstr):
#先过滤CDATA
re_cdata=re.compile(‘//< !\[CDATA\[[^>]*//\]\]>’,re.I) #匹配CDATA
re_script=re.compile(‘< \s*script[^>]*>[^< ]*<\s*/\s*script\s*>‘,re.I)#Script
re_style=re.compile(‘< \s*style[^>]*>[^< ]*<\s*/\s*style\s*>‘,re.I)#style
re_br=re.compile(‘
‘)#处理换行
re_h=re.compile(‘]*>’)#HTML标签
re_comment=re.compile(‘‘)#HTML注释
s=re_cdata.sub(”,htmlstr)#去掉CDATA
s=re_script.sub(”,s) #去掉SCRIPT
s=re_style.sub(”,s)#去掉style
s=re_br.sub(‘\n’,s)#将br转换为换行
s=re_h.sub(”,s) #去掉HTML 标签
s=re_comment.sub(”,s)#去掉HTML注释
#去掉多余的空行
blank_line=re.compile(‘\n+’)
s=blank_line.sub(‘\n’,s)
s=replaceCharEntity(s)#替换实体
return s

##替换常用HTML字符实体.
#使用正常的字符替换HTML中特殊的字符实体.
#你可以添加新的实体字符到CHAR_ENTITIES中,处理更多HTML字符实体.
#@param htmlstr HTML字符串.
def replaceCharEntity(htmlstr):
CHAR_ENTITIES={‘nbsp’:’ ‘,’160′:’ ‘,
‘lt’:’< ','60':'<', 'gt':'>‘,’62’:’>’,
‘amp’:’&’,’38’:’&’,
‘quot’:'”‘,’34’:'”‘,}

re_charEntity=re.compile(r’&#?(?P\w+);’)
sz=re_charEntity.search(htmlstr)
while sz:
entity=sz.group()#entity全称,如>
key=sz.group(‘name’)#去除&;后entity,如>为gt
try:
htmlstr=re_charEntity.sub(CHAR_ENTITIES[key],htmlstr,1)
sz=re_charEntity.search(htmlstr)
except KeyError:
#以空串代替
htmlstr=re_charEntity.sub(”,htmlstr,1)
sz=re_charEntity.search(htmlstr)
return htmlstr

def repalce(s,re_exp,repl_string):
return re_exp.sub(repl_string,s)

if __name__==’__main__’:
s=file(‘Google.htm’).read()
news=filter_tags(s)
print news

Super Linux server

1、开机启动项配置:
root@iZj6cjcwx7sfb0vurxqanbZ:/etc/init.d# update-rc.d -f apache2 remove
Removing any system startup links for /etc/init.d/apache2 …
/etc/rc0.d/K09apache2
/etc/rc1.d/K09apache2
/etc/rc2.d/S91apache2
/etc/rc3.d/S91apache2
/etc/rc4.d/S91apache2
/etc/rc5.d/S91apache2
/etc/rc6.d/K09apache2
root@iZj6cjcwx7sfb0vurxqanbZ:/etc/init.d# update-rc.d -f apache2 defaults
Adding system startup for /etc/init.d/apache2 …
/etc/rc0.d/K20apache2 -> ../init.d/apache2
/etc/rc1.d/K20apache2 -> ../init.d/apache2
/etc/rc6.d/K20apache2 -> ../init.d/apache2
/etc/rc2.d/S20apache2 -> ../init.d/apache2
/etc/rc3.d/S20apache2 -> ../init.d/apache2
/etc/rc4.d/S20apache2 -> ../init.d/apache2
/etc/rc5.d/S20apache2 -> ../init.d/apache2
root@iZj6cjcwx7sfb0vurxqanbZ:/etc/init.d# ls /etc/rc0.d/
K10unattended-upgrades K19rng-tools K20agentwatch K20aliyun-rdate K20apache2 K20im K20nscd K20redis-server K20rsync K20supervisor K20xl2tpd K84ipsec README S20sendsigs S30urandom S31umountnfs.sh S40umountfs S60umountroot S90halt
root@iZj6cjcwx7sfb0vurxqanbZ:/etc/init.d# exit

2、 WordPress index.php 重写
搭建好lamp环境之后,如果你需要使用apache的url重写功能,需要配置文件中启用apache的Rewrite模块:
1.如果是sudo apt-get install lamp-server^方式搭建的开发环境:
在终端中执行
sudo a2enmod rewrite
1
指令后,即启用了 Mod_rewrite 模块。

另外,也可以通过将 /etc/apache2/mods-available/rewrite.load 连接到 /etc/apache2/mods-enabled/rewrite.load 来打开 Mod_rewrite 模块。用指令操作就是:
sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
1
2.如果是源码编译安装的lamp环境:

修改配置文件:/usr/local/apache/conf/httpd.conf

打开LoadModule rewrite_module modules/mod_rewrite.so

即可。
之后重启apache服务即可。
root@iZj6cjcwx7sfb0vurxqanbZ:/var/www/beststudywow/coder# cat .htaccess

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress
root@iZj6cjcwx7sfb0vurxqanbZ:/var/www/beststudywow/coder#

3 、SVN 服务器 配置

* 运行环境:ubuntu 14.04 64位

首先,官方教程是必须的:
https://help.ubuntu.com/community/L2TPServer

没有安照这个做过了就先不要到处百度“如何部署L2TP”之类的了。先参阅Official Ubuntu Documentation。

主要的问题出在:
sudo ipsec verify
这一步。因为官方要求是得到一个没有任何错误的反馈。
在第一次测试的时候我出现了2个[FAILED],具体情况如下:

Checking your system to see if IPsec got installed and started correctly:
Version check and ipsec on-path [OK] Linux Openswan U2.6.38/K3.13.0-52-generic (netkey)
Checking for IPsec support in kernel [OK] SAref kernel support [N/A] NETKEY: Testing XFRM related proc values [FAILED]

Please disable /proc/sys/net/ipv4/conf/*/send_redirects
or NETKEY will cause the sending of bogus ICMP redirects!

[FAILED]

Please disable /proc/sys/net/ipv4/conf/*/accept_redirects
or NETKEY will accept bogus ICMP redirects!

[OK] Hardware RNG detected, testing if used properly [FAILED]

Hardware RNG is present but ‘rngd’ or ‘clrngd’ is not running.
No harware random used!

Checking that pluto is running [OK] Pluto listening for IKE on udp 500 [OK] Pluto listening for NAT-T on udp 4500 [OK] Checking for ‘ip’ command [OK] Checking /bin/sh is not /bin/dash [WARNING] Checking for ‘iptables’ command [OK] Opportunistic Encryption Support [DISABLED]

我们先解决:
NETKEY: Testing XFRM related proc values [FAILED] 解决方案:在命令行里黏贴以下命令
for each in /proc/sys/net/ipv4/conf/*
> do
> echo 0 > $each/accept_redirects
> echo 0 > $each/send_redirects
> done

然后解决:
Hardware RNG detected, testing if used properly [FAILED]

Hardware RNG is present but ‘rngd’ or ‘clrngd’ is not running.
No harware random used!
解决方案:
sudo apt-get install rng-tools

* echo 0 > /proc/sys/net/ipv4/ip_forward
* ipsec verify

2236 vi /etc/apache2/mods-enabled/dav_svn.conf
70
71 DAV svn
72 SVNParentPath /var/www/svn/
73 AuthType Basic
74 AuthName “Subversion Repository”
75 AuthUserFile /etc/apache2/dav_svn.passwd
76 AuthzSVNAccessFile /etc/apache2/dav_svn.authz
77 Require valid-user
78

2238 vim /etc/apache2/dav_svn.authz
1 [groups] 2 admin=svnuser
3 [repos:/] 4 *=
5 @admin=rw

2323 sudo chown -R www-data:subversion xuezhe
2324 sudo chmod -R g+rws xuezhe

1. Apache切换php 版本

sudo a2dismod php5
sudo a2enmod php7.0
root@iZj6cjcwx7sfb0vurxqanbZ:/var/www/beststudywow/moodle# sudo apt-get install php7.0-xml
root@iZj6cjcwx7sfb0vurxqanbZ:/var/www/beststudywow/moodle# sudo service apache2 restart

1.导入软件源的公钥
sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv EA312927
1
2.为mongodb创建软件源list文件

ubuntu12.04
echo “deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.2 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
1
ubuntu14.04
echo “deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
1
ubuntu16.04
echo “deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
1
3.更新软件源并安装mongodb
sudo apt-get update
sudo apt-get install -y mongodb-org
1
2
如果想要安装特定的版本,使用下面命令:
sudo apt-get install -y mongodb-org=3.2.9 mongodb-org-server=3.2.9 mongodb-org-shell=3.2.9 mongodb-org-mongos=3.2.9 mongodb-org-tools=3.2.9
1

Audio Post

This is dummy copy. It is not meant to be read. It has been placed here solely to demonstrate the look and feel of finished, typeset text. Only for show. He who searches for meaning here will be sorely disappointed. These words are here to provide the reader with a basic impression of how actual text will appear in its final presentation. Think of them merely as actors on a paper stage, in a performance devoid of content yet rich in form. That being the case, there is really no point in your continuing to read them. After all, you have many other things you should be doing. Who’s paying you to waste this time, anyway?

This is dummy copy. It’s Greek to you. Unless, of course, you’re Greek, in which case, it really makes no sense. Why, you can’t even read it! It is strictly for mock-ups. You may mock it up as strictly as you wish.

Meaningless mock-up, mock turtle soup spilled on a mock turtle neck. Mach I Convertible copy. To kill a mockingbird, you need only force it to read this copy. This is Meaningless filler. (Elvis movies.) It is not meant to be a forum for value judgments nor a scholarly diatribe on how virtue should be measured. The whole point here (if such a claim can be made in an admittedly pointless paragraph) is that this is dummy copy. Real bullets explode with destructive intensity. Such is not the case with dummy bullets. In fact, they don’t explode at all. Duds. Dull thuds. Dudley do-wrongs. And do-wrongs don’t make a right. Why on earth are you still reading this? Haven’t you realized it’s just dummy copy? How many times must you be reminded that it’s really not meant to be read? You’re only wasting precious time. But be that as it may, you’ve got to throw in a short paragraph from time to time. Here’s a short paragraph.

It breaks up the intimidating blocks of text and makes the page more inviting to read, which is again ironic, considering this is dummy copy. It is not meant to be read. Someday this space will be occupied by real copy that is meant to be read. What other form of filler would dare be so politically incorrect? This is dummy copy. It is not meant to be read. Good thing.

This is dummy copy. It is not meant to be read. Accordingly, it is difficult to figure out when to end it. If this were real copy, it would have ended long ago, because—as we all know—no one reads body copy, and even fewer read body copy this long. But then, this is dummy copy. It is not meant to be read. Period.

This is a video post and it is very nice

Meaningless mock-up, mock turtle soup spilled on a mock turtle neck. Mach I Convertible copy. To kill a mockingbird, you need only force it to read this copy. This is Meaningless filler. (Elvis movies.) It is not meant to be a forum for value judgments nor a scholarly diatribe on how virtue should be measured. The whole point here (if such a claim can be made in an admittedly pointless paragraph) is that this is dummy copy. Real bullets explode with destructive intensity. Such is not the case with dummy bullets. In fact, they don’t explode at all. Duds. Dull thuds. Dudley do-wrongs. And do-wrongs don’t make a right. Why on earth are you still reading this? Haven’t you realized it’s just dummy copy? How many times must you be reminded that it’s really not meant to be read? You’re only wasting precious time. But be that as it may, you’ve got to throw in a short paragraph from time to time. Here’s a short paragraph. It breaks up the intimidating blocks of text and makes the page more inviting to read, which is again ironic, considering this is dummy copy. It is not meant to be read. Someday this space will be occupied by real copy that is meant to be read. What other form of filler would dare be so politically incorrect? This is dummy copy. It is not meant to be read. Good thing. This is dummy copy. It is not meant to be read. Accordingly, it is difficult to figure out when to end it. If this were real copy, it would have ended long ago, because—as we all know—no one reads body copy, and even fewer read body copy this long. But then, this is dummy copy. It is not meant to be read. Period.