Skip to content

Instantly share code, notes, and snippets.

View gcapnias's full-sized avatar

George J. Capnias gcapnias

View GitHub Profile
@gcapnias
gcapnias / FlareVM.ps1
Created October 21, 2021 16:05
Install FlareVM on the fly
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/mandiant/flare-vm/master/install.ps1'))
@gcapnias
gcapnias / ToDataTable.cs
Created January 8, 2021 17:10
Convert an IList<T> to DataTable
public static partial class Extensions
{
public static DataTable ToDataTable<T>(this IList<T> data)
{
PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(T));
DataTable table = new DataTable();
for (int i = 0; i < props.Count; i++)
{
PropertyDescriptor prop = props[i];
DataColumn column = table.Columns.Add(prop.Name, prop.PropertyType);
@gcapnias
gcapnias / workstation.ps1
Last active June 7, 2021 06:42
Proof of concept - Quick developer workstation in Windows Sandbox.
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco feature enable -n allowGlobalConfirmation
choco install notepad2-mod
choco install winrar
choco install git
choco install sourcetree
choco install dotnetcore-sdk
choco install nodejs-lts
choco install vscode
choco install putty
@gcapnias
gcapnias / XmlSerialize.cs
Created March 8, 2019 16:14
Serialize/Deserialize object to XML
/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="buffer"></param>
/// <returns></returns>
public static T FromXML<T>(string buffer)
{
if (string.IsNullOrEmpty(buffer))
{
@gcapnias
gcapnias / UrlFriendly.cs
Created March 8, 2019 16:12
Creates a URL And SEO friendly slug with Greek language support
/// <summary>
/// Creates a URL And SEO friendly slug
/// </summary>
/// <param name="normalText">Text to slugify</param>
/// <param name="maxLength">Max length of slug</param>
/// <returns>URL and SEO friendly string</returns>
/// <remarks>Inspired from: https://www.johanbostrom.se/blog/how-to-create-a-url-and-seo-friendly-string-in-csharp-text-to-slug-generator </remarks>
public static string UrlFriendly(this string normalText, int maxLength = 0)
{
// Return empty value if text is null
@gcapnias
gcapnias / cloudSettings
Last active November 9, 2019 16:52
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-11-09T16:52:28.475Z","extensionVersion":"v3.4.3"}
var degrees2meters = function(lon,lat) {
var radius = 6378137.0;
var x = radius * lon * Math.PI / 180.0;
var y = radius * Math.log(Math.tan(Math.PI / 4.0 + lat * Math.PI / 360.0));
return [x, y]
}
lon= -77.035974
lat = 38.898717
@gcapnias
gcapnias / datepicker-focus.js
Last active December 18, 2015 21:39 — forked from jeffsheets/datepicker-focus.js
jQuery 1.9.x for $.browser missing fix - Chrome fix
/*
After jquery ui datepicker selection, blur and change
events fire before focus is returned to the input field,
handling a quirk from IE browsers & Chrome
*/
$("input.dateInput").datepicker({
changeMonth: true,
changeYear: true,
showAnim: "fadeIn",