Skip to content

Instantly share code, notes, and snippets.

View xbotter's full-sized avatar
:octocat:

xbotter xbotter

:octocat:
  • China , ShangHai
  • 17:58 (UTC +08:00)
View GitHub Profile
@xbotter
xbotter / Lazyload.cs
Created August 3, 2017 05:17
Lazy Load Class
public class LazyLoad<T>
{
private readonly Lazy<T> _lazy;
private T _value;
public LazyLoad(Func<T> valueFactory)
{
_lazy = new Lazy<T>(valueFactory);
}
@xbotter
xbotter / consul.sh
Last active September 8, 2018 20:43 — forked from ianunruh/consul.sh
Install Consul on Ubuntu 16.04
#!/bin/bash
apt-get install -y curl unzip
mkdir -p /var/lib/consul
mkdir -p /usr/share/consul
mkdir -p /etc/consul/conf.d
curl -OL https://releases.hashicorp.com/consul/0.7.5/consul_0.7.5_linux_amd64.zip
unzip consul_0.7.5_linux_amd64.zip
mv consul /usr/local/bin/consul
@xbotter
xbotter / CovarianceAndContravariance.cs
Created March 6, 2017 04:42
C#协变和逆变示例
using System;
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
Two the_two = new Two();
// 协变 逆变
@xbotter
xbotter / MultiThread.cs
Created March 6, 2017 04:33
C#多线程处理示例
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApplication
{
public class Program
{
@xbotter
xbotter / round.js
Created November 10, 2016 09:21
Fload.Round
// define round
function round(float,precision) {
return Math.round(float/precision)/(1/precision);
}
// how to use
round(0.3-0.2, .001)