[ubuntu]在ubuntu 11.04中安裝 squid proxy server

參考網址:ez2o

不知為何,學校上課的網路環境連到makecode速度很慢,上起課來很卡。所以想建個proxy來改善。
server是ubuntu 11.04的老舊系統,apt-get已無法正常使用。只好到old-releases.ubuntu.com抓deb來安裝。
目錄是/ubuntu/pool/main
查了一下日期,大約需要squid_2.7版
需要以下這三個檔案
squid-langpack_20110707-1_all.deb
squid-common_2.7.STABLE9-2.1ubuntu6_all.deb
squid_2.7.STABLE9-2.1ubuntu6_i386.deb
有相依的問題存在,所以需依序安裝。

vi /etc/squid/squid.conf

編輯 http_port 預設為 3128,可以改為想設定的 Proxy Port

設定允許所有人連入 Proxy :

將 http_access allow localhost 改為 http_access allow all

將 http_access deny all 註解

把cache放大,預設是100MB
# cache_dir ufs /var/spool/squid 100 16 256
cache_dir ufs /var/spool/squid 1000 16 256

重新啟動 squid:
/etc/init.d/squid restart

快取檔放在/var/spool/squid

設定參考 http://linux.vbird.org/linux_server/0420squid.php#server_default

MIS的背影

測試後設定
 

http_port 3128

#acl localhost src 127.0.0.1/32
acl localhost src 120.116.22.0/23

acl dropdomain dstdomain "/etc/squid/dropdomain.txt"
http_access deny dropdomain
http_access allow localhost
#http_access allow all
http_access deny all

/etc/squid/dropdomain.txt 放要擋掉的網站

.facebook.com
.yahoo.com
.hinet.net

更改dropdomain.txt後記得要service squid reload 重新讀取設定值

client 端快速啟用proxy (記得把xx.xx.xx.xx改成你的proxy IP yy.yy.yy.yy是不cache的網站)

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"ProxyEnable"=dword:00000001
"ProxyServer"="xx.xx.xx.xx:3128"
"ProxyOverride"="yy.yy.yy.yy"

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\iphlpsvc\Parameters\ProxyMgr\{9839E71E-FDD5-445A-B73A-A59B3FB57E04}] 
"StaticProxy"="xx.xx.xx.xx:3128"

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\iphlpsvc\Parameters\ProxyMgr\{9839E71E-FDD5-445A-B73A-A59B3FB57E04}] 
"StaticProxy"="xx.xx.xx.xx:3128"

刪除cache
 

#!/bin/sh
service squid stop
rm -rf /var/spool/squid
mkdir /var/spool/squid
chown proxy:proxy /var/spool/squid -R
squid -z
service squid start

 

發表於 Linux系統 | 發表迴響

[卡巴斯基]離線安裝版 offline standalone

參考網址:卡巴斯基 2020g 离线安装程序 Kaspersky 2020g offline installer for Windows

OneDrive

發表於 Windows系統 | 發表迴響

讓你手機平板變為擴展螢幕

參考網址:每日頭條

這是一個有趣的想法,之前教學上的需要, 有用過兩個螢幕,把要給學生參考的資料丟到延伸螢幕,直接投影出去。
家裡沒有第二台螢幕,但有時真的需要有延伸螢幕的功能。
在網路上找到這個做法,蠻有趣的。
https://spacedesk.net/

電腦王阿達 https://www.kocpc.com.tw/archives/262230

如果你的電腦是筆電,那麼記得將螢幕模式切成延伸。(快速鍵Fn+F5)

「Shift」+「Win」+左右方向鍵:可將工作中的視窗快速切換到左右螢幕。

發表於 Windows系統, 硬體維修 | 發表迴響

可攜式螢幕 MSI Optix MAG161V

參考網址:

電腦王阿達 https://www.kocpc.com.tw/archives/315455

發表於 教學科技 | 發表迴響

[tinycode]5a88 tni tinycode

以下以 2020 0228 版試做:
5a88 tni tinycode 的DHCPD 是用dnsmasq完成的
設定檔放在/etc/dnsmasq.conf

試用一下5a88.php程式,在啟動DHCP server的時候一直無法成功,
去追了一下程式,發現在/etc/dnsmasq.conf的第39行錯誤dhcp-option=6,
暫時把/home/tc/make_dhcpserverconf.sh的相關程式第33行 echo $rr2 >> /home/tc/dnsmasqdhcp.txt  註解掉
就可以正常啟動了

目前卡在client連線時無法進入到視窗畫面,出現以下錯誤
Could not load host key : /usr/local/etc/ssh/ssh_host_ed25519_key
xset :unable to open disply ""
failed in waitforX

ISO下載 20190809  32位元
ISO下載 20200228  64位元
ISO下載 20191227  32位元

 

發表於 Linux系統 | 發表迴響

[mysql]MySQL 編碼由 latin1 轉 utf8

