Skip to content

Instantly share code, notes, and snippets.

View cadl's full-sized avatar
😀

cadl cadl

😀
  • Beijing
View GitHub Profile
@cadl
cadl / demo.scala
Created September 4, 2020 03:10
hudi-schema-compatibility-check-demo
val existedDf = spark.sql("select 1 as a, '' as b, 1 as __row_key, 0 as __row_version")
val testTable = "foo"
val testConf = Map(
"hoodie.table.name" -> testTable,
"hoodie.avro.schema.validate" -> "true",
"hoodie.datasource.write.recordkey.field" -> "__row_key",
"hoodie.datasource.write.table.name" -> testTable,
"hoodie.datasource.write.precombine.field" -> "__row_version",
@cadl
cadl / myclean.zsh-theme
Last active June 11, 2019 07:13
myclean.zsh-theme
if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="white"; fi
PROMPT='%{$fg[$NCOLOR]%}%B%n%b%{$reset_color%}:%{$fg[blue]%}%B%~/%b%{$reset_color%} $(git_prompt_info)%(!.#.$) '
RPROMPT='[%*]'
# git theming
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}(%{$fg_no_bold[yellow]%}%B"
ZSH_THEME_GIT_PROMPT_SUFFIX="%b%{$fg_bold[blue]%})%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_CLEAN=""
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_bold[red]%}✗"
@cadl
cadl / hehe.json
Last active July 24, 2018 08:46
hehe
{"info":{"version":"1.0.0","description":"\n## \u5173\u4e8e\u63a5\u53e3\u8c03\u7528\n\u63a5\u53e3\u901a\u8fc7 http \u534f\u8bae\u8c03\u7528\u3002\u6240\u6709\u63a5\u53e3\u7684 http method \u5168\u90e8\u4e3a POST\u3002\u6240\u6709\u63a5\u53e3\u7684 http \u72b6\u6001\u7801\u5168\u90e8\u4e3a 200\uff08\u662f\u5426\u8c03\u7528\u6210\u529f\u53c2\u8003\u8fd4\u56de\u7684\u4e1a\u52a1\u72b6\u6001\u7801\uff09\u3002\u6240\u6709\u63a5\u53e3\u7684\u4e1a\u52a1\u53c2\u6570\u5e8f\u5217\u5316\u4e3a json \u5b57\u7b26\u4e32\uff0c\u901a\u8fc7 http body \u4f20\u9012\u3002\u9274\u6743\u53c2\u6570\u901a\u8fc7 http header \u4f20\u9012\n## \u5173\u4e8e api \u7b7e\u540d\u9274\u6743\n\u5bf9\u4e8e\u6240\u6709\u7684\u63a5\u53e3\u8c03\u7528\uff0c\u8c03\u7528\u65b9\u90fd\u9700\u8981\u6dfb\u52a0\u7b7e\u540d\u53c2\u6570\u3002\u5e73\u53f0\u4f1a\u4e3a\u8c03\u7528\u65b9\u751f\u6210 apiKey \u548c apiSecret\n\u7b7e\u540d\u76f8\u5173\u6570\u636e\u901a\u8fc7 http header \u4f20\u9012\u3002http header key \u5206\u522b\u4e3a\uff1a\n- X-XCF-OPENAPI-KEY
@cadl
cadl / atfield.py
Created May 24, 2018 06:30
atfield
# coding: utf-8
import functools
import time
from threading import local
from collections import deque
class ATFieldException(Exception):
pass
@cadl
cadl / gist:093170b79d9071e59cb5
Created July 30, 2014 07:49
multiprocess decorator
import functools
from multiprocessing import Process, Manager
def multiprocess_run(process_num):
def returning_wrapper(func, index, return_dict, *args, **kwargs):
return_dict['proc'+str(index)] = func(*args, **kwargs)
def wrap(f):
return_dict = Manager().dict()
@cadl
cadl / .jshintrc
Last active August 29, 2015 14:00 — forked from haschek/.jshintrc
{
// --------------------------------------------------------------------
// JSHint Configuration, Strict Edition
// --------------------------------------------------------------------
//
// This is a options template for [JSHint][1], using [JSHint example][2]
// and [Ory Band's example][3] as basis and setting config values to
// be most strict:
//
// * set all enforcing options to true
@cadl
cadl / simple_server2
Created March 17, 2014 14:47
simple_server2
#define MAX_EVENTS 512
#define LOCK_NAME ".server.lock"
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <assert.h>
@cadl
cadl / simple_server
Created March 17, 2014 11:03
simple_server
#define MAX_EVENTS 512
#define LOCK_NAME ".server.lock"
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <assert.h>
@cadl
cadl / gist:6609683
Last active December 23, 2015 08:39
all_permutation
def all_perm(l):
if not l:
return [[]]
return [[a] + b for a in l for b in all_perm(_remove(l, a))]
def _remove(l, item):
tmp = l[:]
tmp.remove(item)
return tmp
@cadl
cadl / gist:4038339
Created November 8, 2012 11:44
labyrinth
import Queue
queue = Queue.Queue()
valueSet = set()
valueProc = [(lambda x: x/2+7, 1), (lambda x: (x+7)/2, 0), (lambda x: x*3-5, 3),(lambda x: (x-5)*3, 2)]
valueTry = [(lambda x: (x-5), 2), (lambda x: x*3, 3)]
def check(value, state):
for f, s in valueTry:
if not state == s: