Skip to content

Instantly share code, notes, and snippets.

@moon03432
moon03432 / clickhouse-use-string-as-bytes.go
Created October 13, 2020 10:23
Golang example to insert bytes into ClickHouse as String type
package main
import (
"bytes"
"database/sql"
"fmt"
"log"
"time"
"github.com/ClickHouse/clickhouse-go"
@moon03432
moon03432 / get-current-time.cpp
Created October 28, 2019 02:00
get current time (C++)
#include <iostream>
#include <chrono>
#include <ctime>
using namespace std;
int main() {
chrono::time_point<chrono::system_clock> timePoint = chrono::system_clock::now();
time_t now = chrono::system_clock::to_time_t(timePoint);
cout << ctime(&now) << endl;
@moon03432
moon03432 / sets.py
Last active October 12, 2019 07:32
manipulate sets union / intersection
#!/usr/bin/env python3
# coding=utf-8 (for Python 2)
# return: a list of lists. inner list performs intersection, outer list performs union
# for example: [[1,2], [3,4]] means (1 ∩ 2) ∪ (3 ∩ 4)
def union(groups, operators):
if len(groups) == 1:
return [groups]
if len(groups) == 2 and len(operators) == 1:
if operators[0] == '∪':