【mysql】複製一筆資料

參考網址:http://blog.7311.tw/2014/05/mysqlmssql.html

複製一筆資料
MySQL、MSSQL 都可使用
 

INSERT INTO test(
id,
name,
test1,
test2
)
SELECT
3 AS id,
name,
'test' AS test1,
test2
FROM test
WHERE id =1

* 要複製原來的值就不用AS

 

參考網址:https://caloskao.org/mysql-%E5%9C%A8%E5%90%8C%E4%B8%80%E5%BC%B5%E8%B3%87%E6%96%99%E8%A1%A8%E9%80%B2%E8%A1%8C%E8%A4%87%E8%A3%BD%E8%B3%87%E6%96%99%E7%9A%84%E6%93%8D%E4%BD%9C/
由於先dump出來再操作實在是覺得有點麻煩又有點蠢
想到應該可以直接下SQL來完成這件事情
於是稍微研究了一下
基本上只要避開primary column即可完成

發表於 Linux系統, 程式設計 | 發表迴響

[HTML]動態增加input物件

參考網址:https://www.sanwebe.com/2013/03/addremove-input-fields-dynamically-with-jquery

https://dotblogs.com.tw/newmonkey48/2016/12/14/180815

$(document).ready(function() {
	var max_fields      = 10; //maximum input boxes allowed
	var wrapper   		= $(".input_fields_wrap"); //Fields wrapper
	var add_button      = $(".add_field_button"); //Add button ID
	
	var x = 1; //initlal text box count
	$(add_button).click(function(e){ //on add input button click
		e.preventDefault();
		if(x < max_fields){ //max input box allowed
			x++; //text box increment
			$(wrapper).append('<div><input type="text" name="mytext[]"/><a href="#" class="remove_field">Remove</a></div>'); //add input box
		}
	});
	
	$(wrapper).on("click",".remove_field", function(e){ //user click on remove text
		e.preventDefault(); $(this).parent('div').remove(); x--;
	})
});

 

<div class="input_fields_wrap">
    <button class="add_field_button">Add More Fields</button>
    <div><input type="text" name="mytext[]"></div>
</div>

 

發表於 程式設計 | 發表迴響

angularjs

參考網址:https://angularjs.org/
逛網站時,發現這個網站設計得很不錯。2020臺南古都國際半程馬拉松

有用了angularjs的技術
前端工程的極致精品: AngularJS 開發框架介紹

發表於 程式設計 | 發表迴響

mysql資料庫跨伺服器查詢,需要確定mysql支援FEDERATED

參考網址:程式前沿

 

發表於 Linux系統, 程式設計 | 發表迴響

[linux]zip指令用法

參考網址:
將/home/目錄下1開頭的檔案壓縮成home.zip 

zip -r home /home/1*

第一個home是目的檔,會自動加.zip
-r 參數是包含目錄

發表於 Linux系統, 軟體使用 | 發表迴響

ckeditor加入elfinder檔案上傳功能

參考實戰php7+mysql從0開始寫出自己想要寫的程式(吳弘凱,松崗)P15-14
官方網站https://studio-42.github.io/elFinder/
■修改ckeditor/config.js
在最下方的}之前加入
config.filebrowserBrowseUrl='../js/elFinder/elfinder.html';

■修改elFinder/elfinder.html
直接從光碟複製過來

■在include/config.php中定義
//上傳檔案路徑

define('_UPLOAD_PATH' ,'/var/www/html/sport10901/upload/');
define('_UPLOAD_URL' ,'http://163.26.179.2/sport10901/upload/');

■修改elFinder/php/connector.minimal.php
先在開頭引入
include_once "../../../include/config.php";
修改

//'uploadDeny'    => array('all'),
'uploadDeny' => ['text/php', 'text/x-php', 'application/php', 'application/x-php', 'application/x-httpd-php', 'application/x-httpd-php-source'],

//'uploadAllow'   => array('image', 'text/plain'),
'uploadAllow' => ['all'],

