Zihan's BLOG

Design & Code

简介

Stocker是一款JetBrains IDE证券行情插件,主要功能是在IntelliJ IDEA和其他基于IntelliJ Platform的IDE(如PyCharm、RubyMine、WebStorm等)中实时追踪股票、加密货币的价格行情,其中股票支持A股、港股、美股。

运行时效果

安装

Stocker已上传至JetBrains Marketplace,打开IDE内的 Plugins,然后搜索Stocker,找到对应项并点击安装,安装完成后可能需要重启IDE,依据提示操作即可。

如何使用

添加股票、加密货币代码

点击Stocker窗口上的 弹出搜索窗口,利用关键字(代码、名字)找到目标标的,点击 Add 按钮:

管理已添加的股票、加密货币代码

点击Stocker窗口上的 弹出管理窗口,不同市场的标的归类在不同的Tab中,点击 Delete 可删除不再需要的标的:

停止刷新

Stocker会每5秒通过HTTP请求拉取最新数据,如果有时不希望占用网络(比如休市时段),可点击在窗口Action栏的停止刷新按钮。若要重新开始刷新,点击刷新按钮。

配置修改

Stocker的配置在Preferences/Settings -> Tools -> Stocker,当前支持修改配色:红涨绿跌、绿涨红跌、无配色:

其他操作

使用工具栏

Stocker的Action(搜索窗口、管理窗口、刷新、停止刷新)可在工具栏Tools -> Stocker中找到:

使用Action搜索

通过Action快速搜索也可触发Stocker的Action:

错误处理

如果遇到任何使用问题可以先尝试重装、重启。无法解决的问题可在GitHub提Issue

Preface

Recently, I start to code with Xcode for iOS/macOS application development. Inspired by the Xcode Default (Light) and Default (Dark) color themes, I migrated them to JetBrains IDEs.

Take a Look

Install

You can install this extension from the JetBrains Plugin Marketplaces, search Xcode Theme and you’ll find it.

Repository

If you enjoy this theme, consider a star at GitHub: WhiteVermouth/XcodeTheme.

We often debug iOS/macOS application in simulators when developing iOS/macOS application. Sometimes we need a clean simulator environment, so we have to reset simulators.

Here’s the steps:

Step One

Shutdown all simulators manually, or execute command:

1
xcrun simctl shutdown all

Step Two

Execute command:

1
xcrun simctl erase all

That’s it.

Last year, I created Dracula Theme extension for JetBrains IDEs. The source repo is included in the official Dracula Organization. If you want to try it out, all instructions can be found at here.

screenshot

However, except the free community maintained Dracula Theme(s) or UI(s), Zeno Rocha, who created Dracula, also launched the premium version: Dracula PRO.

Dracula PRO is featured as:

  • A color scheme and UI theme tailored for programming
  • Made for terminal emulators, code editors, and syntax highlighters.
  • Designed to be aesthetically pleasing while keeping you focused.

A bunch of theme variations are packaged in Dracula PRO, all of these goodies are to make developers more productive.

To learn more or get it, check out this link: Learn More

什么是 Kubernetes

我们都知道Docker容器,但是在生产环境中,仅仅有Docker还不够。当遇到应用自动化部署、容器伸缩和管理等问题时,我们需要一个容器编排系统。Kubernetes就是一个生产级的容器编排系统。

Kubernetes 基础

Pod:最小运行单元,由一个或多个容器组成
Deployment:常用的控制器
Service:用于服务注册、服务发现,作用域主要为 K8S 集群内部
Ingress:提供外部访问入口

从哪里获取 Kubernetes 集群

Kubernetes 集群可以自己搭建,也可以直接从云服务商购买。自行搭建较为复杂,且运维工作也会很复杂,使用云服务商的Kubernetes集群较为方便。

比较有名的Kubernetes提供商有:AzureAWSGCP、阿里云

上面这几家都是云计算大厂,稳定性更好,但是价格也会很高。

相对便宜的云服务可以选择:DigitalOceanLinode

