Skip to content

Instantly share code, notes, and snippets.

View hackerain's full-sized avatar
😀
I may be slow to respond.

Guangyu Suo hackerain

😀
I may be slow to respond.
View GitHub Profile
@hackerain
hackerain / ping.sh
Created October 14, 2021 03:07
ping一个服务器通不通,如果ping通的话,则打印日志,并且退出
s=1
while (( $s >= 1 ))
do
ping -c 1 $1 >/dev/null 2>&1
s=$?
sleep 1;
done;
echo $1 >> ping.log
@hackerain
hackerain / prime.py
Created October 14, 2021 03:09
给出一组数字,求其中有几个素数
def isprime(n):
if n < 2:
return False
for i in range(2, n):
if n % i == 0:
return False
return True
nums = input("input: ")
from openpyxl import load_workbook
from datetime import datetime, date, time
import json
wb = load_workbook('/mnt/d/clockin.xlsx')
for ws in wb:
#ws = wb["3月"]
data = {}
@hackerain
hackerain / diff.py
Last active January 9, 2023 17:37
compare two huge lists
# -*- coding: utf-8 -*-
from multiprocessing import Process
index1 = set()
index2 = set()
print "reading index1"
with open("index1.txt") as f:
for line in f:
@hackerain
hackerain / es_composite_agg.java
Last active February 8, 2023 00:20
Get distinct values using elasticsearch composite aggregation java api
package com.example;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import java.util.ArrayList;