//'uploadOrder'   => array('deny', 'allow'), 
'uploadOrder' => ['allow', 'deny'],


 

註:出現「elfinder無可讀取的磁碟」是因為_UPLOAD_PATH or _UPLOAD_URL 引入錯誤
elFinder/php/connector.minimal.php開頭未正確引入include_once "../../../include/config.php";

發表於 程式設計 | 發表迴響

veyon安裝與設定

參考網址:http://wow-cai2.blogspot.com/2018/09/veyon.html

https://veyon.io/

管理員手冊

使用說明書

◆配合5a88使用
先在5a88學生端電腦安裝veyon,產生公鑰及私鑰並匯出
教師端匯入學生端的公鑰及私鑰即可

 

◆匯入電腦教室電腦csv

用最高權限執行CMD
C:\Program Files\Veyon>veyon-cli networkobjects help import
用法
networkobjects import <檔案> [location <位置>] [format <格式字串含預留位置>] [regex <正則運算式含預留位置>]

描述
使用包含一個或多個預留位置的給予格式字串或正則運算式,從指定的文字檔匯入物件。 有效的預留位置為: %location% %name% %host% %mac% %type%

範例
    * 將簡單 CSV 檔匯入到單一教室:
        networkobjects import computers.csv location "教室 01" format "%name%;%host%;%mac%"

    * 匯入第一列中含有位置名稱的 CSV 檔:
        networkobjects import computers-with-rooms.csv format "%location%,%name%,%mac%"

    * 使用正則運算式匯入含金鑰/值配對的文字檔:
        networkobjects import hostlist.txt location "教室 01" regex "^NAME:(%name%:.*)\s+HOST:(%host%:.*)$"

    * 匯入任意格式的資料:
        networkobjects import data.txt regex '^"(%location%:[^”]+)”;”(%host%:[a-z\d\.]+)".*$'

匯入指令
 

veyon-cli networkobjects import ip_veyon.csv location "cmpt" format "%name%;%host%;%mac%"

 

匯入檔範例ip_veyon.csv
 

11;192.168.0.211;f4:4d:30:xx:yy:zz
12;192.168.0.212;f4:4d:30:xx:yy:zz
13;192.168.0.213;f4:4d:30:xx:yy:zz

 

發表於 Windows系統, 軟體使用 | 發表迴響

WakeOnLan

參考網址:
Linux Wake-On-Lan

apt-get install etherwake 進行安裝。使用指令傳送開機封包,請執行 etherwake 00:30:2D:5F:12:A1 送出開機封包。

圖形介面的WakeOnLan
apt install gwakeonlan

使用 PHP 網路開機
在區域網路中,可以傳送 Magic Packet 給主機的網路卡,Magic Packet 內容開頭有6個 "FF",再接 16 個網路卡 MAC,當主機版有開啟支援 Wake on LAN 功能,網路卡接收到符合條件的 Magic Packet,就能開啟電腦。(每個主機版關於 Wake on LAN 的名稱不盡相同,例如 PME Event Wake Up、Power On By PCI Devices…)
另一個影響能否網路開機的設定,在作業系統裡面裝置管理員,網卡裝置內容裡的電源管理,需勾選「允許這個裝置喚醒電腦」。

 

假設網路卡 MAC 位址為:01-02-03-04-05-06
Magic Packet 內容則為:

FFFFFFFFFFFF010203040506010203040506010203040506010203040506010203040506010203040506010203040506010203040506010203040506010203040506010203040506010203040506010203040506010203040506010203040506010203040506

然後以 UDP 通訊協定傳送給電腦的 port 7、或 port 9

 

所以實現網路開機的方式,就是在區網內想辦法傳送給目標電腦網卡 Magic Packet,如果用來傳送 Magic Packet 的設備(Server),平常也有對外連線,也可達成在外網開機的效果。

以下 PHP 傳送 Magic Packet 範例來源
WOL: Wake-on-LAN Tutorial with Bonus PHP Script
僅稍微修改後如下:

class WakeOnLan {

