2022年6月15日 星期三

網頁設計、網站開發工作遇到的英文單字1

1.Configuration (n) 組態、結構、配置
APACHE LOG 檔出現錯誤:client denied by server configuration: xxx.php
client denied by server configuration  客戶端被服務器配置拒絕

2.Regex (n) 正則表達式,標準名稱Regular expression
程式用來搜尋找東西超好用

3.Corporate (adj) 企業的、法人的
Free Business Corporate HTML Template 搜尋免費版型能用這關鍵字
corporate finance 公司財務

4.Dealer (n) 零售商、商人
在別人的程式碼中可以看到這字
a second-hand car dealer 二手汽車經銷商

5.Carousel (n) 圓盤傳送帶、旋轉木馬
Owl Carousel 一個輪播的套件,貓頭鷹轉盤

6.Bootstrap (n) 引導、自力更生、拔靴帶
RWD 重要套件

7.Statistics (n) 統計
後台常常會做統計報表
The city's most shocking statistic is its high infant mortality rate. 這座城市最令人震驚的統計數字是其高嬰兒死亡率。

8.Picker (n) 選擇器、採摘者
常常有套件會叫什麼xxxpicker

9.Well known 眾所周知
Cpanel上會自動產生..well-known的目錄,放一些像是憑證之類的訊息

10.Validation (n) 驗證  validate (v)
寫程式常常會用到驗證

11.Placeholder (n) 佔位符、保留區
<input type="text" name="keyword" value="<{$data.keyword}>" style="height: 21px;font-size: 14px;" placeholder="搜尋商品編號">

12.Trial version (n) 試用版
用試用版常常會看到這文字

13.Series (n) 系列
寫程式常用什麼系列

14.Canvas (n) 畫布、帆布
很好用的繪圖JS canvasjs

16.Storm (n) 風暴、猛攻
付費好用的php編輯器 php storm

17.Exception (n) 例外
debug 時常常出現
Men are usually quite good at map-reading but Tim is the exception. 通常男性都很會看地圖,但提姆卻是例外的。

18.Minimum Stability (n) 最低穩定性
composer init 時的選項
a period of political stability 政治穩定時期

19.Stable (adj) 穩定的
composer init Minimum Stability: stable
He is now got a stable job in a bank.

20.Dependencies (n) 依賴、信賴、依屬
composer init license:dependencies
Drug Dependence let to her early dead. 藥物依賴導致她早死

21.Authorization (n) 授權、委任、認可、批准
API常用驗證方式,常常會用ESA +編碼
Medical records cannot be disclosed with authorization from the patient. 非病患許可,病例不得公開

22.Sibling (n) 兄弟姊妹
$(this).siblings().css("color","red") 選擇該層的兄弟姊妹

23.Toggle (n) 切換、觸發器、栓扣
$(this).toggle(),$(this).toggleclass() 超好用可取代hover
Use this key to toggle between the two typefaces. 用這個鍵在兩種字體間切換

24.Article (n) 文章、論文
文章模組常常會出現這單字
There are an interesting article on vegetarianism in the paper yesterday. 昨天的報紙登了一篇關於蔬菜主義的有趣的文章

25.Maintain (v) 維持、保持、使繼續
常常會出要maintain網站
We have standards to maintain. 我們要堅守原則

26.Tune (n)  調整、曲子
程式碼有沒有tune過?

27.Repository (n) 知識庫
建立自己的知識庫吧
She's repository of knowledge about our family history. 他對我們家族的歷史瞭入執掌

28.Remote (adj) 遠程、絕少、冷漠
共用伺服器,遠端IP $_SERVER['REMOTE_ADDR']
Remote galaxies. 遙遠的星系
a remote possibility. 微小的機會

29.Staging (n) 暫存、演出
git 有  Staging Area 暫存區

30.Untracked (v) 未追蹤
輸入 git init 會顯示 nothing added to commit but untracked files present

31.Fatal (adj) 致命錯誤
錯誤常常發生!
This illness is fatal in almost all cases. 這種病幾乎是不治之症

