Janus's Blog

Free to look around


  • Home

  • Categories

  • Archives

  • Tags

  • Search

Cpanel Composer

Posted on 2017-03-23 | In cPanel | | Visitors

cPanel suhosin issue

If you use cpanel and suhosin, you might get error as

1
2
3
The suhosin.executor.include.whitelist setting is incorrect.
Add the following to the end of your `php.ini` or suhosin.ini (Example path [for Debian]: /etc/php5/cli/conf.d/suhosin.ini):
suhosin.executor.include.whitelist = phar

You have two options to solve it, one is update php.ini file if you have the permission, the other one is add -d option as php -d suhosin.executor.include.whitelist=phar every time you need composer.

Steps

The following code will do the work on 2nd method

1
2
3
4
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php -d suhosin.executor.include.whitelist=phar composer-setup.php
php -r "unlink('composer-setup.php');"

Then you can start enjoy composer

1
php -d suhosin.executor.include.whitelist=phar /path/to/composer.phar install

Prevent HTML5 Video Seeking

Posted on 2017-03-21 | | Visitors

Problem on IOS

If you don't want user skip part of video on HTML web page, you probably want disable controls on Video tag. However, on IOS, even you disable it, QuickPlay will still shows progress bar. Following code demonstrate how to do it.

Read more »

SSH Auto

Posted on 2017-03-11 | | Visitors

Pick SSH from your list

Check out my repository, ssh-auto

Wget & SFTP Examples

Posted on 2017-03-01 | | Visitors

Story

My company needs grab files from 3rd party servers daily and only today’s file. Here are useful snippets of FTP and SFTP.

Wget From FTP

If you need wget download specific file from another server, there is accept list argument -A that helps us filter today’s file.

1
2
today=$(date +"%Y-%m-%d")
wget --user='ROOT' --password='PWD' -r --no-parent -A "File $today*" ftp://ftp.server.com/ -O ./destination.csv

SFTP

For SFTP, once you have public key installed on their server, you can do the following

1
2
3
4
5
today=$(date +"%Y-%m-%d")
sftp name@server.com <<EOF
get *$today* destination.csv // name the file as destination.csv
quit
EOF

CasperJS and Parallel

Posted on 2017-02-11 | In CasperJS | | Visitors

Trouble on CasperJS

One of the project we need use CasperJS to navigates dozens URLs, evaluate hundreds lines of javascript in that page then submit the form, sounds crazy right?!

Read more »

Apache SSH

Posted on 2017-01-21 | In Apache | | Visitors

Test SSH under Apache role

If you need PHP to process bash script, and it need SSH to another server process something else. Example PHP snippet: $bash = shell_exec('bash ./example.sh');.

Because PHP running under Apache, so Apache needs SSH to correct server. However, Ubuntu prevent su apache for obvious security reason, but you still able to change it.

1
sudo vim /etc/passwd

After find role Apache, change /sbin/nologin to /bin/login. Now you can do su apache.

Under Apache role, test your SSH host, you need add host to your trust list for first time. You probably want create ssh_config file under /var/www/.

Don’t forget update Apache to /sbin/nologin after it.

PHP & MSSQL

Posted on 2016-12-11 | | Visitors

Using MSSQL On PHP7

Recently, one of my clients needs pull data from one of his new provider, unexpectedly, this new provider use MSSQL, however, we upgraded from php5.6 to php7, the old mssql_connect function is being removed at php7, read more here, we need another solution for it.

Read more »

Homestead Auto Add New Site

Posted on 2016-11-15 | | Visitors

Add New Site To Homestead

If you using Homestead as your development environment, you should know how to add a new site manually. But I find it a little bit annoying that you have type same commands every time. I started search around and try to find any bash script can do same thing for me in one command, I found this in Github, someone has created nice bash script can do pretty much everything, but it really out-of-date, so I cloned the repo and update a little bit here

Catch

You need update configuration at top of bash script.

Hexo Server Auto Restart

Posted on 2016-10-19 | In Hexo | | Visitors

Introduce Hexo Auto Restart

Hexo is a great blog platform, the article you are looking right now is written on top of Hexo. If you tired manually to Ctrl + c start and restart server, you probably want two console window, one runs hexo server -s, -s means only serve static html files, which located at public/ folder, and the other one runs hexo generate --watch, it’s builtin command to watch file updates and auto generate new static files. Start those two commands, refresh your browser and you should see the new updates.

Problem With Watch in VagrantBox

I personally had pretty much all developing projects running in the vagrant box, the problem of hexo generate --watch seems like doesn’t corporate with vagrant box, so the Nodemon comes into the game.

Install Nodemon

I prefer install Nodemon globally, [sudo] npm install -g nodemon, but if you don’t like it, just do npm install nodemon

Magic Command

Command: nodemon -e html,md,less --ignore public/ -L --exec 'hexo generate', The Nodemon will start watching file updates and automatically runs hexo generate

Short explanation:

  • -e is adding the specific extension to Nodemon watch list, nodemon default looks for files with .js, .coffee, .litcoffee and .json, on this example, Nodemon will watch .html, .md. Add whatever extensions you want.
  • -L is only required if you running your developing environment on virtual machine, such as Vagrant, VirtualBox.
  • --ignore public/ is important, otherwise, once you generated new static files, Nodemon will detect updates in public folder and start generate again, infinite loop…
  • --exec 'hexo generate' is the main command let Nodemon knows how suppose it to execute the program, inside hexo server, you can change it to whatever you currently using, for more information, check at Hexo Server

Finally

On production, you could consider to use forever to start Hexo daemon, the command I use is

1
forever start --uid blog --append -c 'hexo server -s -p 80' ./

After you get new blog and pull from upstream, run hexo generate and your blog should get updated.

Youtube video snapshot with play button

Posted on 2016-10-11 | | Visitors

Why I created this tool

Recently, one of my clients ask me to put their newest marketing video snapshot with play button into the new email campaign. Obviously, if I'm the designer, I would just use Photoshop, but I'm not... So I made a tool myself.

Read more »
12
Janus Zhou

Janus Zhou

11 posts
4 categories
22 tags
RSS
Github LinkedIn
© 2016 - 2017 Janus Zhou
Powered by Hexo
Theme - NexT.Pisces