    /**
     * 喚醒電腦
     * @param type $addr ,目標IP 或 廣播位址(格式 01-02-03-04-05-06 或 01:02:03:04:05:06)
     * @param type $mac ,MAC 位址
     * @param type $port , 7 or 9
     * @return boolean
     */
    public function wake($addr, $mac, $port) {
        $mac = str_replace("-", ":", $mac);
        $addr_byte = explode(':', $mac);
        $hw_addr = '';
        for ($a = 0; $a < 6; $a++) {
            $hw_addr .= chr(hexdec($addr_byte[$a]));
        }
        // 開頭六個 "FF"
        $msg = chr(255) . chr(255) . chr(255) . chr(255) . chr(255) . chr(255);
        // 16個MAC
        for ($a = 1; $a <= 16; $a++) {
            $msg .= $hw_addr;
        }
        // 開一個 UDP 的 socket
        // AF_INET:IP4
        // SOCK_DGRAM:The UDP protocol is based on this socket type
        // SOL_UDP:使用 UDP 通訊協定
        $skt = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
        $err = array();
        if ($skt === false) {
            $err[] = "Error creating socket!";
            $err[] = "Error code is '" . socket_last_error($skt) . "' - " . socket_strerror(socket_last_error($skt));
            throw new Exception(implode("\n", $err));
        } else {
            // 設定使用broadcast廣播訊息
            // $opt_ret = socket_set_option($skt, 1, 6, TRUE);
            $opt_ret = socket_set_option($skt, SOL_SOCKET, SO_BROADCAST, true);
            if ($opt_ret === false) {
                $err[] = "setsockopt() failed, error: " . socket_strerror(socket_last_error($skt));
                throw new Exception(implode("\n", $err));
            }

            if (socket_sendto($skt, $msg, strlen($msg), 0, $addr, $port)) {
                //Magic Packet sent successfully
                $res = trim(socket_strerror(socket_last_error($skt)));
                socket_close($skt);
                return $res;
            } else {
                $err[] = "Magic packet failed!";
                throw new Exception(implode("\n", $err));
            }
        }
    }

}

$WOL = new WakeOnLan();
try {
    // 使用 port 7
    $res = $WOL->wake('192.168.0.255', "01-02-03-04-05-06", 7);
    // 也可使用 port 9
    //$res = $WOL->wake('192.168.0.255', "01-02-03-04-05-06", 9);
    var_dump($res);
} catch (Exception $ex) {
    var_dump($ex->getMessage());
}

 

發表於 程式設計 | 發表迴響

windows10 資料夾共用

參考網址:http://www.fox-saying.com/blog/post/43773565-windows10

請進到 控制台 > 網路和網際網路 > 網路和共用中心

再來進到 變更進階共用設定

以密碼保護的共用 > 關閉

接下來

在您想分享共用的資料夾處~~~ 右鍵 > 內容 > 共用

然後新增使用人 EVERYONE

 

為了保證你的資料夾能被使用的機會提高
您還需要在該資料夾處,滑鼠右鍵 > 內容 > 安全性
然後一樣新增 everyone

發表於 Windows系統 | 發表迴響

[rasp]樹莓派-解析度調整

參考網址:程王敗code

hdmi_group  HDMI ––> Type

 

hdmi_group=1 ––> CEA

hdmi_group=2 ––> DMT

 

hdmi_mode 須對照 hdmi_group

 

