Skip to content

Instantly share code, notes, and snippets.

View yicone's full-sized avatar

yicone

View GitHub Profile
@yicone
yicone / StateMachine.java
Created June 2, 2020 07:00
基于枚举的FSM(有限状态机)
package com.yonyou.dmscloud.passengerflow.domain.model;
public class StateMachine {
ReceptionRecord context;
State state;
StateMachine(ReceptionRecord context) {
this.context = context;
this.state = State.Initial;
@yicone
yicone / EF 批量修改+旧值保留.cs
Last active May 12, 2018 01:38
“旧值保留”:勾选项切换为未勾选时,并不删除整项或者变更属性值,而仅是在数据库中将其标记为未勾选
public void ModifyInstsAndChannels(ChannelEditRequest request)
{
var merchantInsts = _dbfd.MerchantInst.Where(mi => mi.MerchantId == request.MerchantId).ToList();
var query = (from miNew in request.MerchantInsts
join mi in merchantInsts
on miNew.InstCode equals mi.InstCode into g
from miOld in g.DefaultIfEmpty()
select new { miNew, miOld });
var list = query.ToList();
foreach (var pair in list)
package main
import (
"io"
"os"
"strings"
)
func convert(b byte) byte {
switch {
package main
import "fmt"
// fibonacci 函数会返回一个返回 int 的函数。
func fibonacci() func() int {
n0 := 0
n1 := 1
return func() int {
n2 := n0 + n1
package main
import "fmt"
// fibonacci 函数会返回一个返回 int 的函数。
func fibonacci() func() int {
n0 := 0
n1 := 1
return func() int {
n2 := n0 + n1
package main
import "fmt"
// fibonacci 函数会返回一个返回 int 的函数。
func fibonacci() func() int {
n0 := 0
n1 := 1
return func() int {
n2 := n0 + n1
@yicone
yicone / 0_reuse_code.js
Created November 28, 2015 13:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@yicone
yicone / a.java
Created August 3, 2015 17:04
演示响应结果(Response)包含正文(Body),以及正文包含返回码(code)的接口风格中,正文不应为空
public class Order {
public int orderId;
}
public static class OrderService {
private static Order[] s_orders = new Order[3];
public static Response findOrder(final int orderId) {
Response resp = new Response();
@yicone
yicone / gist:163e7359aa73121c8f16
Created April 12, 2015 04:32
"variable @form-group-margin-bottom is undefined"
# old version is 3.3.2, update to 3.3.4
bower update bootstrap --save