This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // define round | |
| function round(float,precision) { | |
| return Math.round(float/precision)/(1/precision); | |
| } | |
| // how to use | |
| round(0.3-0.2, .001) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Threading; | |
| using System.Threading.Tasks; | |
| namespace ConsoleApplication | |
| { | |
| public class Program | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| namespace ConsoleApplication | |
| { | |
| public class Program | |
| { | |
| public static void Main(string[] args) | |
| { | |
| Two the_two = new Two(); | |
| // 协变 逆变 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class LazyLoad<T> | |
| { | |
| private readonly Lazy<T> _lazy; | |
| private T _value; | |
| public LazyLoad(Func<T> valueFactory) | |
| { | |
| _lazy = new Lazy<T>(valueFactory); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class PartialFunction | |
| { | |
| public static Func<T1,Func<T2,TResult>> Curry<T1,T2,TResult>(Func<T1,T2,TResult> func) => arg1 =>arg2=>func(arg1,arg2); | |
| public static Func<T1,Func<T2,Func<T3,TResult>>> Curry<T1,T2,T3,TResult>(Func<T1,T2,T3,TResult> func) => arg1=>arg2=>arg3=>func(arg1,arg2,arg3); | |
| public static Func<T1,Func<T2,Func<T3,Func<T4,TResult>>>> Curry<T1,T2,T3,T4,TResult>(Func<T1,T2,T3,T4,TResult> func) => arg1=>arg2=>arg3=>arg4=>func(arg1,arg2,arg3,arg4); | |
| public static Func<T1,Func<T2,Func<T3,Func<T4,Func<T5,TResult>>>>> Curry<T1,T2,T3,T4,T5,TResult>(Func<T1,T2,T3,T4,T5,TResult> func) => arg1=>arg2=>arg3=>arg4=>arg5=>func(arg1,arg2,arg3,arg4,arg5); | |
| public static Func<T1,Func<T2,Func<T3,Func<T4,Func<T5,Func<T6,TResult>>>>>> Curry<T1,T2,T3,T4,T5,T6,TResult>(Func<T1,T2,T3,T4,T5,T6,TResult> func) => arg1=>arg2=>arg3=>arg4=>arg5=>arg6=>func(arg1,arg2,arg3,arg4,arg5,arg6); | |
| public static Func<T1,Func<T2,Func<T3,Func<T4,Func<T5,Func<T6,Func<T7,TResult>>>>>>> Curry<T1,T2,T3,T4,T5, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function paramReplace(uri, key, value) { | |
| // Find the param with regex | |
| // Grab the first character in the returned string (should be ? or &) | |
| // Replace our href string with our new value, passing on the name and delimeter | |
| var re = new RegExp("[\\?&]" + key + "=([^&#]*)"); | |
| var separator = uri.indexOf('?') !== -1 ? "&" : "?"; | |
| var matches = re.exec(uri); | |
| var newUri; | |
| if (matches === null) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static string GetMd5String(string input) | |
| { | |
| using (MD5 md5Hash = MD5.Create()) | |
| { | |
| // Convert the input string to a byte array and compute the hash. | |
| byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input)); | |
| // Create a new Stringbuilder to collect the bytes | |
| // and create a string. | |
| StringBuilder sBuilder = new StringBuilder(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface ITimerDataSource | |
| { | |
| TimerTask LastTask(); | |
| void RemoveTask(string taskid); | |
| void Insert(TimerTask task); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| docker images | findstr '<none>' | ForEach-Object{$_.Split(" ",[System.StringSplitOptions]::RemoveEmptyEntries)[2];}| ForEach-Object{docker rmi $_} |
OlderNewer