Skip to content

Instantly share code, notes, and snippets.

@emrahyumuk
emrahyumuk / InstallDockerForWindows.md
Last active September 20, 2017 06:36
Install Docker for Windows
  • Download the Docker for Windows https://store.docker.com/editions/community/docker-ce-desktop-windows

  • Search for 'Turn Windows features on or off' and launch it. In the list of features you will find Hyper-V. Check the box next to it and click OK.

  • Check if Virtualization is shown as enabled by going to Task Manager > Performance.

  • If Virtualization is not enabled, restart your PC, go to BIOS setting at startup. Search for Virtualization setting at the BIOS settings. Toggle from 'Disabled' to 'Enabled'. Save the BIOS settings and restart.

  • After restarting, check if Virtualization is enabled at Task Manager > Performance. It should be enabled.

@emrahyumuk
emrahyumuk / RunActionsWithManyParameters.cs
Last active January 11, 2017 12:08
Run Actions with n parameters
public static void Main()
{
Invoke<List<string>>(Test1, new List<string>());
Invoke<string, int>(Test2, string.Empty, 1);
Invoke<string, int, object>(Test3, string.Empty, 1, null);
}
private static void Invoke<T1>(Action<T1> a, T1 p)
{
InvokeMyMethod(a, p);
}
@emrahyumuk
emrahyumuk / EntityFrameworkBulkDelete.cs
Last active January 11, 2017 12:09
Entity Framework Bulk Delete
public static void BulkDelete<T>(DbContext dbContext, IEnumerable<int> idList) where T : class {
var tableName = dbContext.GetTableName<T>();
foreach (var i in idList) {
dbContext.Database.ExecuteSqlCommand("DELETE FROM " + tableName + " WHERE Id=@ID", new SqlParameter("ID", i));
}
}
public static string GetTableName<T>(this DbContext context) where T : class {
ObjectContext objectContext = ((IObjectContextAdapter)context).ObjectContext;
return objectContext.GetTableName<T>();
@emrahyumuk
emrahyumuk / ListIEqualityComparer.cs
Last active January 11, 2017 12:09
List IEqualityComparer
public class Item {
public int Id { get; set; }
public string Name { get; set; }
}
public class ItemListEqualityComparer : IEqualityComparer<List<Item>> {
public bool Equals(List<Item> x, List<Item> y) {
if (ReferenceEquals(x, y))
return true;
@emrahyumuk
emrahyumuk / GetInternalIP.cs
Last active January 11, 2017 12:10
Get Internal IP
Dns.GetHostEntry(Dns.GetHostName()).AddressList.FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork);
@emrahyumuk
emrahyumuk / WindowsServiceInstallUninstall.cmd
Last active January 11, 2017 12:11
Windows Service Install Uninstall
C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe -i C:\MyService.exe
C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe -u C:\MyService.exe