Skip to content

Instantly share code, notes, and snippets.

public class ProfileService
{
private static readonly Dictionary<string, int> _starValues
= new Dictionary<string, int> {
{"Star Empty", 0},
{"Star Quarter", 25},
{"Star Half", 50},
{"Star ThreeQuarter", 75},
{"Star Full", 100}
};
public static class ControlExtensions
{
public static void Invoke(this Control control, MethodInvoker method)
{
if (control.InvokeRequired == false)
{
// The executing thread _is_ the thread that owns the control's underlying
// handle and as such, there is no need to marshall the method invocation.
method.Invoke();
}
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(
private static readonly HttpClient _client = new HttpClient();
private async static void ObtainProfileData(string gamertag, string region)
{
var response = await _client.GetAsync("http://live.xbox.com/" + region + "/Profile?gamertag=" + gamertag);
if (!response.IsSuccessStatusCode)
{
Console.WriteLine("{0} Gamertag not found.", response.StatusCode);
return;
public sealed class HotkeyTextBox : TextBox
{
public Keys Modifier { get; private set; }
public Keys Key { get; private set; }
public HotkeyTextBox()
{
Text = "None";
GotFocus += delegate { NativeMethods.HideCaret(Handle); };
}
http://i.imgur.com/mBZr0lv.png
@AlexArchive
AlexArchive / gist:11055316
Last active August 29, 2015 14:00
EF Code First DatabaseInitializer
Database.SetInitializer(new DropCreateDatabaseAlways<ApplicationDbContext>());
Database.SetInitializer(new DropCreateDatabaseIfModelChanges<ApplicationDbContext>());
Database.SetInitializer(new CreateDatabaseIfNotExists<ApplicationDbContext>());
public class Doohickey : DropCreateDatabaseIfModelChanges<ApplicationDbContext>
{
}
public class MainForm : Form
{
private readonly YouTubeDownloadService _service = new YouTubeDownloadService();
public class MainForm()
{
_serivce.DownloadProgressChanged += OnDownloadProgressChanged;
}
private void DownloadVideo(string videoLocation, VideoResolution resoloution, VideoCodec codec)
public class ImgurService : IDisposable
{
private HttpClient _client;
public string ClientID { get; private set; }
public ImgurService(string clientId)
{
ClientID = clientId;
InitializeHttpClient();
}
public static class ContentTypeIdentifier
{
public static ContentType IdentifyType(Stream contentStream)
{
byte[] contentHeader = new byte[4];
contentStream.Read(contentHeader, 0, 4);
return ResolveContentTypeBasedOnHeader(contentHeader);
}