This file contains 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 MinmalisticHashSet<T> | |
{ | |
private readonly Dictionary<T, object> _dictionary = new Dictionary<T, object>(); | |
public bool Add(T item) | |
{ | |
if (_dictionary.ContainsKey(item)) return false; | |
_dictionary[item] = null; | |
return true; | |
} |
This file contains 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
private static IEnumerable<string> Something() | |
{ | |
yield return "Something() One"; | |
yield return "Something() Two"; | |
yield return "Something() Three"; | |
} | |
// When the compiler encounters an iterator block it emits a nested type for the state machine similar to this: |
This file contains 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 DemonstrationList<T> : IEnumerable<T> | |
{ | |
private const int defaultCapacity = 10; | |
private T[] items = new T[defaultCapacity]; | |
private int count = 0; | |
public void Add(T item) | |
{ | |
if (count == items.Length) | |
{ |
This file contains 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 = new[] { 5, 4, 3, 2, 1 }; | |
var varSum = sequence.Aggregate((sum, number) => sum + number); | |
var varCount = sequence.Aggregate(0, (count, number) => count + 1); | |
var varMin = sequence.Aggregate((min, number) => number < min ? number : min); | |
var varMax = sequence.Aggregate((max, number) => number > max ? number : max); | |
var varAverage = varSum / varCount; | |
var varAverageAlt = sequence.Aggregate(new { sum = 0, count = 0 }, | |
(anonObj, number) => new { sum = anonObj.sum + number, count = anonObj.count + 1 }, | |
anonObj => anonObj.sum / anonObj.count); |
This file contains 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 ProfileModule : ModuleBase | |
{ | |
public ProfileModule() | |
{ | |
Get["/profile/{gamertag}"] = context => | |
{ | |
Profile profile = XboxClient.Profile.GetProfile(context.Gamertag); | |
if (profile == null) | |
return this.ErrorMessage(HttpStatusCode.BadRequest, "Profile does not exist."); |
This file contains 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
git remote -v #output remotes | |
git remote rm REMOTENAME #remove remote | |
git diff #diff for unstaged files | |
git diff --staged #diff for staged files | |
git diff --cached #diff for staged files | |
rm -rf .git #delete Git directory |
This file contains 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
Closures | |
Covariance and Contravaraince | |
Defered Execution | |
Method Group | |
Implicit Conversions | |
Extension Methods | |
Properties | |
Events | |
Law of Demeter |
This file contains 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
USE Musical; | |
CREATE TABLE dbo.Customer( | |
CustomerID INT PRIMARY KEY NOT NULL, | |
Title NVARCHAR(8), | |
FirstName NVARCHAR(50) NOT NULL, | |
LastName NVARCHAR(50) NOT NULL, | |
); | |
CREATE TABLE dbo.CustomerAddress( |
This file contains 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
{ | |
"Data": { | |
"Friends": [{ | |
"GamerTag": "AA doomroka", | |
"GamerTileUrl": "https://avatar-ssl.xboxlive.com/avatar/AA%20doomroka/avatarpic-s.png", | |
"LargeGamerTileUrl": "https://avatar-ssl.xboxlive.com/avatar/AA%20doomroka/avatarpic-l.png", | |
"GamerScore": 61090, | |
"IsOnline": false, | |
"LastSeen": "\/Date(1041379200000)\/", | |
"Presence": "Offline", |
This file contains 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
namespace Code | |
{ | |
public class XboxLogin | |
{ | |
private static void Do() | |
{ | |
var cookieContainer = new CookieContainer(); | |
var handler = new HttpClientHandler(); | |
handler.AllowAutoRedirect = true; | |
handler.CookieContainer = cookieContainer; |