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.Linq; | |
| using System.Threading.Tasks; | |
| using System.Windows; | |
| using System.Windows.Controls; | |
| namespace DeadlockExample | |
| { | |
| /// <summary> | |
| /// Interaction logic for MainWindow.xaml |
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
| // http://channel9.msdn.com/Events/Build/2013/4-329 | |
| int N = 1000; | |
| var A = new int[N,N]; | |
| var B = new int[N, N]; | |
| var C = new int[N, N]; | |
| var random = new Random(); | |
| for(int x = 0; x < N; x++) | |
| { | |
| for(int y = 0; y < N; y++) |
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 | |
| # This cronjob runs at least once a minute and will check if the usage of RAM is more than 75% | |
| # if it is more than 75% it sends me an e-mail and invokes the API. API call removed from the example. | |
| # When the percentage left after a possible decrease is 70& then it decreases the RAM to that level | |
| TOTAL=`free | grep Mem: | awk '{print $2}'` | |
| USED=`free | grep Mem: | awk '{print $3}'` | |
| INCREASE=$(((TOTAL/1024)+512)); |
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
| var sequence = Enumerable.Range(0, 3).ToList(); | |
| while(true) { | |
| sequence.ForEach(e => Console.Beep(650, 100)); | |
| Thread.Sleep(200); | |
| sequence.ForEach(e => Console.Beep(650, 400)); | |
| Thread.Sleep(200); |
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
| void Main() | |
| { | |
| var values = new List<string>(); | |
| var dict = new FancyDictionary<string, string>(); | |
| var insertWatch = new Stopwatch(); | |
| for(int i = 0; i < 3000; i++) | |
| { | |
| var entry = Guid.NewGuid().ToString(); | |
| values.Add(entry); |
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
| void Main() | |
| { | |
| // Define all the vertices in the graph | |
| var a = new Vertex<string>{ Value = "A" }; | |
| var b = new Vertex<string>{ Value = "B" }; | |
| var c = new Vertex<string>{ Value = "C" }; | |
| var d = new Vertex<string>{ Value = "D" }; | |
| var e = new Vertex<string>{ Value = "E" }; | |
| var f = new Vertex<string>{ Value = "F" }; | |
| var g = new Vertex<string>{ Value = "G" }; |
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.Diagnostics; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| namespace EnsureThat.Performance | |
| { | |
| 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.IO; | |
| using System.Linq; | |
| namespace CopyToOneDrive | |
| { | |
| internal class Program | |
| { | |
| private const string _destination = @"C:\Users\YourUserName\OneDrive\Camera Roll"; | |
| private const string _source = @"D:\Camera Roll Backup\"; |
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
| /* Android - DOES NOT DEADLOCK */ | |
| Task.Run(() =>{ | |
| Thread.Sleep(2000); | |
| RunOnUiThread(() => { }); | |
| }).Wait(); | |
| /* iOS - DEADLOCKS */ | |
| Task.Run(() =>{ | |
| Thread.Sleep(2000); | |
| InvokeOnMainThread(() => { }); |
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
| ``` | |
| And finally, I am proving ownership of the github account by posting this as a gist. | |
| ### My publicly-auditable identity: | |
| https://keybase.io/fekberg | |
| ### From the command line: |