熱門文章

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

[優惠]Godaddy wordpress 架站+網域一年不用500台幣!







促銷代碼:
CJCWPH1

2017年2月7日 星期二

AWS EC2 SFTP

使用SFTP來上傳檔案

  • 需要私鑰,但必須轉成.ppk格式
  • FileZilla 
  • Host
  • 帳號密碼


Using An SSH Key

Once you have your server's SSH key, choose your preferred application and follow the steps below to connect to the server using SFTP.
FileZilla
IMPORTANT: To use FileZilla, your server private key should be in PPK format.
Follow these steps:
  • Download and install FileZilla.
  • Launch FileZilla and use the "Edit -> Settings" command to bring up FileZilla's configuration settings.
  • Within the "Connection -> SFTP" section, use the "Add keyfile" command to select the private key file for the server. FileZilla will use this private key to log in to the server.FileZilla configuration
  • Use the "File -> Site Manager -> New Site" command to bring up the FileZilla Site Manager, where you can set up a connection to your server.
  • Enter your server host name and specify bitnami as the user name.
  • Select "SFTP" as the protocol and "Ask for password" as the logon type.FileZilla configuration
  • Use the "Connect" button to connect to the server and begin an SFTP session. You might need to accept the server key, by clicking "Yes" or "OK" to proceed.

aws ec2 如何透過ssh使用phpmyadmin

使用marketplace快速安裝wordpress後,我想要使用phpmyadmi來操作MySQL 卻發現

For security reasons, this URL is only accessible using localhost (127.0.0.1) as the hostname.

不能直接用瀏覽器,必須透過以下方法:




原文

For security reasons, these applications are accessible only when using 127.0.0.1 as the hostname. To access them from a remote system, you must create an SSH tunnel that routes requests to the Apache Web server from 127.0.0.1. This implies that you must have an SSH private key and be able to connect to your server over SSH in order to access these applications remotely.

Linux And Mac OS X

To access the application using your Web browser, create an SSH tunnel, as described below.
  • Make sure you can log in to the server using SSH. Refer to the FAQ for more information on this.
  • Open a new SSH session to the server using the command below:
     ssh -N -L 8888:127.0.0.1:80 -i KEYFILE bitnami@SERVER-IP
    
    Remember to replace KEYFILE in the previous commands with the path to your private key file, and SERVER-IPwith the IP address or hostname of your virtual machine. Note that if successful, this command will create an SSH tunnel but will not display any output on the server console.
While the tunnel is active, you should be able to access the phpMyAdmin console through the secure SSH tunnel you created, by browsing to http://127.0.0.1:8888/phpmyadmin.


盡量翻譯出來.....


因為安全因素,這程式僅能允許主機(指雲端server)本地連線。如需遠端存取(就是你在用的這台client),你必須經由SSH方式向主機的apache伺服器提出請求。這表示你必須有SSH私鑰才能透過SSH連到server進而使用該程式。

Linux and Mac

使用瀏覽器存取此程式前,你必須透過SSH方式,步驟如下:

  • 確定你能夠透過SSH登入server
  • 另開視窗,使用以下command:

 ssh -N -L 8888:127.0.0.1:80 -i KEYFILE bitnami@SERVER-IP
keyfile : 你的私鑰。可以直接拖曳檔案得到私鑰路徑避免打錯
bitnami@SERVER-IP :下圖紅框即是



輸入後終端機並不會有任何的反應,請直接到瀏覽器輸入 http://127.0.0.1:8888/phpmyadmin

完成!!

參考 參考2

[ubuntu]錯誤fix :LC_ALL跟LANGUAGE為unset

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "zh_TW.UTF-8",
LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

Preconfiguring packages ...


網路上看到很多解決方法而我是這樣解的...  

/etc/default 編輯 locale   前必須先更改權限(777很危險之後再改回來)


ubuntu@ip-172-31-28-55:/etc/default$ sudo chmod 777 locale
ubuntu@ip-172-31-28-55:/etc/default$ vim locale




LANG="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"


再執行就過了....卡好久shot