Skip to content

Instantly share code, notes, and snippets.

View henyihanwobushi's full-sized avatar

Donsen Hong henyihanwobushi

  • China University of Geoscience in Beijing
View GitHub Profile
import random
import math
import collections
def guess(history_actions, base_hotness=1, cooling_rate=1):
def hotness(time_passed, base_hotness=1, cooling_rate=1):
return base_hotness * math.exp(-1.0 * time_passed * cooling_rate)
action_hotness = collections.defaultdict(lambda: 0)
@henyihanwobushi
henyihanwobushi / BaseQueryValidator.java
Created March 19, 2023 13:37 — forked from piyusht007/BaseQueryValidator.java
SQL parsing in java using Apache-Calcite SQL parser.
public class BaseQueryValidator {
private static List<String> extractTableAliases(SqlNode node) {
final List<String> tables = new ArrayList<>();
// If order by comes in the query.
if (node.getKind().equals(SqlKind.ORDER_BY)) {
// Retrieve exact select.
node = ((SqlSelect) ((SqlOrderBy) node).query).getFrom();
} else {
node = ((SqlSelect) node).getFrom();
@henyihanwobushi
henyihanwobushi / settings.xml
Created September 30, 2021 17:48 — forked from python012/settings.xml
Maven settings.xml with aliyun mirror
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
@henyihanwobushi
henyihanwobushi / supervisord.conf
Last active July 7, 2018 07:31
supervisord.service
; Sample supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
;
; Notes:
; - Shell expansion ("~" or "$HOME") is not supported. Environment
; variables can be expanded using this syntax: "%(ENV_HOME)s".
; - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
@henyihanwobushi
henyihanwobushi / crontab
Created May 29, 2018 09:34
delete old logs
find /var/log/** -maxdepth 0 -mtime +15 -exec sudo rm -rf {} +
@henyihanwobushi
henyihanwobushi / kill_main.sh
Created May 22, 2018 03:44
kill specific process
sudo kill "$(pgrep Main)"
@henyihanwobushi
henyihanwobushi / simple_args_parsing.sh
Last active May 18, 2023 06:56 — forked from jehiah/simple_args_parsing.sh
a simple way to parse shell script arguments
#!/bin/sh
# a simple way to parse shell script arguments
# please edit and use to your own content
ENVIRONMENT="dev"
DB_PATH="/data/db"
function usage()
{
echo "if this was a real script you would see something useful here"
@henyihanwobushi
henyihanwobushi / hbase data model.txt
Last active September 6, 2024 08:55
hbase data model
SortedMap<RowKey, List<SortedMap<Column, List<Value, Timestamp>>>>
hdfs dfs -getmerge /hdfs/path/with/source/files /target/local/file
@henyihanwobushi
henyihanwobushi / chunk.py
Created February 6, 2018 06:15
pythonic array_chunk function
chunk = lambda arr, n: [arr[i::n] for i in range(arr)]