熱門文章

2017年2月24日 星期五

修正avid theme 手機瀏覽時的slider大小

theme options -> custom CSS

@media only screen and (max-width: 640px) {
#sliders-container .fusion-slider-container,
#sliders-container .fusion-slider-container .tfs-slider,
#sliders-container .fusion-slider-container .tfs-slider .background {
    height: 250px !important;
}
}
}

調整高度為250px

2017年2月20日 星期一

常見的 Ruby on Rails 工程師面試問題

常見的 Ruby on Rails 工程師面試問題

收錄一些業界常見/常問的面試問題和翻譯解答

解答不見得完整和精確,但在面試的環境下回答應該是足夠的

有需要改正或有什麼要新增 / 補充的地方也請大家發 PR

開始閱讀

2017年2月10日 星期五

免密碼 SSH Key 登入 ssh server

每次使用ssh 登入vps 都需要輸入那個又臭又長的密碼
後來找到使用公私鑰的方式來達成免密碼登入ssh


首先建立SSH Key

$ ssh-keygen -t rsa

➜  .ssh git:(master) ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/***/.ssh/id_rsa): 
/Users/***/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/QJpioneer/.ssh/id_rsa.
Your public key has been saved in /Users/QJpioneer/.ssh/id_rsa.pub.


步驟是 enter enter enter ,但因為我原本就有了所以多一個 enter y enter enter

按下enter預設會在你的家目錄底下的 .ssh 產生 id_rsa 與 id_rsa.pub
因為我原本就有ssh key 所以多一個是否覆蓋的選項(因為忘記密碼...)
怕忘記密碼所以就不設passphrase了


Mac 上可以安裝一個方便的程式來幫你設定好遠端的ssh

brew install ssh-copy-id

➜  .ssh git:(master) ssh-copy-id root@****.com
/usr/local/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/Users/****/.ssh/id_rsa.pub"
/usr/local/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/local/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys

root@****.com's password: 

在這邊輸入一次的ssh server的密碼後之後就不用再輸入了,好方便啊


Number of key(s) added:        1

Now try logging into the machine, with:   "ssh 'root@qjpioneer.com'"
and check to make sure that only the key(s) you wanted were added.



#1組key增加
#現在請輸入 "ssh 'root@qjpioneer.com'" 登入server !!!


參考 http://ephrain.pixnet.net/blog/post/58483708-%5Blinux%5D-產生-ssh-key-來免密碼登入-ssh-server

PS. 如果你跟我一樣以前有ssh key 卻忘記密碼可以偷過這個找回來:https://help.github.com/articles/recovering-your-ssh-key-passphrase/



2017年2月8日 星期三

刷紅包爆款操作

https://www.inside.com.tw/2017/02/09/porn-wechat-china

VPS 初體驗

使用VPN 登入,最受不了的就是密碼太長...

Mac terminal

ping  
traceroute 查路由節點


