Skip to content

Instantly share code, notes, and snippets.

View nikanos's full-sized avatar

Nikanos Polykarpou nikanos

  • ::1, Nicosia, Cyprus
View GitHub Profile
@nikanos
nikanos / CleanFolder.cmd
Created October 7, 2018 18:15
Clean old files in folder - Windows batch script
@ECHO OFF
SET days=%1
SET folder=C:\_FolderToClean_
IF %days%.==. GOTO NoDaysEntered
FORFILES /P "%folder%" /D -%days% /C "cmd /c DEL /Q @path"
IF ERRORLEVEL 1 GOTO ForFilesError
GOTO End
@nikanos
nikanos / merge_mp4.py
Created October 7, 2018 19:48
Avidemux script - merge mp4 files in a folder
#Avidemux script (works with Avidemux v 2.7.1)
#Merges all the mp4 files of a folder to a "_merged.mkv" file in the same folder
ext="mp4"
inputFolder=""
currentItemIndex=0
#
def loadOrAppend(filein):
if(currentItemIndex==1):
@nikanos
nikanos / RegExTest.cs
Last active November 23, 2021 08:09
RegEx - Do not allow leading and trailing whitespace
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace RegExTest
{
static class MyExtensions
{
public static void PrintMatch(this Regex re, string input)
{
@nikanos
nikanos / staticpow.cpp
Created November 4, 2018 16:47
static power calculation using c++ templates
#include <iostream>
#include <cstdint>
using namespace std;
template<int N, uint16_t P>
struct Pow
{
static const uint64_t Result = N * Pow<N, P - 1>::Result;
};
@nikanos
nikanos / app.config
Last active October 31, 2019 10:38
.NET Configuration file - proxy settings
<?xml version="1.0"?>
<configuration>
<configSections>
<!-- config sections -->
</configSections>
<system.net>
<defaultProxy enabled="true">
<proxy usesystemdefault="true" proxyaddress="http://127.0.0.1:8888" bypassonlocal="false" />
</defaultProxy>
</system.net>
@nikanos
nikanos / AutoMapperTestEntities.cs
Last active December 29, 2018 09:21
AutomapperTest
using System;
namespace AutoMapperTest.CLI
{
class PersonDTO
{
public Guid? ID { get; set; }
public string Name { get; set; }
public int? Age { get; set; }
public string Description { get; set; }
@nikanos
nikanos / openssl_selfsigned_certificate.sh
Last active February 3, 2019 22:34
openssl self-signed certificate commands
#generate a private key without a pass phrase and with default length
openssl genrsa -out private.key
#generate a private key without a pass phrase and with 4096-bit length
openssl genrsa -out private.key 4096
#generate a private key with a pass phrase and with default length
openssl genrsa -des3 -out private.key
#generate a self-signed certificate using private.key as key and set validity to 365 days
@nikanos
nikanos / IPAddressExtensions.cs
Last active February 18, 2020 23:33
IsInternal IPAddress Extension
using System;
using System.Net;
using System.Net.Sockets;
static class IPAddressExtensions
{
public static bool IsInternal(this IPAddress address)
{
if (address == null)
throw new ArgumentNullException(nameof(address));
@nikanos
nikanos / Program.cs
Last active July 19, 2020 08:27
C# - ADO.NET - Call SQL Server Stored Procedure
namespace MyDbTest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(DBHelper.Greet("Frodo", "Baggins"));
}
}
}
@nikanos
nikanos / EnumUtils.cs
Last active April 25, 2021 09:36
EnumUtils.ConvertTo
class EnumUtils
{
public static T ConvertTo<T, S>(S source)
where T : struct
where S : struct
{
if (!typeof(T).IsEnum)
throw new ArgumentException("T must be an enumerated type");
if (!typeof(S).IsEnum)