编写 Snell 部署所需的资源配置文件

  1. 编写 ConfigMap 用于存储配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
apiVersion: v1
kind: ConfigMap
metadata:
name: snell-server-config
namespace: stage
labels:
app: surge-snell
data:
snell-server.conf: |-
[snell-server]
listen = 0.0.0.0:10000
psk = password
obfs = http
  1. 编写 DeploymentService 资源配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: snell-server
namespace: stage
labels:
app: surge-snell
spec:
replicas: 2
revisionHistoryLimit: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
selector:
matchLabels:
app: snell-server
template:
metadata:
labels:
app: snell-server
spec:
containers:
- name: snell-server
image: vermouthx/surge-snell:2.0.1
command: ["snell-server", "-c", "/etc/snell/snell-server.conf"]
volumeMounts:
- name: snell-config
mountPath: /etc/snell
resources:
limits:
memory: "128Mi"
cpu: "100m"
ports:
- containerPort: 10000
volumes:
- name: snell-config
configMap:
name: snell-server-config
restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
name: snell-service
namespace: stage
labels:
app: surge-snell
spec:
selector:
app: snell-server
ports:
- protocol: TCP
port: 10000
targetPort: 10000
  1. 使用 kubectl 创建上述资源
1
kubectl apply -f /path/to/resource

What is Dracula?

A dark theme for Atom, Alfred, Emacs, Highlight.js, Hyper, iTerm, JetBrains, Pygments, Slack, Sublime Text, TextMate, Terminal.app, Vim, Xcode, Zsh and many more.

Preface

Currently there already exists many Dracula theme or UI for many editors or tools. However the JetBrains port only includes Color Scheme, lacking the UI support. Before IDEA version 2019.1, you may use the Material Theme UI plugin to make IDEA and other IDEA based IDEs fully Dracula style.

Things changed after IDEA 2019.1 released, JetBrains add official support for Custom UI.

Dracula Theme Plugin

With the leverage of official Custom UI support, I make a new Dracula Theme for JetBrains IDEs. The theme is released at JetBrains Plugin Repository and open source at GitHub.

Install

All instructions can be found at draculatheme.com/jetbrains.

Hadoop 概述

什么是 Hadoop

  • 可扩展的、简洁的数据存储、处理及分析系统(生态)

  • 架构图

Hadoop 解决的问题

  1. 传统数据存储在一个中央数据库,当程序需要数据时,数据会被复制给程序
  2. 传统方式对于少量数据可以很好的处理,但不利于海量数据

Hadoop 的方案

  1. 数据分布式存储(HDFS)
  2. 程序计算直接在数据存储的地方运行
  3. 示意图

大数据的处理流程

数据采集

数据源

  • 传统数据库,如 MySQL
  • 日志和运行时产生的文件
  • 直接导入文件

数据采集工具

  • Flume
  • Kafka
  • Sqoop

Sqoop

  • 作用:将数据从传统数据库导入至 HDFS,或将数据从 HDFS 导出至传统数据库
  • 工作流程示意图:

  • Sqoop Shell 命令操作

数据存储

一、 HDFS

概念

  • Hadoop Cluster:多台计算机组成一个 Cluster,每台计算机称为 Node,Node 分为 MasterNode 和 WorkerNode

特点

  • 分布式
  • 块存储
    • NameNode 存储元数据
  • “write once”
  • 对大量的文件读取进行优化

使用

  • Shell
  • Spark
  • 其他程序

目录结构(Recommend)

  • /user:用户文件
  • /ert: Work in progress in Extract/Transform/Load stage
  • /tmp: 临时文件
  • /data: 通用数据
  • /app: 无数据文件,如配置文件

Yarn

  • HDFS 的一个资源调度工具
  • Daemons
    • Resource Manager
    • Node Manager
  • Application
    • Container
    • Application Master

二、 HBase

数据处理

一、 Spark

Spark Shell

  • Python Shell
  • Scala Shell

