Skip to content

Instantly share code, notes, and snippets.

View leetschau's full-sized avatar

Leo leetschau

View GitHub Profile
@leetschau
leetschau / quadratic-form.Rmd
Created October 16, 2018 08:21
二次型的Python实现,用于测试 RStudio 中是否能够实现跨 chunk 的 Python 运行
---
title: "二次型系统的参数估计和异常检测"
output: html_notebook
---
二次型系统([Quadratic form](https://en.wikipedia.org/wiki/Quadratic_form))是只包含二次项,不包含常数和一次项的单变量或者多变量系统,例如下面分别是包含1, 2 和 3个特征变量的二次型系统:
$$
y = a x^2 \\
y = a x^2 + b xy + c y^2 \\
y = a x^2 + b y^2 + c z^2 + d xy + e xz + f yz
@leetschau
leetschau / wavelet-demo.py
Created September 30, 2018 02:12
基于小波分析实现图片降噪的实例
import numpy as np
import matplotlib.pyplot as plt
import pywt
original = pywt.data.camera()
noiseSigma = 16.0
image = original + np.random.normal(0, noiseSigma, size=original.shape)
@leetschau
leetschau / r2cor.md
Last active April 3, 2018 09:22
equation demo

Let $$ \begin{align} ss_{xy} = \sum(x_i - \bar x) (y_i - \bar y) \tag 1 \end{align} $$

@leetschau
leetschau / pivot_table_demo.py
Last active December 28, 2017 04:08
A Pandas Pivot Table Demo
import pandas as pd
import numpy as np
# based on [Pandas Pivot Table Explained](http://pbpython.com/pandas-pivot-table-explained.html)
# basic pivot table function
df = pd.read_excel('./sales-funnel.xlsx')
df['Status'] = df['Status'].astype('category')
df['Status'].cat.set_categories(["won", "pending", "presented", "declined"], inplace=True)
def meta = '''
{
"img": "../../../../static/img/treeImg/project.png",
"name": "财务预算",
"id": "1510126562947",
"open": true,
"level": 0,
"select": false,
"dictoryList": [
{
@leetschau
leetschau / boms.yaml
Created September 23, 2017 15:40
BOMS API
openapi: '3.0.0'
info:
title: BOMS API
description: BOMS API Specification
version: "0.1.1"
servers:
- url: localhost:8080
description: test server
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@leetschau
leetschau / uploadjars.py
Created March 14, 2017 09:15
uploading private jar files to local nexus server
#!/usr/bin/env python3
import os, sys, re, subprocess
group_id = 'com.fr'
repo_id = 'znbt'
repo_url = 'http://192.168.12.233:8081/repository/znbt/'
sample_settings = '''<settings>
<servers>
<server>
<id>znbt</id>
@leetschau
leetschau / docker-show-repo-tags.sh
Created September 26, 2016 08:45
list all tags of an image in docker hub
#!/bin/sh
# From: http://stackoverflow.com/a/34054903/701420
# Simple script that will display docker repository tags.
#
# Usage:
# $ docker-show-repo-tags.sh ubuntu centos
for Repo in $* ; do
curl -s -S "https://registry.hub.docker.com/v2/repositories/library/$Repo/tags/" | \
sed -e 's/,/,\n/g' -e 's/\[/\[\n/g' | \
grep '"name"' | \
@leetschau
leetschau / dsnote2evernote.py
Created September 17, 2016 10:06
将dsnote里面的笔记通过`geeknote create`命令同步到Evernote上
import os
import subprocess
basedir = '/home/leo/.donno/repo'
notebook = 'dsnote'
err_coll = []
for fn in os.listdir(basedir):
print('upload %s' % fn)
fullname = os.path.join(basedir, fn)