博文

目前显示的是 2017的博文

Why cannot mysqld be found?

In some LAMP server, you may be confused that mysqld service cannot be found. For example, when using the command: > sudo service msyqld restart It just failed and said something like mysqld.service didn't exist. When this happens, please try: >sudo service  mariadb restart Hope this will help.

Trap on the way to use a browserified react script - Invariant Violation: Target container is not a DOM element.

When using a script browserified from a react project, I encountered an error said: Invariant Violation: Target container is not a DOM element. It confused me for a while. After I moved the HTML script label from head to the end of the body , the problem was solved. It seems that when the script was executed, the related dom element had not been loaded yet. Then I tried ready function from jQuery, it also works. So when get this kind of error, try to check the position of the script.

Cheat sheet: Ubuntu 16.04 + NodeJS + React + Grunt + Babel + Browserify Configuration

1. Install NodeJS >sudo apt-get install nodejs nodejs-legacy 2. Create a project using npm >npm init 3. Install React >npm install --save react react-dom 4. Install Babel and plugins > npm install --save-dev grunt-babel > npm install babel-preset-env --save-dev > npm install --save-dev babel-plugin-syntax-jsx The last command line is for JSX which is highly recommended by React. 5.Config .babelrc { "plugins": ["syntax-jsx"], "presets": [ ["env", { "targets": { "chrome": 52, "browsers": ["last 2 versions", "safari 7"] } }] ] } 6.Install Grunt and plugins >npm install -g grunt-cli >npm install grunt --save-dev >npm install grunt-contrib-jshint --save-dev 7. Config Grunt file module.exports = function(grunt) { // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON('package.j

Use proxy chains to access socks proxy in command line in 3 steps - Linux

Step 1. Install sudo apt-get install proxychains Step 2. Config port sudo vim /etc/proxychains.conf Step 3. Usage proxychains <your command>

MongoDB study note (2): security configurations - Setup username and password, Bind interface and Iptables (on Ubuntu 16.04/mongoDB 3.4)

Setting up username and password First, check your /etc/mongod.conf to confirm it is not in the auth mode. Add comment symbol '#' of the following code and restart mongod service: #security:   #authorization: enabled sudo service mongod restart Then, Connect to local mongodb: mongo --port 27017 Switch to admin database: use admin Create admin user: db.createUser({ user: "admin", pwd: "<your password>", roles: [{ role: "userAdminAnyDatabase", db: "admin" }] }) Grant Roles: db.grantRolesToUser('admin',[{ role: "root", db: "admin" }]) Check if successfully added (should return 1): db.auth("admin", "<your password>") Exit mongo client: exit Enable the auth mode in your /etc/mongod.conf by activating the following lines and then restart the service: security:   authorization: enabled sudo service mongod restart Go back to

MongoDB study note (1): Installation and Run (on Ubuntu 16.04/MongoDB 3.4)

Installation Command list: (Ubuntu 16.04 for example. Other systems please refer to https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/) sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6 echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list sudo apt-get update sudo apt-get install -y mongodb-org Run Command list: sudo service mongod start

Special effects for html using JS and CSS

This page may not work because the restriction of the Blog theme. Please use your browser to inspect the code. Thank you! Magic Letterfall Mad Rotating Letters Mad Scaling Letters

How to deal with the ERROR: D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open “/var/lib/dbus/machine-id”

After I deployed the scrapy-splash, I ran my spider and encountered an ERROR: D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open “/var/lib/dbus/machine-id” It seemed that no affection to the results but really annoying. After I tried a few solutions from Google, finally I solved it with this command: dbus-uuidgen > /var/lib/dbus/machine-id Good Luck!

Symbols in the version field of package.json

You may have seen something like the following code before in package.json and may be puzzled about the symbols like '<>~^'. Code: { "dependencies" : { "foo" : "1.0.0 - 2.9999.9999" , "bar" : ">=1.0.2 <2.1.2" , "baz" : ">1.0.2 <=2.3.4" , "boo" : "2.0.1" , "qux" : "<1.0.0 || >=2.3.1 <2.4.5 || >=2.5.2 <3.0.0" , "asd" : "http://asdf.com/asdf.tar.gz" , "til" : "~1.2" , "elf" : "~1.2.3" , "two" : "2.x" , "thr" : "3.3.x" , "lat" : "latest" , "dyl" : "file:../dyl" } } Here are the definitions I found in https://docs.npmjs.com/files/package.json . version  Must match  version  exactly >version  Must be greater than  version >=version  etc <version <=versi

Using Haproxy + shadowsocks (ha + ss) to setup multi ss backend and load balance

*Install haproxy > sudo apt-get install haproxy *Configure haproxy >vim /etc/haproxy/haproxy.cfg global     ulimit-n 51200     log /dev/log local0     log /dev/log local1 notice     chroot /var/lib/haproxy     pidfile /var/run/haproxy.pid     user haproxy     group haproxy     daemon defaults     log global     mode tcp     option dontlognull     timeout connect 5000       timeout client 50000     timeout server 50000 frontend ss-in     mode tcp       bind $Your_IP:8002     default_backend shadowsocks backend shadowsocks     mode tcp       balance roundrobin         server ss1 $Your_SS_IP1:$Your_SS_PORT1 maxconn 20480         server ss2 $Your_SS_IP2:$Your_SS_PORT2 maxconn 20480 --The haproxy only allows the remote ss servers with the same password. As here haproxy is only providing the function like a load balancing switch. It's like a multi channel valve which does NOT provide any shadowsocks protocol level function

Setup shadowsocks in Ubuntu 16.04 server [client & server]

1.  Setup Server *Install shadowsocks > apt-get install shadowsocks *Configure config file in /etc/shadowsocks/config.json {     "server":"Your server ip",     "server_port":your server port,     "local_address": "127.0.0.1",     "local_port":1080,     "password":"You Password",     "timeout":300,     "method":"aes-256-cfb",     "fast_open": false,     "workers": 1 } *Restart service > sudo /etc/init.d/shadowsocks restart 2. Setup Client *Install shadowsocks client >sudo apt-get install python-pip >sudo pip install shadowsocks *Create config file in /etc/shadowsocks.conf.json {     "server":"Your server ip",     "server_port":your server port,     "local_address":"your local ip",     "local_port":your local port,     "pas

[WordPress]What the F***! the parent theme is missing?!

There is a very wired problem. I created a child theme named Fatsom Child and I set 'Template: Fatsom' in style.css and the parent theme is Fatsom which had been already installed. It worked perfectly in my local environment. The child theme could be successfully detected by WordPress and activated manually. But, when I uploaded the parent theme and child theme to  my host, a very strange thing happened: In my backend, WordPress threw an error saying "the parent theme 'Fatsom' is missing"! And I could not find 'Fatsom Child' to activate! Why! I was blocked by this problem the whole evening. Finally, I found the solution -- just change 'Template: Fatsom' to 'Template: fatsom' in style.css of the child theme and it works again! I couldn't tell why, but it just happened. If you knows why or encountered the same problem, please comment this blog or email me (wagner@joybin.cn). Have a good day!

[WordPress]Oops, customized query vars make front page missing

There is a very strange thing which may be a bug but not fixed yet in WordPress -- If you add a customized query var, it will make the WordPress lost the static front page and directly point to the post river. (As discussed in https://core.trac.wordpress.org/ticket/25143#comment:36 ) For example, if our static front page is http://www.example.com/ and we add following code to add a query var named 'lang' hoping that we could get 'lang' from the structure of http://www.example.com/%lang% function add_custom_page_variables ( $ public_query_vars ) {         $ public_query_vars [] = ' lang ';         return $ public_query_vars ;     } add_filter ( ' query_vars ', array ( $ this , ' add_custom_page_variables ' ) ) ; It doesn't work. get_query_var will return null and what is worse, the front page will lost if we use http://www.example.com/en. Actually, current parse_query will check $_query after it thinks it is a home pa

[WordPress] About the URL autocompletion function in WordPress

There is an unimpressive URL autocompletion function in WordPress which a lot of the users or developers may not know. This function can find the most similar URL even if the URL input is not exactly right. For example: there is a permalink http://www.example.com/testpost If you mistakenly input http://www.example.com/testp, the WordPress can still help you find the testpost. This sounds nice. But it can cause some problems. For example, I want to add a rewrite rule to make http://www.example.com/en point to http://www.example.com/?lang=en. This autocompletion function will still try to find something similar to 'en' instead of giving me the page of http://www.example.com directly. So we have to turn off this function. Here is the solution: add_action ( ' redirect_canonical ', ' __return_false ' ) ; After adding this action, this autocompletion function will be turned off and the rewrite rules will successfully work.

[WordPress API] About the 'count' field of get_terms function

get_terms is a very common function in WordPress. Here is the definition: get_terms(  array|string   $args  =  array() ,   array   $deprecated  =  ''  ) For example: $res = get_terms(term->taxonomy, array('parent' => term->id, 'hide_empty' => false)); var_dump($res); The WordPress will print something like this: array (size=5) 0 => object ( WP_Term )[ 4319 ] public 'term_id' => int 15 public 'name' => string 'Copenhagen S' (length=12) public 'slug' => string 'copenhagen-s' (length=12) public 'term_group' => int 0 public 'term_taxonomy_id' => int 15 public 'taxonomy' => string 'property_city' (length=13) public 'description' => string '' (length=0) public 'parent' => int 37 public 'count' => int 3 public