‘IT DOC’ Posts

 

更换wordpress 域名

Read full article  | 评论关闭

1. 更改wp-config.php里面的域名

2. 修改数据库里面的内容

UPDATE wp_options SET option_value = replace(option_value, ‘old_domain’,'new_domain’) ;

UPDATE wp_posts SET post_content = replace(post_content, ‘old_domain’,'new_domain’) ;

UPDATE wp_posts SET guid = replace(guid, ‘old_domain’,'new_domain’) ;

UPDATE wp_comments SET comment_content = replace(comment_content, ‘old_domain’,'new_domain’) ;

UPDATE wp_comments SET comment_author_url = replace(comment_author_url, ‘old_domain’,'new_domain’) ;

Read More

ubuntu remove package

Read full article  | 评论关闭

 

apt-get autoclean:
如果你的硬盘空间不大的话,可以定期运行这个程序,将已经删除了的软件包的.deb安装文件从硬盘中删除掉。

 

apt-get clean:
类似上面的命令,但它删除包缓存中的所有包。这是个很好的做法,因为多数情况下这些包没有用了。

 

apt-get autoremove:
删除为了满足其他软件包的依赖而安装的,但现在不再需要的软件包。

 

其它:

apt-get remove 软件包名称:
删除已安装的软件包(保留配置文件)。

apt-get –purge remove 软件包名称:
删除已安装包(不保留配置文件)。

Read More

nginx upstream based on URL parameter

Read full article  | 评论关闭

 

 

location / {

if ( $arg_parameterName = “test1″ ) {
proxy_pass http://server1;
}
if ( $arg_parameterName = “test2″ ) {
proxy_pass http://server2;
}
}

Read More

nginx upstream based on http header

Read full article  | 评论关闭

upstream apache {
     server 127.0.0.1:8080;
}

upstream staging {
     server 127.0.0.1:8081;
}

upstream development {
     server 127.0.0.1:8082;
}

# map to different upstream backends based on header
map $http_x_server_select $pool {
     default "apache";
     staging "staging";
     dev "development";
}

server {
     listen 80;
     server_name example.com;
     location / {
          proxy_pass http://$pool;

          #standard proxy settings
          proxy_set_header X-Real-IP $remote_addr;
          proxy_redirect off;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $http_host;
          proxy_redirect off;
          proxy_set_header X-Forwarded-Proto $scheme;
          proxy_set_header X-NginX-Proxy true;
          proxy_connect_timeout 600;
          proxy_send_timeout 600;
          proxy_read_timeout 600;
          send_timeout 600;
     }
}

Read More

json 中文显示乱码

Read full article  | 评论关闭

方法一

print res_content.decode(‘raw_unicode_escape’)

 

方法二

print json.dumps(json.loads(result),ensure_ascii=False)

Read More

http cache

Read full article  | 评论关闭

 

 

Last-Modified  &  ETag  (判断是否修改)

Cache-Control & Expires  (缓存多久)

Read More

GITLAB /var/opt/gitlab/.ssh/authorized_keys 未更新

Read full article  | 评论关闭

 

用户添加public key 后,/var/opt/gitlab/.ssh/authorized_keys 未更新, 重启sidekiq即可!

$ sudo gitlab-ctl kill sidekiq

$ sudo gitlab-ctl start sidekiq

Read More

GITLAB 修改DNS

Read full article  | 评论关闭

 

修改文件 “/var/opt/gitlab/gitlab-rails/etc/gitlab.yml”

修改成如下的样子就好了哦。

  ## GitLab settings
  gitlab:
    ## Web server settings (note: host is the FQDN, do not include http://)
    host: gitlab.ops.ac.cn
    port: 80
    https: false
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

Read More

mongoengine 更新

Read full article  | 评论关闭

mongoengine 更新

collection.update({‘userid’:int(float(item))},{‘$set’:{‘status’:1}},upsert=False,multi=True)

有兴趣可以研究一下update的四个参数:

第一个为匹配

第二个为条件(条件上可以大作文章),

第三个为没找到是否插入,

第四个为是否支持多操作

Read More

django view太大,切分到不同的目录

Read full article  | 评论关闭

(新增目录下面一定得有__init__.py,    方法1,需要修改__init__.py,  方法2可以将__init__.py 保持为空)

备注:view 子目录引用model, 可用 from app_name.models import * 方式引用, 记得加上 app_name

方法1:

Remove the views.py file and create a directory named views. Add a __init__.py file inside it and create the separated view files.

|∙∙core/
  |∙∙__init__.py
  |∙∙admin.py
  |∙∙migrations/
  |∙∙models.py
  |∙∙tests.py
  |∙∙urls.py
  |∙∙views/
    |∙∙__init__.py
    |∙∙alpha.py
    |∙∙beta.py

views/__init__.py

This is an important step: import all the modules inside each view file.

from .alpha import *
from .beta import *

views/alpha.py

from django.shortcuts import render

def view_a(request):
    return render(request, 'view_a.html')

def view_b(request):
    return render(request, 'view_b.html')

views/beta.py

from django.shortcuts import render

def view_c(request):
    return render(request, 'view_c.html')

def view_d(request):
    return render(request, 'view_d.html')

urls.py

You don’t need to change anything here.

from django.conf.urls import url
import .views

urlpatterns = [
    url(r'^aaa$', views.view_a, name='view_a'),
    url(r'^bbb$', views.view_b, name='view_b'),
    url(r'^ccc$', views.view_c, name='view_c'),
    url(r'^ddd$', views.view_d, name='view_d'),
]

方法2:

Remove the views.py file and create a directory named views. Add a __init__.py file inside it and create the separated view files.

|∙∙core/
  |∙∙__init__.py
  |∙∙admin.py
  |∙∙migrations/
  |∙∙models.py
  |∙∙tests.py
  |∙∙urls.py
  |∙∙views/
    |∙∙__init__.py
    |∙∙alpha.py
    |∙∙beta.py

views/alpha.py

from django.shortcuts import render

def view_a(request):
    return render(request, 'view_a.html')

def view_b(request):
    return render(request, 'view_b.html')

views/beta.py

from django.shortcuts import render

def view_c(request):
    return render(request, 'view_c.html')

def view_d(request):
    return render(request, 'view_d.html')

urls.py

You don’t need to change anything here.

from django.conf.urls import url
import .views

urlpatterns = [
    url(r'^aaa$', views.view_a, name='view_a'),
    url(r'^bbb$', views.view_b, name='view_b'),
    url(r'^ccc$', views.view_c, name='view_c'),
    url(r'^ddd$', views.view_d, name='view_d'),
]



Read More