Skip to content

Instantly share code, notes, and snippets.

View YabZhang's full-sized avatar
🎯
Focusing

YabZhang YabZhang

🎯
Focusing
  • Arizona State University
  • Arizona State University
View GitHub Profile
@YabZhang
YabZhang / smallchat.go
Last active November 5, 2023 12:30
smallchat.go
package main
import (
"bytes"
"flag"
"fmt"
"net"
"sync"
)
@YabZhang
YabZhang / markdown-details-collapsible.md
Created March 25, 2021 18:21 — forked from pierrejoubert73/markdown-details-collapsible.md
How to add a collapsible section in markdown.

A collapsible section containing markdown

Click to expand!

Heading

  1. A numbered
  2. list
    • With some
    • Sub bullets
@YabZhang
YabZhang / timeout_refine.go
Created May 21, 2020 17:54
timeout_refine
package main
import (
"fmt"
"time"
)
func main() {
fmt.Println("start...", time.Now())
timeout := time.After(1 * time.Second)
@YabZhang
YabZhang / timeout_demo1.go
Last active May 21, 2020 17:48
chan_timeout
package main
import (
"fmt"
"time"
)
func main() {
fmt.Println("start...", time.Now())
timeout := make(chan bool, 1) // 超时信号传输通道
@YabZhang
YabZhang / gilded_roas.py
Created December 1, 2019 07:53
GildedRoseRefact
# -*- coding: utf-8 -*-
class GildedRose(object):
def __init__(self, items):
self.items = items
def update_quality(self):
for item in self.items:
refresher_factory(item).refresh()
@YabZhang
YabZhang / orderedset.py
Created April 13, 2019 10:46
ordersed set
#!/usr/bin/env python3
from collections import MutableSet
from weakref import proxy
class Node(object):
__slots__ = ["prev", "next", "key", "__weakref__"]
@YabZhang
YabZhang / Dockerfile
Created October 21, 2018 11:20
Dockerfile Demo
# Use an official Python runtime as a parent image
# 使用官方的Python环境做为父镜像(parent)
FROM python:2.7-slim
# Set the working directory to /app
# 设置容器内的当前工作目录为 /app
WORKDIR /app
# Copy the current directory contents into the container at /app
# 复制当前文件夹内容到容器的 /app 目录下
@YabZhang
YabZhang / quiz.py
Last active August 16, 2017 17:31
quiz
#!/usr/bin/env python3
# Problem No.1
def get_pairs_helper(alist, total):
"""获取列表中和为total的一组元素"""
if not (alist and isinstance(alist, (list, tuple))):
return
alist.sort()
prev, next_ = 0, len(alist) - 1
@YabZhang
YabZhang / sparse_matrix.py
Created August 6, 2017 10:39
sparse matrix transpose
#!/usr/bin/env python3
class SparseMatrix(object):
"""二维稀疏矩阵"""
def __init__(self, row, col):
self.m = row - 1
self.n = col - 1
self.seq = []
@YabZhang
YabZhang / es_demo.py
Last active August 3, 2017 12:15
es demo
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from datetime import datetime
from elasticsearch_dsl import (
DocType, Date, Nested, Boolean,
analyzer, token_filter, InnerObjectWrapper, Keyword, Text, String
)
# 中文分词器