Skip to content

Instantly share code, notes, and snippets.

@aclisp
aclisp / LongLivedScheduler.java
Last active April 30, 2024 11:44
一个分布式调度器,能执行持续10小时以上的长时间定时任务
package cloud.youxin.logserver.controller;
import cloud.youxin.logserver.config.SchedulerConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.script.DefaultRedisScript;
@aclisp
aclisp / hex_dump.lua
Created November 30, 2023 01:10 — forked from Elemecca/hex_dump.lua
Lua function which creates a hex dump of a binary string.
function hex_dump (str)
local len = string.len( str )
local dump = ""
local hex = ""
local asc = ""
for i = 1, len do
if 1 == i % 8 then
dump = dump .. hex .. asc .. "\n"
hex = string.format( "%04x: ", i - 1 )
@aclisp
aclisp / cron.go
Last active November 2, 2023 08:38
优雅结束的定时任务
package job
import (
"fmt"
"git.yy.com/ihago/yalert/v2"
"git.yy.com/ihago/ylog"
"git.yy.com/ihago/ylog/zap"
"git.yy.com/ihago/yruntime"
"github.com/robfig/cron/v3"
"hago-room-srv-metrics2/util"
@aclisp
aclisp / script.sh
Created July 19, 2020 08:38 — forked from sergeycherepanov/script.sh
shallow update not allowed
Here's what I ended up doing - it worked perfectly. Note that I was moving from my old host (Bitbucket) to my new one (Gitlab). My comments are above the commands:
# First, shallow-clone the old repo to the depth we want to keep
git clone --depth=50 https://[email protected]/....git
# Go into the directory of the clone
cd clonedrepo
# Once in the clone's repo directory, remove the old origin
git remote remove origin
@aclisp
aclisp / notes.md
Created July 7, 2020 07:55
搭建开发环境 yarn typescript eslint standard

安装

  • npm install --global yarn
  • yarn init
  • yarn add eslint typescript standard --dev
  • eslint --init
  • 调整 tsconfig.json 和 .eslintrc.json

运行

@aclisp
aclisp / notes.md
Last active July 7, 2020 07:53
Git Workflow
  • 拉开发分支 git checkout -b {branch} master
    • 有改动后, git push --set-upstream origin {branch}
  • 跟上 master 的最新改动
    • git checkout {branch}
    • git fetch origin
    • git rebase origin/master
  • 自己的分支,合并多次小提交
    • git rebase -i 3a4226b
    • 请注意3a4226b这个版本是不参与合并的,可以把它当做一个坐标
  • git push origin +{branch}
@aclisp
aclisp / mongo.js
Created December 12, 2019 09:32
MongoDB Shell Scripts
var now = Math.floor(Date.now() / 1000)
var db = connect("10.70.0.140:10002/admin", "ikdx_admin", "vws6XGl78Q4D")
db = db.getSiblingDB("channel_biz")
var table = db.getCollection('fixed_pos_channels')
var cursor = table.aggregate([
{"$group": {_id:"$cid", count:{$sum:1}}}
])
@aclisp
aclisp / redis-example.py
Last active October 4, 2021 15:42
Install python3 jupyter notebook on Ubuntu 16.04
import sys
import os.path
import configparser
import mmh3
import math
import redis
import time
import requests
import json
@aclisp
aclisp / evaluate.py
Last active April 22, 2019 07:45
Recommendation using Python
def calc_precision_recall(recommend_method, training_data, testing_data, user_colname, item_colname, sim_matrix, top_k):
users_testing_and_training = list(
set( testing_data[user_colname].unique() ).intersection(
set( training_data[user_colname].unique() ))
)
hit = 0
n_recall = 0
n_precision = 0
for user in users_testing_and_training:
@aclisp
aclisp / selenium-youtube.py
Created November 3, 2018 11:32
Youtube Comment Bot using Selenium
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as expect
from selenium.webdriver.common.keys import Keys
import time
from random import randint
def delay(n):