RDD (Resilient Distributed Dataset)

  1. 创建 RDD

    • 从文件创建

      1
      val mydata = sc.textFile("purplecow.txt")
    • 从内存中的数据创建

    • 从其他 RDD 创建

  2. RDD Operations

    • Actions
      • count()
      • take(n)
      • collect()
      • saveAsTextFile(file)
    • Transformations
      • map(function)
      • filter(function)
      • Lazy Execution
      • Chain Transformations

函数式编程

  • 伪代码:
1
2
3
4
5
RDD {
map(fn(x)) {
foreach record in rdd
emit fn(record)
} }
  • Scala
1
2
mydata.map(line => line.toUpperCase()).take(2)
mydata.map(_.toUpperCase()).take(2) // 匿名参数

二、 MapReduce

三、 Pig

数据分析

  • Impala
  • Hive

Feature

  • 提供 SQL 的方式查询 HDFS/HBase 的数据
  • 示意图

  • Impala 直接操作 HDFS
  • Hive 通过 MapReduce 操作 HDFS

Why Hive or Impala

  • Brings large-scale data analysis to a broader audience
  • More produc.ve than wri.ng MapReduce or Spark directly
  • Offers interoperability with other systems

使用

  • Impala Shell
  • BeeLine (Hive Shell)

注意

  • Impala 和 Hive 提供 SQL 方式与存储层交互,但此时的 Cluster 不能等同于传统的关系数据库
  • Impala/Hive 同传统关系型数据库的对比图

知识体系图

0.基本概念

体言:包括名词、代词、数词
用言:包括动词、形容词、形容动词

1.判断句

体言体言です—肯定(……是……)
体言体言ではありません—否定(……不是……)

例句:

  • わたしは大(だい)学(がく)院(いん)生(せい)です。/我是研究生。
  • 専(せん)攻(こう)は中(ちゅう)国(ごく)語(ご)です。/专业是中文。
  • 彼(かの)女(じょ)は主(しゅ)婦(ふ)ではありません。/她不是家庭主妇。

2.领格助词 の

3.こそあど系词汇

4.终助词 か(疑问)

Core Concept

What is CI

Continuous Integration is the practice of merging in small code changes frequently - rather than merging in a large change at the end of a development cycle. The goal is to build healthier software by developing and testing in smaller increments. This is where Travis CI comes in.

.travis.yml may contain…

  • What programming language your project uses
  • What commands or scripts you want to be executed before each build (for example, to install or clone your project’s dependencies)
  • What command is used to run your test suite
  • Emails, Campfire and IRC rooms to notify about build failures

Lifecycle

  1. apt addons (optional)
  2. cache components (optional)
  3. before install
  4. install
  5. before_script
  6. script
  7. before_cache (optional)
  8. after_success or after failure
  9. before_deploy (optional)
  10. deploy (optional)
  11. after_deploy (optional)
  12. after_script

Build Docker Image

Create docker-compose.yml and edit like following codes:

1
2
3
4
5
6
7
8
9
10
11
12
13
tomcat:
image: "tomcat:latest"
ports:
- "127.0.0.1:8000:8000"
- "127.0.0.1:8888:8080"
environment:
- JPDA_ADDRESS=8000
- JPDA_TRANSPORT=dt_socket
volumes:
- /path/to/war/file/directory:/usr/local/tomcat/webapps
container_name: tomcat-literature
command: "/usr/local/tomcat/bin/catalina.sh jpda run"
restart: always

The key point in the config file is the two environment variables:

1
2
JPDA_ADDRESS=8000
JPDA_TRANSPORT=dt_socket

Caveat

You may set the JPDA_ADDRESS value *:8000, which makes Tomcat listen on 0.0.0.0 other than 127.0.0.1.

Run Docker Container

In the directory of docker-compose.yml, execute command:

1
docker-compose up -d

Debug in IDEA

  1. add a Remote Run Configuration

  1. set a breakpoint in your program anywhere you like

  2. swith to Run Configuration which setup in first step, and click debug

0%