參考網址:藏經閣

很久以前的 MySQL 資料庫,因為過去預設編碼為 latin1,在新的 phpMyAdmin 就無法成功轉為 utf8 的編碼。

利用mysql自帶的mysqldump功能dump一下原有的 latin1 編碼的資料庫。請進入 cmd 模式,輸入以下指令:

mysqldump --user=使用者名稱 --password=密碼 --default-character-set=latin1  --skip-set-charset 資料表名稱 > 輸出檔名.sql

再利用取代的功能,把 latin1 都取代成 utf8。

完成取代之後請直接另存新檔 .. 這時把檔案類型設定儲存成 UTF-8。

最後您就可以回到 phpMyAdmin 中將這個 sql 檔匯入 MySQL 中了。以下是參考的指令:


mysql --user=使用者名稱 --password=密碼 --default-character-set=utf8 資料表名稱 < 輸出檔名.sql
發表於 Linux系統, 程式設計 | 發表迴響

[飛狼blog]PHPExcel 讀取日期欄位

參考網址:
掃文 總結了下PHPExcel官方讀取的幾個例子

美寶論壇 PHPExcel 讀取「時間格式」的儲存格內容

require_once("../class/PHPExcel/IOFactory.php");

$inputFileName = 'import.xlsx';

$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);

//$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); //格式化輸出

$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,false,true);  //未格式化輸出

$colindex = 0;

foreach( $sheetData as $key => $col ){

if($rowindex == 0)  {

    //

}

if($rowindex >= 1)  {

//$col['B']是日期欄位

//未格式化輸出 $col['B']為 1900-1-1 到該日期的天數 

                //例如:如果 B2 是 2000/1/1 ,則 $number = 36529 (天)

        

                //重點來了,下面這個函式會將 1900-1-1以來的天數 轉換成 1970-1-1 以來的秒數 

                //接上例,如果 $number = 36529(天) ,則 $t = 946944000 (秒)  

$t = PHPExcel_Shared_Date::ExcelToPHP( $col['B'] );



//接著 這個 $t 就可以利用 php 的函式發揮了

$a = date( "Y-m-d", $t );

    echo "{$col['A']} {$col['B']} {$t} {$a}  {$col['C']}". strlen($col['A']). " ".mb_strlen($col['A'])."<br>";

    //     

}

$rowindex++;    

} 

 

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

[lifetype]LifeType 透過 RSS Dump 所有文章

參考網址:Tsung's Blog

LifeType 要匯出所有文章的方法, 除了自己從 DB 撈以外, 另一招可以用 RSS 倒.

下述假設文章量是在 30000篇以內.

 

LifeType 修改 RSS 秀出所有的文章

  1. cp /var/www/lifetype/rss.php /var/www/lifetype/rss2.php
  2. vim /var/www/lifetype/rss2.php # 於檔案最上方, 增加一行

    define('TSUNG', 1);
  3. vim /var/www/lifetype/class/action/rssaction.class.php
    # 於 103行 

     

    $amount = $blogSettings->getValue( "recent_posts_max", 15 );

    # 改成

    
    if (defined('TSUNG')) {
        $hardLimit = 30000;
        $amount = 30000;
    } else {
        $amount = $blogSettings->getValue( "recent_posts_max", 15 );
    }
  4. 在連結 http://lifetype-domain/rss2.php , 就可以透過 rss 倒出所有文章.
發表於 Linux系統, wordpress | 發表迴響

[rasp]How to Remote Connect to a Windows PC From a Raspberry Pi

參考網址:

https://www.makeuseof.com/tag/remote-connect-windows-pc-raspberry-pi/

apt install xrdp
apt install remmina
發表於 Linux系統 | 發表迴響

安裝 WSL 2

參考網址:https://docs.microsoft.com/zh-tw/windows/wsl/wsl2-install

WSL 2 僅適用於 Windows 10 組建 18917 或更高版本

  • 請確定您已安裝 WSL (您可以在這裡找到進行這項操作的指示),而且您正在執行 Windows 10 組建 18917 或更高版本

     

     

     

    • 若要確定您使用組建 18917 或更高版本,請加入 Windows 測試人員計畫,並選取 [快速] 或 [慢速] 通道。
    • 您可以藉由開啟 [命令提示字元] 並執行 ver 命令,以檢查您的 Windows 版本。
  • 啟用「虛擬機器平臺」選用元件
  • 使用命令列設定 WSL 2 支援的分散式版
  • 驗證分散式版本使用的 WSL 版本

Windows 10 20H1 (Vibranium) 公眾預覽版本 Build 19041 發佈 + 繁體中文版下載

 

Huan-Lin 學習筆記 在 Windows 10 環境上安裝 WSL 2

壞蛋的密室 最近開始改用 WSL2 跑 docker 當開發環境

 

發表於 Windows系統 | 發表迴響