Docker with wordpress

UPDATE (2018-05-11):

Our team at LodeStream has built a scaffold specifically for Wordpress development. You can check it out today and start play with it. Out of the box, it supports:

  • Docker, Docker Compose
  • Let’s encrypt HTTPS
  • Nginx as a reverse proxy with auto generated config
  • Simplified domain configuration
  • More information in the repo

Github repo: lodestreams/wordpress-docker-compose


The original post:

Install Docker on a Ubuntu:

Docker installation guide: https://docs.docker.com/engine/installation/linux/ubuntulinux/

If you don’t know about datastore yet, refer to: https://getcarina.com/docs/best-practices/docker-best-practices-data-stateful-applications/

  • sudo docker create -v "$PWD":/var/lib/mysql --name dbstore mysql
  • sudo docker create -v "$PWD":/var/www/html --name htmlstore php
  • sudo docker run --name mysql -e MYSQL_ROOT_PASSWORD=password --volumes-from=dbstore -dp 3306:3306 mysql
  • git clone https://github.com/youdarnet/wordpress.git
  • sudo docker run -d --name wordpress --link mysql:mysql --volumes-from=htmlstore -p 80:80 youdar/wordpress
  • sudo docker run -d --link mysql:mysql -e MYSQL_USERNAME=root --name phpmyadmin -p 3307:80 corbinu/docker-phpmyadmin

Notes:

添加新的 Wordpress 网站:

使用现有的 MySQL 数据库。

  • sudo docker create -v "$PWD":/var/www/html --name wordpressNameStore php
  • sudo docker run -d --name wordpressName --link mysql:mysql --volumes-from=htmlstore -p 800x:80 youdar/wordpress

其它提示

  • Remove dangling volumes: sudo docker volume ls -f dangling=true | awk 'FNR > 1 {print $2}' | xargs sudo docker volume rm
  • Run a nginx at current dir: sudo docker run -it --rm -v "$PWD":/usr/share/nginx/html -p 8081:80 nginx

  • sudo docker inspect --format="" nginx | json_pp

Read More

Webpage screenshot has been automatically removed!

UPDATE (2016-02-10):

I’ve found there is still a record in ~/Library/Application\ Support/Google/Chrome/Default/Preferences and deleted it, see if it works.


For those of you who suffering from the malicious Chrome plug-in called Webpage screenshot always saying it’s removed automatically…

Try this:

1
2
3
4
5
6
7
8
9
# Fire a commandline up, and go to your Chrome directory
cd ~/Library/Application\ Support/Google/Chrome

# Searching for it
find . -iname 'Webpage Screenshot'

# find out the directory and remove it, in my case:
cd Default/Extensions
rm -rf ckibcdccnfeookdmbahgiakhnjcddpki

If it does the job, then congrats, if not, post your idea below :)

Ideas come to my mind:

  • grep -r 'Webpage Screenshot' .
  • grep -r 'ckibcdccnfeookdmbahgiakhnjcddpki' .

Mongoose notes

Custom getters

Use custom getters to process the MongoDB retunred data, like an interceptor.

Schema custom getters doesn’t work with lean().

Set up the Schema:

1
2
DBSchema.set('toObject', {getters: true, virtuals: true});
DBSchema.set('toJSON', {getters: true, virtuals: true});

Add custom get function on specified field:

1
2
3
4
5
6
7
8
DBSchema.path('images').get(function (images) {
if (images && Array.isArray(images) && images.length > 0) {
images = images.map(function (image) {
return getUrl(image);
});
}
return images;
});

Read More

JavaScript OO

ONE script to understand JavaScript OO :-)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function MyClass () { // constructor function
var privateVariable = "foo"; // Private variable

this.publicVariable = "bar"; // Public variable

this.privilegedMethod = function () { // Public Method
alert(privateVariable);
};
}

// Instance method will be available to all instance but only load once in memory
MyClass.prototype.publicMethod = function () {
alert(this.publicVariable);
};

// Static variable shared by all instance
MyClass.staticProperty = "baz";

//...
var myInstance = new MyClass();

Clipped from StackOverflow: http://stackoverflow.com/a/1535687/1904043

fonts.rankun.org

搭建一个在国内外都可以访问的 Google Fonts 代理

Google fonts is blocked in China.

– by Google Fonts Unstable in China – Here is How to Fix It

Yah, we all know that. But the general solution for this is awkward to me, Because after I switched the fonts location to http://fonts.useso.com, I can open my blog very quickly inside China, where the useso(360™) located. When I was trying to access it from the outside of China, both Japanese and West American are slow, over 5 seconds to download a 800 Bytes file, That’s unbearable.

Then I tried to use Qiniu as a CDN to cache fonts.googleapi.com, then I realized it’s blocked anyway. Afterwards, I use the CDN to cache fonts.useso.com, still doesn’t work at all, it persist showing me this:

1
2
3
{
error: "get from image source failed: E400"
}

Read More

Bitcoin playground

使用 Blockchain 的服务进行比特币交易

Use blockchain bitcoin service to transfer bitcoins

Wallet api

1
2
3
4
5
6
7
8
https://blockchain.info/merchant/$guid/payment
?password=$main_password
&second_password=$second_password
&to=$address
&amount=$amount
&from=$from
&fee=$fee
&note=$note

Request tips:

The My Wallet API provides a simple interface Merchants can use interact with their wallet. Blockchain.info will decrypt the wallet on our server manipulate it as necessary and re-save. HTTP GET and POST are supported. However, if a POST request is sent without “Content-Type: application/x-www-form-urlencoded” header, some endpoints may not work correctly.

Read More

Colnect Finding Marketing Guy In China

大!!!家,Colnect.com决定要来国内开展业务了。

##colnect.com

网站概况:colnect.com是一家面向收藏家的网站,colnect即collectors connection / connect collectors,意在连接收藏家,做收藏家的好帮手。网站现在已经有来自221个国家的7万8千余名注册收藏家。

网站功能:收藏品目录运作方式与百度百科类似,每一类收藏品都包含很多具体的收藏品。可以浏览及分享收藏品,注册用户可以标注为自己拥有这个收藏品、有而且可供交换、希望拥有等。用户也可以发起请求添加colnect还没有收录的收藏品,如果你有很多收藏品,将它们全部记录在colnect网站上将会给你的收藏品管理浏览及交易带来极大的方便。

招聘!!:网站推广人员,专门寻找国内的潜在用户。

Read More