These values are valid if hdmi_group=1 (CEA)
hdmi_mode=1    VGA
hdmi_mode=2    480p   60 Hz
hdmi_mode=3    480p   60 Hz  H
hdmi_mode=4    720p   60 Hz
hdmi_mode=5    1080i  60 Hz
hdmi_mode=6    480i   60 Hz
hdmi_mode=7    480i   60 Hz  H
hdmi_mode=8    240p   60 Hz
hdmi_mode=9    240p   60 Hz  H
hdmi_mode=10   480i   60 Hz  4x
hdmi_mode=11   480i   60 Hz  4x H
hdmi_mode=12   240p   60 Hz  4x
hdmi_mode=13   240p   60 Hz  4x H
hdmi_mode=14   480p   60 Hz  2x
hdmi_mode=15   480p   60 Hz  2x H
hdmi_mode=16   1080p  60 Hz
hdmi_mode=17   576p   50 Hz
hdmi_mode=18   576p   50 Hz  H
hdmi_mode=19   720p   50 Hz
hdmi_mode=20   1080i  50 Hz
hdmi_mode=21   576i   50 Hz
hdmi_mode=22   576i   50 Hz  H
hdmi_mode=23   288p   50 Hz
hdmi_mode=24   288p   50 Hz  H
hdmi_mode=25   576i   50 Hz  4x
hdmi_mode=26   576i   50 Hz  4x H
hdmi_mode=27   288p   50 Hz  4x
hdmi_mode=28   288p   50 Hz  4x H
hdmi_mode=29   576p   50 Hz  2x
hdmi_mode=30   576p   50 Hz  2x H
hdmi_mode=31   1080p  50 Hz
hdmi_mode=32   1080p  24 Hz
hdmi_mode=33   1080p  25 Hz
hdmi_mode=34   1080p  30 Hz
hdmi_mode=35   480p   60 Hz  4x
hdmi_mode=36   480p   60 Hz  4xH
hdmi_mode=37   576p   50 Hz  4x
hdmi_mode=38   576p   50 Hz  4x H
hdmi_mode=39   1080i  50 Hz  reduced blanking
hdmi_mode=40   1080i 100 Hz
hdmi_mode=41   720p  100 Hz
hdmi_mode=42   576p  100 Hz
hdmi_mode=43   576p  100 Hz  H
hdmi_mode=44   576i  100 Hz  
hdmi_mode=45   576i  100 Hz  H
hdmi_mode=46   1080i 120 Hz  
hdmi_mode=47   720p  120 Hz  
hdmi_mode=48   480p  120 Hz  
hdmi_mode=49   480p  120 Hz  H
hdmi_mode=50   480i  120 Hz  
hdmi_mode=51   480i  120 Hz  H
hdmi_mode=52   576p  200 Hz  
hdmi_mode=53   576p  200 Hz  H
hdmi_mode=54   576i  200 Hz  
hdmi_mode=55   576i  200 Hz  H
hdmi_mode=56   480p  240 Hz  
hdmi_mode=57   480p  240 Hz  H
hdmi_mode=58   480i  240 Hz  
hdmi_mode=59   480i  240 Hz  H
H means 16:9 variant (of a normally 4:3 mode).
2x means pixel doubled (that is, higher clock rate, with each pixel repeated twice)
4x means pixel quadrupled (that is, higher clock rate, with each pixel 
repeated four times)

 
These values are valid if hdmi_group=2 (DMT)

Note: according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=26&t=20155&p=195417&hilit=2560x1600#p195443 

there is a pixel clock limit which means the highest supported 

mode is 1920x1200 @60 Hz with reduced blanking.

hdmi_mode=1    640x350    85 Hz

hdmi_mode=2    640x400    85 Hz

hdmi_mode=3    720x400    85 Hz

hdmi_mode=4    640x480    60 Hz

hdmi_mode=5    640x480    72 Hz

hdmi_mode=6    640x480    75 Hz

hdmi_mode=7    640x480    85 Hz

hdmi_mode=8    800x600    56 Hz

hdmi_mode=9    800x600    60 Hz

hdmi_mode=10   800x600    72 Hz

hdmi_mode=11   800x600    75 Hz

hdmi_mode=12   800x600    85 Hz

hdmi_mode=13   800x600   120 Hz

hdmi_mode=14   848x480    60 Hz

hdmi_mode=15   1024x768   43 Hz  DO NOT USE

hdmi_mode=16   1024x768   60 Hz

hdmi_mode=17   1024x768   70 Hz

hdmi_mode=18   1024x768   75 Hz

hdmi_mode=19   1024x768   85 Hz

hdmi_mode=20   1024x768  120 Hz

hdmi_mode=21   1152x864   75 Hz

