2017年2月

树莓派ubuntu mate开启root自动登录

如果lightdm.conf文件存在

可编辑/etc/lightdm/目录下的lightdm.conf文件,如没有此文件,直接创建

  1. [SeatDefaults]
  2. autologin-user=root
  3. user-session=meta
  4. greeter-show-manual-login=true

注意:如果有lightdm.conf就不需要步骤2了
2、如果lightdm.conf文件不存在

在terminal下输入

  1. sudo gedit /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf

内容如下:

  1. [SeatDefaults]
  2. autologin-user=root
  3. user-session=ubuntu
  4. greeter-show-manual-login=true

4、在terminal下输入

  1. gedit /root/.profile

将文件末尾的 “mesg n”,修改为 “tty -s && mesg n”。

注意:如果这里不修改,登录会提示如下信息:

Error found when loading /root/.profile

stdin:is not a tty
5.用reboot命令重启即可

ngrok使用TCP指定远程端口

对于需要使用Ngrok指定远程端口写法比较麻烦,对格式缩进也比较严格,指定远程端口为remote_port,使用Tunnel方式启动,

以下为格式模板:

 

server_addr: "tunnel.qydev.com:4443"
trust_host_root_certs: false
tunnels:

              web:
                  subdomain: web
                  proto:
                            http: 80
              ssh:
                  remote_port: 6666
                  proto:
                            tcp: 22

需要注意的是,指定端口的前面是有一个空格

YII跨表查询多对多,$criteria->together = true的使用

例:
当C>B多对一的关系,B>A多对一的关系,当A关联到C的时候使用:
A:"feedbackRecords"=>array(self::HAS_MANY,"wkeFeedbackRecord","fdFeedbackID"),
B:"recordTypeMap"=>array(self::HAS_MANY,"wkeFeedbackTypeMap","fdFeedbackRecordID"),
$with[]="feedbackRecords.recordTypeMap";
$c->compare("recordTypeMap.fdTypeID", $args['typeMap']);
$c->together=true;

django 有model生成SQL以及现有反向表生成model

已有models生成SQL语句
语法 python manage.py sqlall app_name   # app_name, 在settings已经导入,
如:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
"apps.libs.models.weixin",
)
有现有表反向生成models
语法 python manage.py inspectdb  --database db1

Django自定义表别名

使用Django  Model类生成的数据表带有表前缀,或者引用数据库原本存在不带前缀表会无法识别,解决办法为在Model类下自定义表别名。

 

例如:
class tables(models.Model):
          name = models.CharField()
          class Meta:
                   db_table = 'tables'