首页
关于
Search
1
git lg彩色显示日志
24 阅读
2
在 Ubuntu 22.04 LTS 中安装 Docker
19 阅读
3
CentOs/Ubuntu搭建上网x-ui
18 阅读
4
git使用多个源和多个分支
15 阅读
5
git保存账号密码
14 阅读
默认分类
网站搭建
Windows
Linux
Docker
OpenWrt
Hackintosh
Git
Python
Pandas
Web开发
JavaScript
FFmpeg
Demo
工具
刷机
油猴脚本
Excel
Chrome Extension
登录
Search
标签搜索
Pandas
读取
时区
Chrome
centos8
求和
Nginx
Typecho
404
csv
国际站
询盘导出
油猴脚本
bbr
Ubuntu
远程桌面
日志
log
数据清洗
打印机
野生程序猿
累计撰写
151
篇文章
累计收到
0
条评论
首页
栏目
默认分类
网站搭建
Windows
Linux
Docker
OpenWrt
Hackintosh
Git
Python
Pandas
Web开发
JavaScript
FFmpeg
Demo
工具
刷机
油猴脚本
Excel
Chrome Extension
页面
关于
搜索到
3
篇与
的结果
2023-04-16
一个切换ip的脚本
macOS设置为DHCP#!/bin/bash echo 设置网络Wi-Fi为固定DHCP sudo networksetup -setdhcp Wi-Fi sudo networksetup -setdnsservers Wi-Fi "Empty" echo "已将网络接口 en1 设置为使用 DHCP。" 设置为固定IP#!/bin/bash echo 设置网络Wi-Fi为固定ip(ChatGPT) sudo networksetup -setmanual "Wi-Fi" 192.168.123.52 255.255.255.0 192.168.123.22 sudo networksetup -setdnsservers "Wi-Fi" 192.168.123.22Windows设置为DHCP@echo off chcp 65001 setlocal EnableDelayedExpansion set "connection_name=以太网" set "ip_address=" set "gateway_address=" for /f "tokens=2 delims=:" %%f in ('netsh interface ip show address "%connection_name%" ^| findstr /c:"IP Address"') do set "ip_address=%%f" for /f "tokens=2 delims=:" %%b in ('netsh interface ip show address "%connection_name%" ^| findstr /c:"Default Gateway"') do set "gateway_address=%%b" set "ip_address=!ip_address: =!" set "gateway_address=!gateway_address: =!" echo 原%connection_name% 的 IP 地址是 %ip_address% echo 原%connection_name% 的 网关地址是 %gateway_address% netsh interface ipv4 set address "%connection_name%" static %ip_address% 255.255.255.0 192.168.0.50 netsh interface ipv4 set dns "%connection_name%" static 192.168.0.50 timeout /t 3 for /f "tokens=2 delims=:" %%a in ('netsh interface ipv4 show addresses "%connection_name%" ^| findstr /r /c:"IP Address.*:"') do ( set "ip_address=%%a" set "ip_address=!ip_address: =!" ) for /f "tokens=2 delims=:" %%b in ('netsh interface ipv4 show config "%connection_name%" ^| findstr /r /c:"Default Gateway.*:"') do ( set "gateway_address=%%b" set "gateway_address=!gateway_address: =!" ) echo 设置后IP地址是: %ip_address% echo 设置后网关地址是: %gateway_address% endlocal echo ===================== echo 设置完毕,3秒后将自动关闭窗口。 timeout /t 3 设置为固定IP@echo off chcp 65001 setlocal EnableDelayedExpansion set "connection_name=以太网" set "ip_address=" REM 将本机IP地址和DNS设置为自动获取 netsh interface ipv4 set address "%connection_name%" dhcp netsh interface ipv4 set dnsservers "%connection_name%" dhcp echo IP地址和DNS设置为自动获取。 timeout /t 3 for /f "tokens=2 delims=:" %%a in ('netsh interface ipv4 show addresses "%connection_name%" ^| findstr /r /c:"IP Address.*:"') do ( set "ip_address=%%a" set "ip_address=!ip_address: =!" ) for /f "tokens=2 delims=:" %%b in ('netsh interface ipv4 show config "%connection_name%" ^| findstr /r /c:"Default Gateway.*:"') do ( set "gateway_address=%%b" set "gateway_address=!gateway_address: =!" ) echo 设置后IP地址是: %ip_address% echo 设置后网关地址是: %gateway_address% endlocal echo ===================== echo 设置完毕,3秒后将自动关闭窗口。 timeout /t 3
2023年04月16日
2 阅读
0 评论
0 点赞
2023-04-12
一个模仿Telegram的密码输入框
实现步骤首先,在 HTML 代码中,使用了 input 标签和 type 属性将输入框定义为 password 类型:<input type="password" id="password-input" class="password-input" placeholder=" ">然后,使用 CSS 定义了输入框的样式,包括宽度、高度、内边距、字体大小、边框、边框半径、背景色和字体颜色等:.password-input { width: 100%; height: 50px; padding: 10px; font-size: 16px; border: 1px solid #ccc; border-radius: 10px; background-color: #fff; color: #333; }为了在输入框中显示提示文本,使用了 placeholder 属性。同时,使用了伪类 ::placeholder 来定义提示文本的样式,包括字体大小和颜色:.password-input::placeholder { color: #999; font-size: 16px; }为了在用户输入密码时向上移动输入框的标签,并在输入框获得焦点时改变输入框边框的颜色,使用了以下 CSS:.password-input:focus, .password-input:not(:placeholder-shown) { outline: none; border: 2px solid rgb(51,144,236); } .password-input:focus + label, .password-input:not(:placeholder-shown) + label { font-size: 12px; top: -8px; left: 8px; color: rgb(51,144,236); }最后,在 JavaScript 中,通过获取输入框的值并将其显示在警告框中来实现提交功能。此外,还使用了事件监听器来实现显示密码按钮的功能:const passwordInput = document.getElementById("password-input"); const togglePassword = document.getElementById("toggle-password"); const button = document.querySelector(".show-button"); togglePassword.addEventListener("click", function(event) { const type = passwordInput.getAttribute("type") === "password" ? "text" : "password"; passwordInput.setAttribute("type", type); togglePassword.classList.toggle("fa-eye"); togglePassword.classList.toggle("fa-eye-slash"); }); button.addEventListener("click", function(event) { alert("你输入的密码是:" + passwordInput.value); });通过使用 JavaScript 监听输入框中的输入事件,可以实现当用户开始输入密码时显示显示密码按钮和提交按钮的功能。这是通过在事件处理程序中检查输入框的值来实现的:passwordInput.addEventListener("input", function(event) { if (passwordInput.value !== "") { togglePassword.style.display = "block"; button.style.display = "block"; } else { togglePassword.style.display = "none"; button.style.display = "none"; } });这将根据输入框中的值来显示或隐藏按钮。当用户输入任何字符时,这将被视为输入框中已有值的信号,并显示按钮。如果输入框的值为空,则会隐藏按钮。完整代码<!DOCTYPE html> <html> <head> <title>输入密码</title> <style> * { box-sizing: border-box; } body { font-family: Arial, sans-serif; background-color: #ffffff; } h1 { text-align: center; margin-top: 50px; color: #333; } .input-box { position: relative; width: 300px; margin: 50px auto; } .password-input { width: 100%; height: 50px; padding: 10px; font-size: 16px; border: 1px solid #ccc; border-radius: 10px; background-color: #fff; color: #333; } .password-input::placeholder { color: #999; font-size: 16px; } .password-input:focus, .password-input:not(:placeholder-shown) { outline: none; border: 2px solid rgb(51,144,236); } .password-input:focus + label, .password-input:not(:placeholder-shown) + label { font-size: 12px; top: -8px; left: 8px; color: rgb(51,144,236); } label { position: absolute; top: 14px; left: 14px; font-size: 16px; color: #999; transition: all 0.3s; background-color: #ffffff; pointer-events: none; } .eye-icon { position: absolute; top: 16px; right: 15px; font-size: 16px; color: #999; cursor: pointer; } .show-button { position: absolute; color: white; bottom: -75px; right: 0px; width: 100%; height: 50px; background-color: rgb(51,144,236); border: none; border-radius: 10px; cursor: pointer; display: none; } .show-button:focus { outline: none; } .show-button:active { transform: translateY(2px); } .show-button i { color: #fff; font-size: 16px; } </style> </head> <body> <h1>请输入密码</h1> <div class="input-box"> <input type="password" id="password-input" class="password-input" placeholder=" "> <label for="password-input">输入密码</label> <i id="toggle-password" class="eye-icon fa fa-eye-slash" aria-hidden="true"></i> <button class="show-button" type="button" title="显示密码" tabindex="-1">下一步</button> </div> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <script> const passwordInput = document.getElementById("password-input"); const togglePassword = document.getElementById("toggle-password"); const button = document.querySelector(".show-button"); togglePassword.addEventListener("click", function(event) { const type = passwordInput.getAttribute("type") === "password" ? "text" : "password"; passwordInput.setAttribute("type", type); togglePassword.classList.toggle("fa-eye"); togglePassword.classList.toggle("fa-eye-slash"); }); passwordInput.addEventListener("input", function(event) { if (passwordInput.value !== "") { togglePassword.style.display = "block"; button.style.display = "block"; } else { togglePassword.style.display = "none"; button.style.display = "none"; } }); button.addEventListener("click", function(event) { alert("你输入的密码是:" + passwordInput.value); }); </script> </body> </html>
2023年04月12日
3 阅读
0 评论
0 点赞
2022-10-19
Python统计时间段频次demo
import datetime import pandas as pd # from pprint import pprint from pytz import timezone,all_timezones fmt = "%Y-%m-%d %H:%M:%S %Z%z" # Current time in UTC now_utc = datetime.datetime.now(timezone('UTC')) print(now_utc.strftime(fmt)) # Convert to US/Pacific time zone now_pacific = now_utc.astimezone(timezone('US/Pacific')) print(now_pacific.strftime(fmt)) now_pabeijing = now_utc.astimezone(timezone('Asia/Shanghai')) print(now_pabeijing.strftime(fmt)) # for zone in all_timezones: # if 'Asia' in zone: # print(zone) def get_loacl(x): if type(x['时间']) == str: time_str = x['日期']+' '+x['时间'] dt = datetime.datetime.strptime(time_str,'%Y/%m/%d %H:%M PDT') dt = timezone('US/Pacific').localize(dt) dt_beijing = dt.astimezone(timezone('Asia/Shanghai')) print(time_str,dt,dt_beijing) return dt_beijing else: return x['时间'] def calc_hours(df): # 生成24小时时间段 times = [] for i in range(24): times.append({'时间段': '{0}时'.format(i), 'section': (i, i + 1), '计数': 0}) # 处理带PDT的时间 df['hours'] = df.apply(lambda x: datetime.datetime.strptime(x['日期']+x['时间'],'%Y/%m/%d%H:%M PDT') if type(x['时间']) == str else x['时间'],axis=1) df['locals'] = df.apply(lambda x: get_loacl(x),axis=1) print(df) # 循环统计 for i,r in df.iterrows(): for tx in times: if tx['section'][0] <= r['locals'].hour < tx['section'][1]: tx['计数'] = tx['计数'] + 1 break # 转为dataframe dt = pd.DataFrame(times).drop(['section'],axis=1) return dt df = pd.read_excel('./亚马逊订单2022-10-19.xlsx',usecols=['日期','时间'],sheet_name='订单详情') d = calc_hours(df) print(d)import datetime import random # 生成随机测试时间数量 from pprint import pprint SAMPLE_COUNT = 10 SECTION = 'section' SUM = 'sum' def my_time(): times = [] for i in range(24): times.append({SECTION: (i, i + 1), SUM: 0}) cnt = 0 while True: h = random.randint(0, 23) m = random.randint(0, 59) t = datetime.time(hour=h, minute=m) for tx in times: if tx[SECTION][0] <= t.hour < tx[SECTION][1]: tx[SUM] = tx[SUM] + 1 pprint(f'{t.strftime("%H:%M")} @ {tx[SECTION]}') break cnt = cnt + 1 if cnt > SAMPLE_COUNT: break return times if __name__ == '__main__': timex = my_time() pprint(timex)
2022年10月19日
2 阅读
0 评论
0 点赞