Skip to content

Instantly share code, notes, and snippets.

View kevinzhow's full-sized avatar
🏠
正在搬砖

Kevin kevinzhow

🏠
正在搬砖
View GitHub Profile
@kevinzhow
kevinzhow / NMPD.md
Last active November 30, 2022 16:36
在 macOS 10.12 配置 Nginx+MySQL+PHP+Discuz
@kevinzhow
kevinzhow / Alamofire+Protobuf.swift
Created November 28, 2022 18:23
Makes the alamofire can encode protobuf easily
import Foundation
import Alamofire
open class ProtobufParameterEncoder: ParameterEncoder {
/// Returns an encoder with default parameters.
public static var `default`: ProtobufParameterEncoder { ProtobufParameterEncoder() }
public init() {}
@kevinzhow
kevinzhow / route.sh
Last active October 2, 2022 08:01
AnyConnect 路由表
route = 8.0.0.0/255.0.0.0
route = 58.0.0.0/255.0.0.0
route = 23.0.0.0/255.0.0.0
route = 117.0.0.0/255.0.0.0
route = 199.0.0.0/255.0.0.0
route = 190.0.0.0/255.0.0.0
route = 198.0.0.0/255.0.0.0
route = 173.0.0.0/255.0.0.0
route = 174.0.0.0/255.0.0.0
route = 168.0.0.0/255.0.0.0
@kevinzhow
kevinzhow / ip_cook.rb
Created March 20, 2014 11:24
路由转换
#utf-8
require 'netaddr'
newfile = File.open("some_file", "w")
File.foreach('out_ip').with_index { |line, line_num|
line = line.split(',')[0].to_s
a = NetAddr::CIDR.create(line)
puts "#{a.ip}/#{a.wildcard_mask}"
newfile.write("route = #{a.ip}/#{a.wildcard_mask}\n")
@kevinzhow
kevinzhow / validator.swift
Created April 5, 2022 08:04
Example of How to create Validator in Vapor4
/// Define
extension Validator where T == String {
/// Validates whether a `String` is a valid email address.
public static var zipCode: Validator<T> {
.init {
guard
let range = $0.range(of: zipCodeRegex, options: [.regularExpression]),
range.lowerBound == $0.startIndex && range.upperBound == $0.endIndex
else {
return ValidatorResults.ZipCode(isValidZipCode: false)
@kevinzhow
kevinzhow / docker-compose.yml
Last active March 28, 2022 07:38
albatross
# albatross
version: '3.7'
services:
app:
image: ghcr.io/kevinzhow/albatross:latest
restart: unless-stopped
environment:
LOG_LEVEL: ${LOG_LEVEL:-debug}
ADMIN_USERNAME: albatross
extension AppThemeModeExt on AppThemeMode {
AppThemeData get themeData {
switch (this) {
case AppThemeMode.light:
return AppThemeData(
primaryColor: Color(0xFF28AA4B),
backgroundColor: Colors.white,
tileColor: Colors.white,
tableColor: Color(0xFFF3F3F3),
titleColor: Colors.black,
@kevinzhow
kevinzhow / GzipMiddleware.swift
Last active September 8, 2021 20:05
Vapor 4 Gzip middleware
//
// GzipMiddleware.swift
// GzipMiddleware
//
// Created by 周楷雯 on 2021/9/8.
//
// MARK: use https://docs.vapor.codes/4.0/server/#response-compression instead of this script
// MARK: Use this at end of app.middleware
@kevinzhow
kevinzhow / ocserv
Created March 20, 2014 11:15
ocserv 启动脚本
#!/bin/sh
### BEGIN INIT INFO
# Provides: ocserv
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
# Copyright Rene Mayrhofer, Gibraltar, 1999
# This script is distibuted under the GPL

Yep API Reference

概述

  • 基于 HTTP
  • RESTful
  • 采用标准 HTTP Code 返回错误
  • 返回格式为 JSON