32.Revert (v) 還原
發生錯誤可以還原吧

33.Commit (v) 承諾、提交、做
git commit

34.Swipe (v) 滑動、刷卡、猛打
javascript 會用到滑動事件
She swiped him round the head. 他揮手打了他的頭

35.Bundle (n) 捆、卷、束 (v) 亂塞
javascript 套件有些會bundle成一支檔案
He bundled his clothes into the washing machine. 他亂塞他的衣服到洗衣機

36.Landing (n) page 登陸頁面
搜索引擎列表或者廣告之後所達到的網頁
We make a perfect landing at the airstrip. 我們完美降落到飛機跑道

37.property (n) 屬性、財產
像是某某物品的屬性
One of the properties of copper is that it conducts heat and electricity very well. 銅的特性之一是導熱和到電性佳。

38.Bounce (v) 彈回
Bounce Rate 跳出率
The ball bounced off this goalpost into the net. 那顆球碰到門柱後進網

39.Announce (v) 發布、宣布
在程式碼中看到,最新消息模組
They announced the death of their mother in the local paper. 他們一家母親死亡的消息公布在當地報紙上。

40.Cond、Condition (n) 條件
apache設定中從寫條件 RewriteCond
He's in no condition to drive home. 他的狀況根本不是和自已開車回家。

41.Element (n) 元素
DTD 還可以宣告以下四種:元素 (Elements)、屬性 (Attribute)、實體 (Entities)及註解 (Comments) 。其中的實體 (Entities)

42.Attribute (n) 屬性
DTD 還可以宣告以下四種:元素 (Elements)、屬性 (Attribute)、實體 (Entities)及註解 (Comments) 。其中的實體 (Entities)

43.Entity,Entities (n) 實體
DTD 還可以宣告以下四種:元素 (Elements)、屬性 (Attribute)、實體 (Entities)及註解 (Comments) 。其中的實體 (Entities)

44.Comments (n) 註解
DTD 還可以宣告以下四種:元素 (Elements)、屬性 (Attribute)、實體 (Entities)及註解 (Comments) 。其中的實體 (Entities)
I don't went any comments on my new haircut. 我不想任何人對我的髮型有所評論

45.Junior (adj) 初級、少年
junior school 小學

46.Senior (adj) 高級
She's senior to me. 他是我上級

47.Guide (n) 指南
Developer Guide 開發指南
a guide to Taiwan. 台灣指南

48.Procedure (n) 程序
General Procedure 一般程序

49.Alias (n) 別名
apache virtualhost 設定別名 ServerAlias 127.0.0.1
He travels under using on alias. 它旅遊都用匿名

50.Diagram (n) 圖表
class diagram 類別圖

2021年4月13日 星期二

【MSSQL】名稱相同址更新最新一筆資料

UPDATE _test SET [value]='100' WHERE id  = (SELECT TOP 1 id FROM _test WHERE [name]='aa' ORDER BY id DESC) AND [name]='aa'

2020年5月28日 星期四

【javascript】小數相加

javascript 小數相加偶爾會跑出奇怪的數字
例如:1.001 + 2.0001 = 3.00110000000000001

解決方式:先把小數乘很大的數,讓他變成整數計算好在除回去

剛剛的例子要改成:
(1.001 * 1e12) + (2.0001 * 1e12) / 1e12

(1e12 = 1後面帶了12個0,1000000000000)

2020年5月13日 星期三

【PHP】 AES 256 encrypt decrypt

AES(Advanced Encryption Standard) 256 進階加密標準
用來取代舊的DES(Data Encryption Standard)

php 的 mcrypt_encrypt 函數在php7.2就不支援要使用openssl_encrypt

使用openssl加解密方法:
function encrypt($key, $payload)
{
    $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc'));
    $encrypted = openssl_encrypt($payload, 'aes-256-cbc', $key, 0, $iv);
    return base64_encode($encrypted . '::' . $iv);
}

