Skip to content

Instantly share code, notes, and snippets.

View yicone's full-sized avatar

yicone

View GitHub Profile
package main
import "fmt"
// fibonacci 函数会返回一个返回 int 的函数。
func fibonacci() func() int {
n0 := 0
n1 := 1
return func() int {
n2 := n0 + n1
@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
@yicone
yicone / cal.css
Last active December 20, 2015 20:49
hhCal.js
/*==== calendar ==== */
.calendar_box {width:1168px;margin-bottom:20px;zoom:1;}
.calendar_box table {position:relative;float:left;width:554px;margin:0 30px 5px 0;overflow:hidden;zoom:1 ;}
.calendar_box caption {font:20px/42px "microsoft yahei";color:#24747b;}
.calendar_box caption a {display:block;height:42px;zoom:1;color:#24747b;}
.calendar_box table caption .pre,.calendar_box table caption .next {float:left;*display:inline;margin-right:-34px;width:34px;font:bold 26px/42px simsun;text-align:center;}
.calendar_box table caption .next {float:right;margin:0 0 0 -34px;}
.calendar_box table caption a:hover {background-color:#32c6c6;color:#fff;text-decoration:none;}
.calendar_box thead {border:1px solid #eee;}
.calendar_box th {width:78px;font:14px/34px "microsoft yahei";color:#999;}
@yicone
yicone / autoSetFrameHeight.js
Created July 24, 2013 07:24
Old Old autoSetFrameHeight
function autoSetFrameHeight(name) {
try {
var iframe;
if (!name) return;
iframe = document.getElementById(name);
if (iframe.contentDocument)
$("#" + name).height(iframe.contentDocument.height + "px");
else
$("#" + name).height(document.frames[name].document.body.scrollHeight + "px");
} catch (e) {
@yicone
yicone / AsyncActionManager.cs
Last active December 20, 2015 03:09
AsyncActionManager (internal supply buffering)
using System;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
namespace BufferingWorker
{
public class AsyncActionManager<TActionParam> where TActionParam : class
{
private BlockingCollection<ActionBag<TActionParam>> _q1 = new BlockingCollection<ActionBag<TActionParam>>(5000);