Skip to content

Instantly share code, notes, and snippets.

View yanli0303's full-sized avatar

Yan Li yanli0303

View GitHub Profile
@yanli0303
yanli0303 / static-analysis-test-report2.jelly
Created January 12, 2018 22:25
Jenkins HTML email template for testing result
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define">
<html>
<head>
<title>${project.name}</title>
<style>
body table, td, th, p, h1, h2 {
margin:0;
font:normal normal
100% Georgia, Serif;
@yanli0303
yanli0303 / swift-extension-default-implementation.swift
Last active July 25, 2018 15:51
Swift 4 extension default implementation vs. inheritance
import Cocoa
// see https://team.goodeggs.com/overriding-swift-protocol-extension-default-implementations-d005a4428bda
protocol ToString {
func toString() -> String
}
extension ToString {
@yanli0303
yanli0303 / HttpStatusEnum.strings
Last active July 27, 2018 19:35
HTTP Status Swift Enumeration based on https://httpstatuses.com/
/// HTTP Status
"http_status_100" = "Continue";
"http_status_101" = "Switching Protocols";
"http_status_102" = "Processing";
"http_status_200" = "OK";
"http_status_201" = "Created";
"http_status_202" = "Accepted";
"http_status_203" = "Non-authoritative Information";
"http_status_204" = "No Content";
"http_status_205" = "Reset Content";
@yanli0303
yanli0303 / xcode-9-edit-in-scope.md
Created August 24, 2018 20:30
Xcode 9.4.1 edit in scope (rename a local variable)
  1. Set cursor to the variable name.
  2. Press and hold "SHIFT" key until all occurrences of the variable are highlighted.
  3. CMD + CTRL + E and start edit in scope.
[
{
"id": "zhongzisou",
"name": "种子搜",
"proxy": false,
"url": "https://zhongzidi1.com",
"paths": {
"time": "/list/{k}/{p}",
"size": "/list_length/{k}/{p}",
"hot": "/list_click/{k}/{p}"
@yanli0303
yanli0303 / micro-module-services.md
Last active August 31, 2020 18:07
Micro Module Services Programming Model

Micro Module Services Programming Model

"Micro Module Services" is a loosely coupled programming model that aims to solve below problems of centralized design patterns such as MVC:

  • Controllers tend to get bigger and bigger over time (and multiple developers), and overly complex.
  • Big controllers would become God objects when they take responsibility for handling all kinds of requests. They end up with lots of code and do all kinds of things, they know and have access to almost everything in an application.
  • Big controllers hurt the isolation of concerns, make it hard to refactor or delete code, require more and more efforts to maintain.
  • Libraries designed in centralized patterns aren't reusable, because it's hard to separate one of the functionalities from the central points such as controllers.
  • Unit testing is difficult as test cases need to mock dependencies.

The Micro Module Services programming model borrows concepts from microservices, it structures an application

@yanli0303
yanli0303 / how-to-capture-network-traffic-with-wireshark.md
Last active February 16, 2021 20:43
How to capture network traffic (TCP, UDP, Kerberos, HTTP, HTTPS...etc) with Wireshark

How to capture network traffic with Wireshark

This note introduces how to install and configure Wireshark to capture network traffics of following protocols:

  • TCP
  • UDP
  • Kerberos
  • HTTP
  • HTTPS
  • ...more
<?xml version="1.0" encoding="UTF-8"?>
<OfficeApp
xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0"
xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0"
xsi:type="MailApp">
<Id>092ed79b-a5ca-5fa1-ba67-aa2e9691a362</Id>
@yanli0303
yanli0303 / open-new-broswer-window-by-post-method.js
Created April 22, 2021 17:27
Open a new browser window using HTTP POST method.
/**
* Submit login form with POST method.
* @param {string} action The login page URL.
* @param {string} target The name of the iframe, or `_blank`;
* @param {object} params The dictionary of form data.
* @returns The form element inserted into the page.
*/
export const postForm = (action, target, params) => {
const form = document.createElement('form')
form.style.display = 'none'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="./style.css">
<title>Adopt Me</title>
</head>