Skip to content

Instantly share code, notes, and snippets.

View staticor's full-sized avatar

SteveYagn staticor

View GitHub Profile
@staticor
staticor / Pascall-Triangle.py
Created October 17, 2019 23:37
Leetcode一些编程小练习
class Solution:
def getRow(self, rowIndex: int) -> List[int]:
if rowIndex < 0:
return []
ans = [1]*(rowIndex+1)
for i in range(rowIndex):
ans[i+1] = ans[i]*(rowIndex-i)//(i+1)
return ans
class Solution:
def romanToInt(self, s: str) -> int:
d = {'I':1, 'IV':3, 'V':5, 'IX':8, 'X':10, 'XL':30, 'L':50, 'XC':80, 'C':100, 'CD':300, 'D':500, 'CM':800, 'M':1000}
return sum(d.get(s[max(i-1, 0):i+1], d[n]) for i, n in enumerate(s))
@staticor
staticor / lstsq.py
Created September 29, 2019 00:46
Least Square Method in Linear Regression.
# Linear Least Squares
def lstsq(a, b, cond=None, overwrite_a=False, overwrite_b=False,
check_finite=True, lapack_driver=None):
"""
Compute least-squares solution to equation Ax = b.
Compute a vector x such that the 2-norm ``|b - A x|`` is minimized.
Parameters
@staticor
staticor / squirrel.custom.yaml
Created August 8, 2019 16:21
squirrel 配置
# squirrel.custom.yaml
patch:
# us_keyboard_layout: true # 键盘选项:应用美式键盘布局# show_notifications_when: growl_is_running # 狀態通知,默認裝有Growl時顯示,也可設爲全開(always)全關(never)
style/color_scheme: demo # 选择配色方案
style/horizontal: true# 候选窗横向显示# style/inline_preedit: false # 关闭内嵌编码,这样就可以显示首行的拼音(MAC下不建议开启)
style/corner_radius: 3# 窗口圆角半径
style/border_height: 4# 窗口边界高度,大于圆角半径才有效果
tyle/border_width: 4# 窗口边界宽度,大于圆角半径才有效果# style/line_spacing: 1 # 候选词的行间距# style/spacing: 5 # 在非内嵌编码模式下,预编辑和候选词之间的间距
style/font_face: "Lantinghei TC Extralight"# 预选栏文字字体,使用中文字体:兰亭黑-纤黑
style/font_point: 17#预选栏文字字号
@staticor
staticor / Pydata.py
Last active August 7, 2019 16:57
pydata 数据分析常用
def shoq(a, silent=True, step=0.05, label="label"):
''' quantile research'''
x = []
y = []
for i in np.arange(0, 1, step):
x.append(i)
y.append(a.quantile(i))
if not silent:
print(i, a.quantile(i))
plt.plot(x, y, label=label)
@staticor
staticor / azkaban-statu.sql
Last active June 24, 2019 10:15
Azkaban-Status统计
select ifnull( status , 'TOTAL') status, count( flow_id ) exec_num
from (
select exec_id, project_id, flow_id
, case
when status = 50 then 'success'
when status = 60 then 'killed'
when status = 70 then 'failed'
@staticor
staticor / squirrel.custom.yaml
Created June 5, 2019 01:29 — forked from singlepig/squirrel.custom.yaml
Rime主题配色,模仿官网rime.im配图
# modified from https://gist.github.com/deamwork/7cfb49777c2f163a475c71521cf7dd6e
# preview https://i.loli.net/2017/12/11/5a2d782e2f695.png
rimeblue:
name: "RimeBlue"
horizontal: false # 候选条横向显示
inline_preedit: true # 启用内嵌编码模式,候选条首行不显示拼音
candidate_format: "%c.\u2005%@\u2005" # 用 1/6 em 空格 U+2005 来控制编号 %c 和候选词 %@ 前后的空间。
corner_radius: 10 # 候选条圆角半径
border_height: 0 # 窗口边界高度,大于圆角半径才生效
@staticor
staticor / tmux.md
Created May 22, 2019 23:48 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

create table temp.result
as
select uid, dtnum
from (
select uid, rndiff, dtnum
, row_number() over ( partition by uid order by dtnum desc ) rk
from (
select uid, rndiff, count(dt) dtnum
from (
@staticor
staticor / HotItems.java
Created February 26, 2019 09:55
Flink- example 2 计算热门商品, wuchong blog - code
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0