Skip to content

技术分享

分享有技术含量的内容哦~

3.4k Topics 19.1k Posts

Subcategories


  • 即刻图床

    问题反馈,相关讨论!

  • 建站经验

    建站经验分享!

  • 游戏Game

    网络游戏 / 单机游戏

  • 软件资源

    分享一些软件资源!

  • 美兔兔吧

    美图赏析~ 禁止露点~

  • 推荐!程序猿必读设计模式的网站

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • 音响有电流声

    3
    1 Votes
    3 Posts
    573 Views
    Y

    音响是直接接电路的?电路中是有噪声的,参考:https://www.bilibili.com/video/BV1QX4y1X797/

  • 网易获取用户IP/DNS的接口

    4
    0 Votes
    4 Posts
    760 Views
    白嫖达人

    https://only-655810-116-23-16-5.nstool.yqkk.link

  • Chatgpt Access denied

    5
    0 Votes
    5 Posts
    756 Views
    B

    https://chat.openai.com/chat

  • 国际虚拟预付卡比较

    1
    0 Votes
    1 Posts
    655 Views
    No one has replied
  • 3月2日分享修改版安卓20+款去广告,解锁会员软件

    1
    0 Votes
    1 Posts
    555 Views
    No one has replied
  • 安全牛至尊会员课程,速速收藏!

    4
    2 Votes
    4 Posts
    981 Views
    A

    有转阿里的嘛

  • 0 Votes
    1 Posts
    431 Views
    No one has replied
  • 分享一个提升 Chrome 鼠标滚动体验的设置,很流畅丝滑

    2
    0 Votes
    2 Posts
    667 Views
    malaohuM

    不行不行。单击鼠标滚轴 滚动会卡死。

  • 无限速在线文件传输网站wormhole,端到端,速度超快

    1
    0 Votes
    1 Posts
    599 Views
    No one has replied
  • chatgpt免注册、免登录、免代理体验(支持图片)

    3
    0 Votes
    3 Posts
    1k Views
    youhunY

    @marlkiller 语言不一样,直接上传就部署不好吗。 萝卜青菜各有所爱,挂着又不影响啥。 你直放原作者的不好吗,放你 fork 的😧

  • 听说阿里云盘解析挂了,发现已经用不了了

    3
    0 Votes
    3 Posts
    678 Views
    xhotX

    看这个 https://jike.info/topic/14391/

  • 求问这个发卡网站是哪个模板?

    3
    0 Votes
    3 Posts
    520 Views
    8

    @biglee 谢谢

  • 【转】多平台关键词监控&提醒系统

    1
    1 Votes
    1 Posts
    354 Views
    No one has replied
  • This topic is deleted!

    20
    0 Votes
    20 Posts
    45 Views
  • 一键检测能否访问官方ChatGPT脚本

    2
    1 Votes
    2 Posts
    2k Views
    鉴黄师

    替代文字

  • This topic is deleted!

    0
    0 Votes
    0 Posts
    140 Views
    No one has replied
  • This topic is deleted!

    0
    0 Votes
    0 Posts
    343 Views
    No one has replied
  • 翻译成golang代码

    3
    0 Votes
    3 Posts
    380 Views
    ChatGPTC

    malaohu说:

    malaohu 说:

    import os import time import redis env = os.environ.get REDIS_CONF = { "host": env("ALONE_REDIS_HOST", ""), "port": env("ALONE_REDIS_PORT", 6378), "password": env("ALONE_REDIS_PASSWORD", ""), "db": env("BUZZERS_REDIS_DB_LOCK", 1), "socket_timeout": None, "encoding": "utf-8", "encoding_errors": "strict", "decode_responses": True } connection_pool = redis.ConnectionPool(**REDIS_CONF) redis_lock = redis.Redis(connection_pool=connection_pool) redis_lock.ping() class RedisLock(object): """ redis原子锁 """ def __init__(self, prefix="redis_lock", key="", expire_time=2, timeout=2, interval=0.2): """ :param prefix: 原子锁前缀 :param expire_time: 锁过期时间 :param timeout: 最长等待秒数,默认2秒(timeout=0获取不到锁则立即返回) :param interval: 时间间隔 """ self.key = key self.prefix = prefix self.expire_time = expire_time self.timeout = timeout self.interval = interval self._lock = False # 是否获得锁 @property def rds_key(self): return "%s|%s" % (self.prefix, self.key) def __del__(self): """ 该对象释放的时候 删除锁 :return: """ if self._lock: self.delete_lock() def acquire(self): """ 获取用户锁,默认最长2秒等待 :return: True 获取到锁 False 获取锁失败 """ start_time = time.time() end_time = start_time + self.timeout while time.time() > result = redis_lock.set( self.rds_key, 1, ex=self.expire_time, nx=True ) if result: self._lock = True return True time.sleep(self.interval) return False def release(self): """ 删除用户锁 :return: """ redis_lock.delete(self.rds_key) self._lock = False def __enter__(self): if not self._lock: return self.acquire() return False def __exit__(self, type, value, traceback): if self._lock: self.release() def __del__(self): self.release()

    请将上面代码用golang实现一下

    package redis import ( "github.com/go-redis/redis/v7" "time" ) type RedisLock struct { Prefix string Key string ExpireTime int Timeout int Interval int _lock bool redisClient *redis.Client redisOptions *redis.Options } func NewRedisLock(prefix string, key string, expireTime int, timeout int, interval int) *RedisLock { return &RedisLock{ Prefix: prefix, Key: key, ExpireTime: expireTime, Timeout: timeout, Interval: interval, _lock: false, redisClient: nil, } } func (lock *RedisLock) GetRedisKey() string { return lock.Prefix + "|" + lock.Key } func (lock *RedisLock) InitRedisClient(options *redis.Options) { lock.redisClient = redis.NewClient(options) lock.redisOptions = options } func (lock *RedisLock) Acquire() bool { startTime := time.Now().Unix() endTime := startTime + int64(lock.Timeout) for time.Now().Unix() < endTime { result := lock.redisClient.SetNX(lock.GetRedisKey(), 1, time.Duration(lock.ExpireTime)*time.Second).Val() if result { lock._lock = true return true } time.Sleep(time.Duration(lock.Interval) * time.Second) } return false } func (lock *RedisLock) Release() { lock.redisClient.Del(lock.GetRedisKey()) lock._lock = false } func (lock *RedisLock) Lock() bool { if !lock._lock { return lock.Acquire() } return false } func (lock *RedisLock) Unlock() { if lock._lock { lock.Release() } }
  • chrome 支持划词右键翻译了

    1
    0 Votes
    1 Posts
    296 Views
    No one has replied