➜  d-copy git:(master traceroute 198.12.88.***
traceroute to 198.12.88.*** (198.12.88.***), 64 hops max, 52 byte packets
 1  192.168.1.2 (192.168.1.2)  2.291 ms  5.108 ms  5.433 ms
 2  h254.s98.ts.hinet.net (168.95.98.254)  8.140 ms  7.368 ms  7.322 ms
 3  chch-3301.hinet.net (168.95.220.86)  10.456 ms  7.929 ms  7.392 ms
 4  chch-3012.hinet.net (220.128.19.206)  13.023 ms  12.845 ms
    chch-3011.hinet.net (220.128.18.194)  13.129 ms
 5  220-128-18-10.hinet-ip.hinet.net (220.128.18.10)  14.191 ms  13.981 ms
    220-128-19-10.hinet-ip.hinet.net (220.128.19.10)  12.643 ms
 6  r4102-s2.tp.hinet.net (220.128.7.65)  10.510 ms
    r4102-s2.tp.hinet.net (220.128.11.149)  14.819 ms  10.031 ms
 7  r4002-s2.tp.hinet.net (220.128.31.13)  36.698 ms  14.272 ms  10.656 ms
 8  r12-pa.us.hinet.net (211.72.108.81)  140.205 ms
    211-72-108-49.hinet-ip.hinet.net (211.72.108.49)  144.984 ms
    r12-pa.us.hinet.net (211.72.108.5)  152.026 ms
 9  r11-pa.us.hinet.net (202.39.83.45)  146.032 ms
    r11-pa.us.hinet.net (202.39.83.77)  141.618 ms  156.505 ms
10  tge1-3.sjo01-1.us.as5580.net (198.32.176.206)  149.407 ms  144.677 ms  157.694 ms
11  eth1-1.edge1.buf1.us.as5580.net (78.152.45.216)  220.302 ms  216.573 ms  212.385 ms
12  78.152.61.31 (78.152.61.31)  221.667 ms
    78.152.57.87 (78.152.57.87)  226.615 ms
    78.152.60.39 (78.152.60.39)  224.464 ms
13  10.8.40.214 (10.8.40.214)  227.837 ms
    10.8.25.198 (10.8.25.198)  232.994 ms *
14  10.8.28.58 (10.8.28.58)  234.335 ms *
    10.8.28.66 (10.8.28.66)  223.209 ms
15  * * *

16  198-12-88-***-host.colocrossing.com (198.12.88.***)  227.844 ms  225.599 ms  219.357 ms


➜  d-copy git:(master ping -c 5 198.12.88.***
PING 198.12.88.*** (198.12.88.***): 56 data bytes
64 bytes from 198.12.88.***: icmp_seq=0 ttl=47 time=225.961 ms
蠻高的 225ms 最好在100以下...




安裝所需軟體使用ee 來快速完成

  • wget -qO ee rt.cx/ee && sudo bash ee # 下載與安裝EasyEngine


中間有需要打名字email

EasyEngine (ee) required your name & email address to track changes you made under the Git version control
EasyEngine (ee) will be able to send you daily reports & alerts in upcoming version
EasyEngine (ee) will NEVER send your information across
Enter your name: qjpioneer

Enter your email: qjpioneer@gmail.com
.....
EasyEngine (ee) installed/updated successfully

EasyEngine (ee) help: http://docs.rtcamp.com/easyengine/
完成,約5分鐘?


  • sudo ee stack install --web # 安裝網站所需之相關軟體
Adding repository for MySQL, please wait...
Adding repository for NGINX, please wait...
Adding repository for PHP, please wait...


Installing packages, please wait...
Downloading MySQLTuner           [Done]
Downloading WP-CLI               [Done]
Reload : postfix   [OK]
Reload : nginx     [OK]
Restart : php5.6-fpm[OK]
Reload : mysql     [OK]
HTTP Auth User Name: eas**
HTTP Auth Password : ***

Successfully installed packages

此為admin tools  mysite.com:22222 的帳密



  • sudo ee site create 網域 --快取方式 #建立wp網站與快取方式設定
這邊我用sudo ee site create qjpioneer.com --wpsc


Running pre-update checks, please wait...
Setting up NGINX configuration  [Done]
Setting up webroot  [Done]
Downloading WordPress  [Done]
Setting up database [Done]
Installing plugin nginx-helper, please wait...



Installing plugin wp-super-cache, please wait...
Reload : nginx     [OK]
WordPress admin user : qj***
WordPress admin user password : ****
Configure WPSC: http://qjpioneer.com/wp-admin/options-general.php?page=wpsupercache
Successfully created site http://qjpioneer.com

上面這段裝好久,可能是選cache的關係

再來就是到Godaddy(你的網域商) 將網域改成主機的位置 (應該是要先改才對...)




變更主機時區  dpkg-reconfigure tzdata 


後來又下了這行 改php7 跟ssl憑證
sudo ee site update qjpioneer.com --php7 --letsencrypt

再來是phpmyadmin
ee stack install --admin

PHP already installed
MySQL connection is already alive
Downloading phpMyAdmin           [Done]
Downloading Adminer              [Done]
Downloading phpMemcachedAdmin    [Done]
Downloading clean.php            [Done]
Downloading opcache.php          [Done]
Downloading Opgui                [Done]
Downloading OCP.php              [Done]
Downloading Webgrind             [Done]
Downloading pt-query-advisor     [Done]

Downloading Anemometer           [Done]


再來切換到網頁目錄去並下載探針
/var/www/qjpioneer.com# wget http://www.yahei.net/tz/tz_tw.zip
wget下載探針

安裝zip壓縮程式並解壓縮
apt-get install unzip
unzip tz_tw.zip


在wp-config找 mysql 密碼

define('DB_NAME', 'qj****');

/** MySQL database username */
define('DB_USER', 'qj****');

/** MySQL database password */
define('DB_PASSWORD', '****');

/** MySQL hostname */

define('DB_HOST', 'localhost');

phpmyadmin 所需要用的 mysql username 和 password 可以在 wp-config.php 找到
另外,如果需要 mysql 的 root password,可以以 root 身份打 cat /root/.my.cnf
就可以看到 mysql 的 root password.
但我使用以上都登不進去....

Q 19. What is MySQL username and password?

MySQL username and password is saved in /etc/mysql/conf.d/my.cnf file while installing mysql. EasyEngine reads username and password from this file.
If my.cnf is not found on above location , EasyEngine also searches for same in ~/.my.cnf .
user = ****
password = ****


參考 

https://www.yogoeasy.com/vps-wp-installation/

https://www.enterpr1se.info/2015/08/set-up-wordpress-using-easyengine/

 Easyengine 的 document

EE FAQ

VPS

香港 Host US  https://my.hostus.us/cart.php?a=confproduct&i=1



Special 2 (768MB)  16usd/year
768MB RAM
768MB vSwap
1 vCPU Core (Fair Share)
20GB Disk space
2TB Bandwidth
1Gbit/s port
1 x IPv4 Address
4x IPv6 Addresses
OpenVZ / Breeze Control Panel

Virmach Micro+   7.5/yr

• 128MB RAM
• 10GB Disk
• 250GB Bandwith @ 1 Gbps
• Shared Intel HT CPU 1 Core @ 1GHz
• 1x IPv4 Addresses
Starting from 
$7.50 USD Annually
 Order Now











VPS新手教程:一键安装LNMP/LAMP/LANMP环境之Vestacp





http://www.zrblog.net/reading  vps優惠資訊/評測

[優惠]Godaddy 頂級網域 一年只要45元!




cjcsiglerc