分类: 未分类

  • windows上命令行方式修改exe图标

    目前有两个工具可以实现命令行修改图标

    cei

    https://github.com/0x546F6D/cei_-_Change_Executable_Icon
    这个命令比较简单,执行如下命令即可修改图标
    cei icon.ico my.exe new.exe
    但是不支持在windows 7系统上运行

    ResourceHacker

    http://www.angusj.com/resourcehacker/
    ResourceHacker有两种语法格式

    1. 命令方式

    ResourceHacker.exe -open winsw-x64.exe -saveas winsw-x64.exe -action addoverwrite -res logo.ico -mask ICONGROUP,MAINICON,0

    1. 脚本方式
      创建文件icon.txt,内容如下
    [FILENAMES]
    Exe=    WinSW-x64.exe
    SaveAs= WinSW-x64.exe
    [COMMANDS]
    -addoverwrite logo.ico, ICONGROUP,MAINICON,0
    

    然后执行命令
    ResourceHacker.exe -script icon.txt

    ResourceHacker.exe在执行的时候会立即退出在后台运行,不会等待执行完再返回,这点需要注意。

    在CI/CD或批处理中如果需要等待ResourceHacker执行完成则可以使用powershell中的start-process命令,如下:
    start-process resourcehacker -argumentlist "-open old.exe -saveas new.exe -action addoverwrite -res logo.ico -mask ICONGROUP,MAINICON,0" -Wait -PassThru
    如果是cmd则可以用start命令,具体用法可以参考相关资料。

    关于icon文件的生成可以用这个网站
    https://convertio.co/zh/

    重建图标缓存

    修改图标后在资源管理器有可能看到的还是旧的图标,这时候需要重建图标缓存。
    使用 IE4uinit 刷新 Windows 上的图标缓存
    在Windows中有一个内置工具 ie4uinit (IE每用户初始化实用程序),可用于快速重置图标缓存数据库。

    在 Windows 10 上: ie4uinit.exe -show
    在 Windows 7 上: ie4uinit.exe -ClearIconCache
    

    ie4uninit.exe执行后需要重启explorer.exe进程或重启电脑。
    也可以用如下批处理:

    taskkill /f /im explorer.exe
    cd /d %userprofile%\AppData\Local\Microsoft\Windows\Explorer
    attrib –h iconcache_*.db
    del /f IconCache*
    del /f thumbcache*
    cd /d  %userprofile%\AppData\Local\
    attrib –h IconCache.db
    del /f IconCache.db
    start C:\Windows\explorer.exe
    

    Views: 117

  • windows上的hash工具

    https://github.com/namazso/OpenHashTab
    这个项目是2019年首次发布的,比hashtab更强大,可以作为hashtab(https://implbits.com/hashtab)的替代,而且hashtab已经停止开发了

    Views: 42

  • 在新电脑上安装Windows7

    因为windows7安装镜像中缺少相关驱动在6代以后的cpu上无法识别U盘及USB键盘鼠标
    可以用技嘉的Windows USB Installation Tool集成缺失的驱动
    GIGABYTE Windows USB Installation Tool 使用说明​
    www.gigabyte.cn/webpage/-79/usb.html

    这个工具里面已经自带的各种驱动

    不过7代cpu不提供win7用的集成显卡驱动,所以如果7代以上cpu得有独立显卡。
    其它需要的资源
    Windows6.1-KB3033929-x64 支持sha265驱动签名
    Windows6.1-KB4474419-v3-x64 修复windows update失败
    ChromeSetup.exe windows7版本的chrome
    MicrosoftEdgeSetup.exe windos7版本的edge
    EIE11_ZH-CN_MCM_WIN764.EXE IE11,https://www.microsoft.com/en-us/download/details.aspx?id=41628
    SetupRST.exe rapid storage technology driver
    ndp48-web.exe dotnet framework 4.8
    mb_utility_windowsimagetool win7驱动封包工具,使用这个工具可以把驱动和补丁包集成到windows 7安装镜像中
    intel 驱动下载:https://www.intel.com/content/www/us/en/download-center/home.html
    nvidia驱动下载:https://www.nvidia.com/download/find.aspx
    realtek网卡驱动下载: https://www.realtek.com/zh-tw/component/zoo/category/network-interface-controllers-10-100-1000m-gigabit-ethernet-pci-express-software
    intel 7代以上cpu不再提供windows7的显卡驱动,nvidia 40以上的显卡不再提供windows7驱动,所以7代以上cpu安装windows7只能使用独显。nvidia要安装whql版的驱动

    Views: 82

  • http ping工具

    http ping工具可以测试http服务的运行情况,连接性能以及压力测试
    windows https://www.coretechnologies.com/products/http-ping/
    linux https://manpages.ubuntu.com/manpages/jammy/man1/httping.1.html
    linux 直接用apt或yum安装即可
    华为ar路由器用http get命令

    Views: 58

  • 3GPP R17的节能效果

    参考:
    https://mediatek-marketing.files.svdcdn.com/production/documents/MediaTek_White-Paper-R17-5G.pdf

    空闲状态

    连接状态

    由图可见在非连接状态下可节能20%左右,在通话状态下可节能30%左右,在高负载状态下可节能23%左右。以上数据都是与3GPP R16相比较。

    Views: 101

  • python捕获ctrl+c中断的两种方法

    1,try…except…

        try:
            while True:
                time.sleep(100)
        except KeyboardInterrupt:
            print('Got signal: SIGINT, shutting down.')
            exit(0)
    

    2, 信号处理

    def handler(signal_received, frame):
        # Handle any cleanup here
        if signal_received == signal.SIGINT:
            print('SIGINT or CTRL-C detected. Exiting gracefully')
            exit(0)
    if __name__ == '__main__':
        signal.signal(signal.SIGINT, handler=handler) # ctlr + c
    

    建议用try…except的方法,通用性强,代码易读性高。

    Views: 61

  • python实现非塞UDP通信的两种方法

    当使用阻塞式UDP socket时无法执行多任务处理,也无法与用户交互,甚至不能响应ctrl+c中断。为了解决这些问题所以要用非阻塞式udp通信。
    1,多线程法

    import socket
    import signal
    import threading
    import time
    
    def handler(signal_received, frame):
        # Handle any cleanup here
        if signal_received == signal.SIGINT:
            print('SIGINT or CTRL-C detected. Exiting gracefully')
            exit(0)
    
    def task(host, port):
        print("udp server is listen on " + str(host) + ':' + str(port))
    
        sock = socket.socket(socket.AF_INET, # Internet
                            socket.SOCK_DGRAM) # UDP
        sock.bind((UDP_IP, UDP_PORT))
    
        while True:
            data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
            print("from %s received message: %s" % (addr, data))
    
    if __name__ == '__main__':
        signal.signal(signal.SIGINT, handler=handler) # ctlr + c
    
        UDP_IP = "0.0.0.0"
        UDP_PORT = 5005
    
        t = threading.Thread(target=task, args=(UDP_IP, UDP_PORT))
        t.daemon = True
        t.start()
    
        while True:
            time.sleep(100)
    

    2, 协程法
    官方文档说不要在应用中使用asyncio,而是应该在框架中用

    import asyncio
    
    class EchoServerProtocol:
        def __init__(self, message, on_con_lost):
            self.message = message
            self.on_con_lost = on_con_lost
            self.transport = None
    
        def connection_made(self, transport):
            self.transport = transport
    
        def datagram_received(self, data, addr):
            print('Received %r from %s' % (data.decode(), addr))
            self.transport.sendto(data, addr)
        def error_received(self, exc):
            print('Error received:', exc)
        def connection_lost(self, exc):
            print("Connection closed")
            self.on_con_lost.set_result(True)
    
    async def main():
        print("Starting UDP server")
    
        # Get a reference to the event loop as we plan to use
        # low-level APIs.
        loop = asyncio.get_running_loop()
        on_con_lost = loop.create_future()
        message = 'Hello World!'
        # One protocol instance will be created to serve all
        # client requests.
        transport, protocol = await loop.create_datagram_endpoint(
            lambda: EchoServerProtocol(message, on_con_lost=on_con_lost),
            local_addr=('127.0.0.1', 9999),
            remote_addr=('127.0.0.1', 5005))
    
        try:
            while True:
                await asyncio.sleep(10)  # Serve for 1 hour.
        finally:
            transport.close()
    
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        print('Got signal: SIGINT, shutting down.')
        exit(0)
    

    Views: 89

  • 2022年世界各国人均GDP(IMF)

    该表默认以国际货币基金组织(IMF)公布的各国家或地区的最新估计值进行排名。如果IMF未能提供某个国家或地区的最新数据,则使用世界银行或联合国提供的最新数据排名。您也可选择列表中的Sort both.gif图标以选择其中一个来源重新排名。

    最左栏的排名数字不包括地区和非IMF成员国(在列表中使用 背景色 标记)。

    注:以下国家和地区无数据:福克兰群岛、直布罗陀、根西行政区、圣座(梵蒂冈)、泽西、纽埃、皮特凯恩群岛、圣赫勒拿、阿森松和特里斯坦-达库尼亚、托克劳和西撒哈拉。

    Views: 46

  • jenkins与gitlab集成实现自动构建

    • 安装插件
      https://github.com/jenkinsci/gitlab-api-plugin #GitLab API Plugin
      https://github.com/jenkinsci/gitlab-branch-source-plugin #GitLab Branch Source Plugin
      https://github.com/jenkinsci/basic-branch-build-strategies-plugin #Basic Branch Build Strategies
      https://plugins.jenkins.io/gitlab-oauth/ #GitLab Authentication
      https://plugins.jenkins.io/permissive-script-security/ #Permissive Script Security,这个只对sandbox中的脚本有效,非sandbox是不行的
    • 配置Gitlab Server
      1. 生成token

        这个token生成后要记好,一会儿要填到jenkins里面
      2. 配置system hook

        密码是在jenkins中设置的
      3. 创建应用

        密码是在jenkins中设置的
        这一步是用于oAuth认证
      4. 配置出站请求

        没有这一步会无法添加webhook
    • 配置Jenkins
      1. 配置Gitlab连接
      2. 配置认证

        然后就可以直接用gitlab帐号来登录jenkins
    • 创建Jenkins流水线
      1. 创建Folder Organization类型的Job
        如图

        这个类型的job会自动扫描指定用户或分组下的gitlab项目
        在owner中输入用户名或分组名(可以指定子组)
        在行为列表下面添加以下新的行为
        discover subgroup projects 支持扫描子组
        discover tags 支持扫描tag
        discover branches 发现分支
        advanced clone behaviours 自定义clone选项,用于clone时支持tags
        然后在build strategies里面添加(用于自动构建tag,默认不会)
        change requests
        regular branches
        tags
    1. 如果只针对单个项目创建流水线可以创建Multibranch Pipeline类型的项目
      其它具体的细节可以参考github上的README.md

    其它有用的插件:
    https://plugins.jenkins.io/pipeline-utility-steps/ Pipeline Utility Steps 常用steps集合
    https://plugins.jenkins.io/inline-pipeline/ Multibranch Pipeline Inline Definition 支持内联Jenkinsfile
    https://plugins.jenkins.io/pipeline-multibranch-defaults/ Multibranch with defaults 支持不同分支和项目共用Jenkinsfile
    https://plugins.jenkins.io/config-file-provider/ Config File Provider 用于配置文件
    存储
    https://plugins.jenkins.io/permissive-script-security/ Permissive Script Security
    注意:
    gitlab连接中配置的用户必须是git项目的成员,否则即使能拉取代码也无法同步jenkins的构建状态到gitlab
    用curl调用gitlab api(测试access token及api是否有效)
    curl –request POST \
    –header “PRIVATE-TOKEN: glpat-1234567890” \
    –url “https://git.hetao.me/api/v4/projects/test%2Ftest/statuses/3212877acf1bb58f05818c95cd981ef243e935d8?state=success”

    Views: 26

  • groovy正则表达式

    正则表达式是在文本中寻找子字符串的一种模式。

    • 定义正则表达式

      Groovy中正则表达式定义是通过 ~'正则表达式'定义的
      def regex =~'chese'

    • 常用正则表达式
    表达式 匹配意义 示例
    ^ 常用正则表达式
    $ 行尾。与字符串的尾部或换行符之前的位置相匹配。不包括换行符本身
    . 匹配除换行符以外的任意一个字符
    \w 字母和数字 [0-9A-Za-z]
    \W 非字母和数字。\w以外的单个字符
    \s 空字符 [\t\n\r\f]
    \S 非空字符
    \d 数字 [0-9]
    \D 非数字
    [] 指定字符范围 如:[0-9]
    * 前面元素至少出现0次
    + 前面元素至少出现1次
    {m} 前面的元素出现m 次
    {m,} 前面的元素至少出现m 次
    {m,n} 前面的元素出现至少m 次,至多n 次
    | 选择,匹配其中的任何一个 (a|b)*指a或b出现任意次
    () 正则表达式的群组化 (ab)* 指ab出现任意次
    [\u4E00-\u9FA5] 汉字
    [^\u4E00-\u9FA5] 非汉字
    • 运算符

      1. 匹配操作符(==~)

      用于检查字符串是否匹配 返回true或false
      如:

      if( "abc" ==~ /abc/)
      {
          println 'true'
      }
          else
      {
          println 'flase'
      }
      
      1. 查找操作符(=~)

      用于在字符串中查找匹配的子字符串

      def string = "id=12345"
      def matcher = string =~ /id=/
      def id = matcher.replaceAll('')
      println id  //运行结果为:12345
      

    转自:https://www.cnblogs.com/sky_online/archive/2010/05/14/1735712.html

    Views: 17