Skip to content

Instantly share code, notes, and snippets.

@tupunco
tupunco / Netflix.js
Created January 5, 2012 09:19 — forked from rbartholomew/Netflix.js
Netflix Windows 8
(function () {
'use strict';
var clientKey = "XXXXXXXXXXXXXX";
var clientSecret = "XXXXXXXXXXXX";
var oauthToken;
var oauthSecret;
var userId;
var loginUrl;
var applicationName;
@tupunco
tupunco / ConcurrentConsumerQueue.cs
Last active August 29, 2015 13:59
ConcurrentConsumerQueue 并行消费者队列
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Tup.Utilities
{
/// <summary>
/// 并行消费者队列
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace SuffixTreeAlgorithm
{
public class SuffixTree
{
public class Tree
{
/// <summary>
/// store the tree's root
/// </summary>
private Node _root;
/// <summary>
/// construct a new tree with it's root
/// </summary>
@tupunco
tupunco / ConsistentHashing.cs
Last active March 26, 2020 07:46
Consistent Hashing C#, 一致性HASH
/// <summary>
/// 一致性 Hash 算法
/// </summary>
class ConsistentHashing
{
List<KeyValuePair<uint, string>> _serList = new List<KeyValuePair<uint, string>>();
public ConsistentHashing(string[] serList)
{
if (serList == null || serList.Length == 0)
@tupunco
tupunco / ExecuteAction.cs
Last active December 14, 2015 07:39
C# 同步/异步执行 控制台 命令
/// <summary>
/// Async Execute Command Action
/// </summary>
/// <param name="startFileName"></param>
/// <param name="startFileArg"></param>
/// <param name="msgAction"></param>
/// <returns></returns>
public static Task<bool> ExecuteActionAsync(string startFileName, string startFileArg, Action<string> msgAction)
{
ThrowHelper.ThrowIfNull(msgAction, "msgAction");
@tupunco
tupunco / DbTransactionConnection.cs
Last active October 17, 2019 06:44
Dapper extensions (For SQLServer/MySQL/SQLite)
using XHEdu;
namespace System.Data
{
/// <summary>
/// 包含 `已创建事务` 的 DbConnection
/// </summary>
public class DbTransactionConnection : IDbConnection
{
private IDbTransaction innerDbTransaction = null;
@tupunco
tupunco / SerializableDictionary.cs
Created December 14, 2015 07:38
XML Serializable Collections, 可 XML 序列化的 字典/HashSet 类型
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
namespace Tup.Utilities
{
/// <summary>
/// 支持XML序列化的泛型Dictionary类
@tupunco
tupunco / BizResult.cs
Created December 18, 2015 01:05
业务逻辑 返回结果
/// <summary>
/// 业务逻辑 返回结果
/// </summary>
/// <remarks>
/// 建议以本类型为返回对象的方法, 不要返回 null 对象.
///
/// 提供三种方法创建本实例:
/// 直接实例:
/// new BizResult<Dish>(...);
///
@tupunco
tupunco / golang_学习.go
Last active May 17, 2017 02:40
golang_学习
package main
import (
//"encoding/json"
"fmt"
//"os"
"sync"
"time"
)