Setup NextCloud with Docker

之前配置过一次 NextCloud,本地操作搭mysql和nginx既麻烦又不好维护。后来docker用得多一些了之后,觉得这种部署应该是由docker来支持的,找了一下确实有现成的解决方案,记录一下在这里。

简单说一下,NextCloud是本地云平台,通俗的说就是可以在自家的机器上配一套某度网盘 🙂
然后家里每个人的手机、平板、笔记本都可以访问。我们家的需求主要是共享和备份照片,共享大批量的陈年老照片,备份最近手机上拍的照片。

先clone一下这个repo:

git clone https://github.com/christophetd/nextcloud-docker-compose

按照需要,编辑docker-compose.yml 把自动备份相关的注释掉,就是 backups 下面的部分都可以删掉

编辑.env

 vim .env 

修改DATA_DIR指向自家云的存储位置,HOST到机器的IP (比如 192.168.0.123)

然后

docker-compose up -d

应该就可以了
如果没有 docker-compose 需要先安装:

 
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose 
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose 

然后打开浏览器访问 http://192.168.0.123 就设置帐号密码就可以用了。

看起来和某度网盘差不多。

可以尝试传一个文件上去,系统就会创建用户的文件夹了。具体的数据位置在 ${DATA_DIR}/data/${USERNAME}/files/ 下面。

到此基本上就可以用了,但是实际上大家都会面临的问题是怎么样把之前的数据迁移进去云里面。NextCloud的iOS/Andriod App都有很好的支持手机上传的支持,但是PC上总不能网页上一张一张照片的传。实际上是有工具可以做这个事情的。

我们可以把之前的数据,本地复制到NextCloud放数据的目录下,然后用NextCloud提供的命令行工具自动扫描更新到MySQL就好了。

 sudo rsync -zvrP /path/to/old/data ${DATA_DIR}/data/${USERNAME}/files/ 

之后要进到运行的docker container里面做操作:

 sudo docker ps 

列出来在跑的containers,找到 nextcloud 对应的 container ID,然后

 sudo docker exec -ti ${CONTAINER_ID} bash 

就到了container的环境里。

接下来要先安装sudo

 apt-get update && apt-get install -y sudo 

修正文件权限

 sudo chown -R www-data:www-data data/${USERNAME}/files/ 

重新扫描

 sudo -u www-data php occ files:scan --all 

文件多的话会比较慢,但是等着就好了。

用起来还是挺方便的,维护和部署也没有什么特别的操作。用Docker还是方便,希望Docker公司自己可以找到盈利点别挂了。

How to contact USCIS and what to expect

For any foreigner in the US, when it comes to immigration related issues, there are always a lot of stories to tell. My recent story is about renewing my EAD (work authorization in the US) card.

After I sent out my renewal application, I have tried multiple methods to contact USCIS and would like share the experience here. My case is a little special that what I need to get legitimate work authorization again is simply the receipt notice from USCIS that my application is accepted to be processed. Usually it only takes 2 weeks for one to receive this letter in mail. Sometimes it doubles.

The application was sent to Lockbox and the official in-take process can be found here. The official website has listed a number of tools to submit all kinds of requests. But before having the receipt letter with a receipt number, most of them are not applicable.

  1. First thing you can try is to email the local Lockbox office at lockboxsupport@uscis.dhs.gov. It takes a few days (e.g. 17 days in my case) to get the reply. But the local office should have the first-hand information about the thing I’ve submit. If they couldn’t find your application at all, I would assume the application is lost. In the end, I firstly get my receipt number from the kind officer through this email address.
  2. Second thing you can try is to call USCIS contact center. Trying to schedule an info-pass or appointment through the answering system could eventually lead you to live representative. The waiting time is usually around 30~60mins in my prior trials. When the representative couldn’t answer my question, I learned that I can ask to escalate the case to a tier-2 representative or officer. It is always better to make the phone call in the morning since the tier-2 representatives/officers do not take calls in the late afternoon. I found the officers are usually efficient and processional with access to more information.  In my case,  when other representatives could not tell me whether or not my receipt letter has been mailed to me, the officer told me that it was mailed out with an accurate mailed-out date.
  3. The last thing I tried is to contact my senator for help. Their contact can always be easily found and their application process is clearly described on their webpages. I provided the nice senator everything I have regarding the case. They actively asked for the things they need. I am not clear how they would contact USCIS. In the end, I didn’t hear back updates regarding my case.

It is always unpredictable when the Immigration documents would get processed and it is a bitter ordeal to one’s patience. Hope these help in relieving your anxiety.

[读书笔记] How to Write a Lot: A Practical Guide to Productive Academic Writing

最近读了这本书 How to Write a Lot: A Practical Guide to Productive Academic Writing书很短,作者很幽默,所以也很容易读。这本书主要讨论如何能够高产的写作。提出的方法很简单,核心的信息就是 “Instead of finding time to write, allot time to write. Prolific writers make a schedule and stick to it.”。他不谈怎样激发你的兴趣,怎样找到适合自己的写作方法。相反,作者对这类方法都进行了毫不留情的吐槽。书中的观点是,正确的高产写作方法只有一个,定下一个固定的写作时间,每天坚持写。作者还针对大家常用的逃避写作的借口进行了批判。总的来说,感觉作者挺毒舌的,哈哈。

比如,很多人会说自己找不到合适的时间写作。作者的回应是 “Instead of finding time to write, allot time to write… you write during your allotted times and then forget about it.”。很多人也喜欢说自己找不到大块时间写作所以总是没有产出,“the simple fact of sitting down to write day after day is what makes writers productive”。

有的人喜欢说自己没有写很多东西,是因为总是学术写作会需要做很多准备工作,比如我们写文章之前需要看一些相关文章,准备一些图表。作者的方法是把这些准备工作发放在固定的写作时间里去做,否则 “Binge writers are also binge readers and binge statisticians. The bad habits that keep them from writing also keep them from doing the prewriting (Kellogg, 1994), the reading, outlining, idea generation, and data analysis necessary for generating text” 。

 

总之,最有效的方法,就是坚持固定时间写作。这样不会让你喜欢上写作,但是会让你完成更多的写作任务。如作者所说 “Some kinds of writing are so unpleasant that no normal person will ever feel like doing them. What kind of person feels enthusiastic about writing a grant proposal?”。 🙂