276篇 Default中的文章

Git: remove untracked files

To remove directories, run
git clean -f -d or git clean -fd

To remove ignored files, run
git clean -f -X or git clean -fX

To remove ignored and non-ignored files, run
git clean -f -x or git clean -fx

More ~

mysql delete foreign key

Check what's the CONSTRAINT name and the FOREIGN KEY name:

SHOW CREATE TABLE table_name;

Remove both the CONSTRAINT name and the FOREIGN KEY name:

ALTER TABLE table_name
  DROP FOREIGN KEY the_name_after_CONSTRAINT,
  DROP KEY the_name_after_FOREIGN_KEY;

Or simply run this if you know the foreign key name:

alter table footable drop foreign key fooconstraint

原文:https://stackoverflow.com/questions/838354/mysql-removing-some-foreign-keys

More ~

No changes detected while running python manage.py makemigrations

Issues:

I want to recreate the migrations, so I deleted files under migrations folder, and drop the database. And try this python manage.py makemigrations, it reponse No changes detected.

Fix:

Create the database again, and clear files and folders under migrations, then try the following:

  1. python manage.py makemigrations --empty appname
  2. python manage.py makemigrations
  3. python manage.py migrate

It works!

More ~

ld: library not found for -lssl - Install mysqlclient for Django 2, macos

Background

mysql server was installed by brew install mysql

Issues like this:

ERROR: Failed building wheel for mysqlclient

ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1

Exception: Wrong MySQL configuration: maybe https://bugs.mysql.com/bug.php?id=86971 ?

More ~

也谈华为鸿蒙系统 - Thinks About Huawei Hongmeng

linux_android_huawei.jpg

自从华为被ARM和Android"封锁令"一系列负面消息来袭之后,关于华为的鸿蒙系统新闻层出不穷。
另据国家知识产权局商标查询显示,华为今年5月份和6月份申请了商标名称为"鸿蒙"的多个类目商标。这个时间前后也有许多公司和个人开始抢注"鸿蒙"为关键字的不同类目的商标。
其实按照以往的营销策略,一开始大V如华为高管在微博散布消息,之后开始让媒体热炒,再加上用户的跟风等一系列炒作之后,基本上就可以看到具体上线时间了。不过对于研发一款多平台支持的OS来说并不是易事。

More ~

Django root url point to app root

In the Django's tutorial, I created an app name front, and its urls.py definition like this:

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('front/', include('front.urls')),
    path('admin/', admin.site.urls),
]

So, if the app's url in web browser is http://127.0.0.1:8000/front/
In fact, most website the home page won't have subdirectory. So, the solutions is here:

from django.contrib import admin
from django.urls import path, include, re_path

urlpatterns = [
    re_path(r'^', include('front.urls')),
    path('front/', include('front.urls')),
    path('admin/', admin.site.urls),
]

Now, you can visit the app root url in the home page. http://127.0.0.1:8000/

More ~

rsync 用法

sync命令是一个远程数据同步工具,可通过LAN/WAN快速同步多台主机间的文件。rsync使用所谓的“rsync算法”来使本地和远程两个主机之间的文件达到同步,这个算法只传送两个文件的不同部分,而不是每次都整份传送,因此速度相当快。 rsync是一个功能非常强大的工具,其命令也有很多功能特色选项,我们下面就对它的选项一一进行分析说明。

rsync [OPTION]... SRC DEST
rsync [OPTION]... SRC [USER@]host:DEST
rsync [OPTION]... [USER@]HOST:SRC DEST
rsync [OPTION]... [USER@]HOST::SRC DEST
rsync [OPTION]... SRC [USER@]HOST::DEST
rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]
More ~