hdmi_mode=22   1280x768          Reduced blanking

hdmi_mode=23   1280x768   60 Hz

hdmi_mode=24   1280x768   75 Hz

hdmi_mode=25   1280x768   85 Hz

hdmi_mode=26   1280x768  120 Hz  Reduced blanking

hdmi_mode=27   1280x800          Reduced blanking

hdmi_mode=28   1280x800   60 Hz  

hdmi_mode=29   1280x800   75 Hz  

hdmi_mode=30   1280x800   85 Hz  

hdmi_mode=31   1280x800  120 Hz  Reduced blanking

hdmi_mode=32   1280x960   60 Hz  

hdmi_mode=33   1280x960   85 Hz  

hdmi_mode=34   1280x960  120 Hz  Reduced blanking

hdmi_mode=35   1280x1024  60 Hz  

hdmi_mode=36   1280x1024  75 Hz  

hdmi_mode=37   1280x1024  85 Hz  

hdmi_mode=38   1280x1024 120 Hz  Reduced blanking

hdmi_mode=39   1360x768   60 Hz  

hdmi_mode=40   1360x768  120 Hz  Reduced blanking

hdmi_mode=41   1400x1050         Reduced blanking

hdmi_mode=42   1400x1050  60 Hz  

hdmi_mode=43   1400x1050  75 Hz  

hdmi_mode=44   1400x1050  85 Hz  

hdmi_mode=45   1400x1050 120 Hz  Reduced blanking

hdmi_mode=46   1440x900          Reduced blanking

hdmi_mode=47   1440x900   60 Hz  

hdmi_mode=48   1440x900   75 Hz  

hdmi_mode=49   1440x900   85 Hz  

hdmi_mode=50   1440x900  120 Hz  Reduced blanking

hdmi_mode=51   1600x1200  60 Hz  

hdmi_mode=52   1600x1200  65 Hz  

hdmi_mode=53   1600x1200  70 Hz  

hdmi_mode=54   1600x1200  75 Hz  

hdmi_mode=55   1600x1200  85 Hz  

hdmi_mode=56   1600x1200 120 Hz  Reduced blanking

hdmi_mode=57   1680x1050         Reduced blanking

hdmi_mode=58   1680x1050  60 Hz  

hdmi_mode=59   1680x1050  75 Hz  

hdmi_mode=60   1680x1050  85 Hz  

hdmi_mode=61   1680x1050 120 Hz  Reduced blanking

hdmi_mode=62   1792x1344  60 Hz  

hdmi_mode=63   1792x1344  75 Hz  

hdmi_mode=64   1792x1344 120 Hz  Reduced blanking

hdmi_mode=65   1856x1392  60 Hz  

hdmi_mode=66   1856x1392  75 Hz  

hdmi_mode=67   1856x1392 120 Hz  Reduced blanking

hdmi_mode=68   1920x1200         Reduced blanking

hdmi_mode=69   1920x1200  60 Hz  

hdmi_mode=70   1920x1200  75 Hz  

hdmi_mode=71   1920x1200  85 Hz  

hdmi_mode=72   1920x1200 120 Hz  Reduced blanking

hdmi_mode=73   1920x1440  60 Hz  

hdmi_mode=74   1920x1440  75 Hz  

hdmi_mode=75   1920x1440 120 Hz  Reduced blanking

hdmi_mode=76   2560x1600         Reduced blanking

hdmi_mode=77   2560x1600  60 Hz  

hdmi_mode=78   2560x1600  75 Hz  

hdmi_mode=79   2560x1600  85 Hz  

hdmi_mode=80   2560x1600 120 Hz  Reduced blanking

hdmi_mode=81   1366x768   60 Hz  

hdmi_mode=82   1080p      60 Hz  

hdmi_mode=83   1600x900          Reduced blanking

hdmi_mode=84   2048x1152         Reduced blanking

hdmi_mode=85   720p       60 Hz  

hdmi_mode=86   1366x768          Reduced blanking
發表於 Linux系統 | 發表迴響