function decrypt($key, $garble)
{
    list($encrypted_data, $iv) = explode('::', base64_decode($garble), 2);
    return openssl_decrypt($encrypted_data, 'aes-256-cbc', $key, 0, $iv);
}

$key = "ABCDE";
echo $encode = encrypt($key, "123"); 
echo "<br>";
echo $decode = decrypt($key, $encode); 

2020年1月17日 星期五

【linux】免費SSL設定,Cerbot

1.先到Cerbot官網

2.選擇目前伺服器環境

















3.照著步驟走,要先確定有裝mod_ssl
yum -y install yum-utils
yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional

sudo yum install certbot python2-certbot-apache
sudo certbot --apache


4.取得憑證 certbot certonly --webroot -w /var/www/html -d mydomain.com --email {your_email_address} --agree-tos
成功後SSL憑證會放到 /etc/letsencrypt/live/{YOUR URL}/

5.改SSL,/etc/httpd/conf.d/ssl.conf
SSLCertificateFile /etc/letsencrypt/live/www.chiender.bnet.tw/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.chiender.bnet.tw/privkey.pem
SSLCACertificateFile /etc/letsencrypt/live/www.chiender.bnet.tw/fullchain.pem

6.設定VirturalHost
<VirtualHost *:80>
        ServerAlias *
        VirtualDocumentRoot "/var/www/html/%0"
        RewriteEngine on
        RewriteCond %{HTTPS} !=on
        RewriteRule ^(.*) https://%{SERVER_NAME}$1 [L,R]
</VirtualHost>

<VirtualHost *:443>
        ServerAlias *
        VirtualDocumentRoot "/var/www/html/%0"
        SSLEngine on
</VirtualHost>

2020年1月6日 星期一

【Jquery】ajax post from 檔案上傳

    $.ajax({
        type : "POST",
        url : "/sj/cooperation/ajax_dd",
        data : new FormData($('#myform')[0]),
        async: false,
        cache: false,
        contentType: false,
        processData: false,
        success : function($data) {
            $re = jQuery.parseJSON($data);
            $("#dd_id").val($re.dd_id);
            $msg = temp_dd($re.ddd);
            $($msg).hide().prependTo(".coop-msg").fadeIn('show');
            $("#coop_msg").val("");
        }
    });

2019年12月26日 星期四

【Mysql】json_extract

json_extract 可抓取在資料中json的值

範例:
// 抓取json第1個跟第0個值
SELECT JSON_EXTRACT('[10, 20, [30, 40]]', '$[1]', '$[0]');
結果:20 | 10

// 抓取data欄位,json名稱為name的值
select json_extract(data,'$.name'),json_extract(data,'$.tel') from tab_json 
直接抓取json第幾個值
CREATE TABLE tj10 (a JSON, b INT);
// 建立資料
INSERT INTO tj10 VALUES ("[3,10,5,17,44]", 33), ("[3,10,5,17,[22,44,66]]", 0);
// 抓取
SELECT a->"$[4]" FROM tj10;
結果:44 | [22,44,66]
更多資訊要看mysql官網:連結

2019年12月18日 星期三

【laravel】storage 相關

1.在 laravel 目錄輸入,預設目錄為 /storage/app/
   php artisan storage:link

2.建立檔案,在程式碼中加入
   Storage::disk('public')->put('test.txt', 'contents...');

3.取得剛剛新建立檔案的網址
   echo asset('storage/test.txt');

4.取得檔案的內容
   echo Storage::get('test.txt');

5.下載檔案
   Storage::download('test.txt');

6.檔案上傳
   $path = request()->image->store('public'); // 將欄位名image的圖片存入/storage/app/public
   request()->image->storeAs($dir, $file_name); // 將檔案以 $file_name 存入 $dir,$dir='public/';

7.取得副檔名
   $ext = request()->image->extension();

8.是否有檔案
   request()->hasFile('image');

9.照片上傳+縮圖範例
    
/**
 *  圖片上傳 + 縮圖
 * @param  [request]$img     $request->file
 * @param  [string] $feild   欄位名稱
 * @param  array  $thumb_arr 縮圖 [[100,100],[250,250]] 會有兩個thumb資料目錄,沒輸入就不縮圖
 * @return [array]           result:是否成功 file_name、file_path
 */
