Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / 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 / 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 / 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 / InstallNodejsOnUbuntu.md
Last active September 20, 2017 06:47
Install Node.js and npm LTS on Ubuntu
sudo apt install curl

curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -

sudo apt install nodejs

node --version

npm version
@emrahyumuk
emrahyumuk / InstallDebPackagesOnLinux.md
Created September 20, 2017 13:21
Install Deb Packages on Linux
sudo apt-get -f install

sudo dpkg -i <package-name>.deb
@emrahyumuk
emrahyumuk / RunShScriptFileOnUbuntu.md
Last active January 28, 2021 07:28
Run .sh script files on Linux
@emrahyumuk
emrahyumuk / InstallDockerOnUbuntu.md
Created September 22, 2017 07:29
Install Docker on Ubuntu
sudo apt-get update

sudo apt-get install \
   apt-transport-https \
   ca-certificates \
   curl \
   software-properties-common
   
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -