Skip to content

Instantly share code, notes, and snippets.

View staticor's full-sized avatar

SteveYagn staticor

View GitHub Profile
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 / 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
@staticor
staticor / SocketWindowWordCount.java
Last active February 25, 2019 19:12
first Flink application , used to wordcount
package myflink;
import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.windowing.time.Time;
import org.apache.flink.util.Collector;
public class SocketWindowWordCount {
@staticor
staticor / 404.html
Created February 23, 2019 15:02
hexo 404.html
<html>
<head>
<!-- hexo-inject:begin --><!-- hexo-inject:end --><meta charset="utf-8">
<title>404页面</title>
<style>
*{margin:0;padding:0;outline:none;font-family:\5FAE\8F6F\96C5\9ED1,宋体;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-khtml-user-select:none;user-select:none;cursor:default;font-weight:lighter;}
.center{margin:0 auto;}
.whole{width:100%;height:100%;line-height:100%;position:fixed;bottom:0;left:0;z-index:-1000;overflow:hidden;}
.whole img{width:100%;height:100%;}
.mask{width:100%;height:100%;position:absolute;top:0;left:0;background:#000;opacity:0.6;filter:alpha(opacity=60);}