I use Ubuntu’s Uncomplicated firewall because it is available on Ubuntu and it's very simple.
if ufw is not installed by default be sure to install it first.
| /// <summary> | |
| /// Read contents of an embedded resource file | |
| /// </summary> | |
| private string ReadResourceFile(string filename) | |
| { | |
| var thisAssembly = Assembly.GetExecutingAssembly(); | |
| using (var stream = thisAssembly.GetManifestResourceStream(filename)) | |
| { | |
| using (var reader = new StreamReader(stream)) | |
| { |
| <?xml version="1.0" encoding="utf-8"?> | |
| <Weavers> | |
| <PropertyChanged EventInvokerNames="NotifyOfPropertyChange" /> | |
| </Weavers> |
| //extension method make a database call by providing a function pointer to Task<T> and passing in a method parameter | |
| public static async Task<T> DatabaseCall<T>(this IDatabase cache, string key, Func<string, Task<T>> databaseCall, string methodParameter, TimeSpan timeSpan, bool invalidate, bool useCache) | |
| { | |
| T returnValue; | |
| var cachedItem = default(T); | |
| try | |
| { | |
| cachedItem = await cache.GetAsync<T>(key); | |
| } | |
| catch (RedisConnectionException ex) |
Thanks to @seejee for making this for me!!!
The goal of this is to have an easily-scannable reference for the most common syntax idioms in C# and Rust so that programmers most comfortable with C# can quickly get through the syntax differences and feel like they could read and write basic Rust programs.
What do you think? Does this meet its goal? If not, why not?
| using System; | |
| using System.Threading; | |
| static class Program { | |
| static void Main() { | |
| Console.Write("Performing some task... "); | |
| using (var progress = new ProgressBar()) { | |
| for (int i = 0; i <= 100; i++) { | |
| progress.Report((double) i / 100); |
| // Example 1: Signing a byte[] using PKCS#1 v1.5 padding and a SHA-256 hash | |
| // 4.5: | |
| public static byte[] SignDataPkcs1Sha256(X509Certificate2 cert, byte[] data) | |
| { | |
| // X509Certificate2.PrivateKey returns the same object across multiple calls, | |
| // so it shouldn't be Disposed independent of the X509Certificate2 object. | |
| // | |
| // The RSA base class doesn't expose any signature-based methods. | |
| // The PrivateKey property returns AsymmetricAlgorithm, so really this call should be |
| { | |
| "repositories": [ | |
| { | |
| "type": "path", | |
| "url": "../relative/project/path" | |
| } | |
| ], | |
| "require": { | |
| "${project}": "dev-${branch}" | |
| } |
| using System.Net.Http; | |
| using (var client = new HttpClient()) | |
| { | |
| var url = "http://google.com/api-example"; | |
| var response = client.GetAsync(url).Result; | |
| if (response.IsSuccessStatusCode) | |
| { | |
| // by calling .Result you are performing a synchronous call |
| using System; | |
| using System.Collections.Generic; | |
| using System.Diagnostics; | |
| using System.Linq; | |
| using System.Threading; | |
| using System.Threading.Tasks; | |
| using StackExchange.Redis; | |
| namespace CitySurvival.Redis | |
| { |