public function upload_image($img, $feild, $thumb_arr=[])
{
    $check = 1;
    $ext = $img->extension();
    if (!$this->fileExtCheck($ext)){
        $check = 0;
    }

    $admin_path = $this->admin_path.'/'.$feild;

    Storage::makeDirectory('public/'.$admin_path);

    $file_name = $this->getFileName($img->getClientOriginalName());
    $directory = $this->la_storage_path.'/'.$admin_path;
    $save_file = $directory.'/'.$file_name;
    if (!Image::make($img)->save($save_file)){
        $check = 0;
    }

    if (isset($thumb_arr)){
        foreach($thumb_arr as $thumb){
            $thumb_name = 'thumb_'.$thumb[0].'_'.$thumb[1];
            Storage::makeDirectory('public/'.$admin_path.'/'.$thumb_name);
            $themb_img = $directory.'/'.$thumb_name.'/'.$file_name;
            $t = Image::make($img)->resize($thumb[0],$thumb[1],function($constraint){
                $constraint->aspectRatio();
            })->save($themb_img);
            if (!$t){
                $check = 0;
            }
        }
    }

    if ($check)
        return ['result'=>'ok', 'file_name'=>$file_name, 'file_path'=>'storage/'.$admin_path.'/'.$file_name];
    else 
        return ['result'=>'err'];
}
10.刪除照片及縮圖
    
public function unlink_img($img, $thumb_arr=[])
{
    if (is_file($this->root.'/'.$img)) unlink($this->root.'/'.$img);

    if (isset($thumb_arr)){
        foreach($thumb_arr as $thumb){
            $thumb_name = 'thumb_'.$thumb[0].'_'.$thumb[1];
            $thumb_img = $this->root.'/'.dirname($img).'/'.$thumb_name.'/'.basename($img);
            if (is_file($thumb_img)) unlink($thumb_img);
        }
    }
}

2019年3月11日 星期一

【PHP】CURL 傳檔案 方法2


$url = '上傳網址';
$file_path = "檔案絕對路徑";
$fields = array('key'=>'val'); // post值


function curl_file_get_contents($url,$file_path,$fields='')
{
 $files['files[0]'] = file_get_contents($file_path);

 // curl
 $curl = curl_init();

 $boundary = uniqid();
 $delimiter = '-------------' . $boundary;

 $post_data = build_data_files($boundary, $fields, $files);

 curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_SSL_VERIFYPEER => 0,
  CURLOPT_SSL_VERIFYHOST => 1,
  CURLOPT_RETURNTRANSFER => 1,
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  //CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POST => 1,
  CURLOPT_POSTFIELDS => $post_data,
  CURLOPT_HTTPHEADER => array(
   //"Authorization: Bearer $TOKEN",
   "Content-Type: multipart/form-data; boundary=" . $delimiter,
   "Content-Length: " . strlen($post_data)
  ),
  
 ));

 $response = curl_exec($curl);
 $info = curl_getinfo($curl);
 $err = curl_error($curl);
 curl_close($curl);

 return $response;
}



function build_data_files($boundary, $fields, $files){
  $data = '';
  $eol = "\r\n";

  $delimiter = '-------------' . $boundary;

  if ($fields)
  {
   foreach ($fields as $name => $content) {
     $data .= "--" . $delimiter . $eol
       . 'Content-Disposition: form-data; name="' . $name . "\"".$eol.$eol
       . $content . $eol;
   }
  }


  foreach ($files as $name => $content) {
    $data .= "--" . $delimiter . $eol
      . 'Content-Disposition: form-data; name="' . $name . '"; filename="' . $name . '"' . $eol
      //. 'Content-Type: image/png'.$eol
      . 'Content-Transfer-Encoding: binary'.$eol
      ;

    $data .= $eol;
    $data .= $content . $eol;
  }
  $data .= "--" . $delimiter . "--".$eol;


  return $data;
}