Skip to content

Instantly share code, notes, and snippets.

View xtrmstep's full-sized avatar
🏠
Working from home

Alexander Goida xtrmstep

🏠
Working from home
  • Sofia, Bulgaria
View GitHub Profile
@xtrmstep
xtrmstep / ExtractEmbeddedResourcesToFiles
Last active August 29, 2015 14:27
Extract text files embedded as resources to an assembly to files on disk
public void ExtractEmbeddedResourcesToFiles()
{
Assembly a = typeof (SomeTypeFromAssemblyWithResources).Assembly;
string d = Path.GetDirectoryName(a.Location);
string outputDir = Path.Combine(d, subFolder);
if (Directory.Exists(outputDir) == false)
{
Directory.CreateDirectory(outputDir);
}
List<string> rs = a.GetManifestResourceNames().Where(n => n.Contains(prefix)).ToList();
@xtrmstep
xtrmstep / WriteObjectToStringWriter.cs
Created September 28, 2015 08:47
Write an object using StringWriter to StringBuilder
using System;
using System.IO;
using System.Text;
namespace ConsoleApplication2
{
internal class Program
{
private static void Main(string[] args)
{
@xtrmstep
xtrmstep / AppConfigChanger.cs
Created October 1, 2015 13:27
The hack for substitution of standard configuration file
/// <summary>
/// The hack for substitution of standard configuration file
/// question at StackOweflow: http://stackoverflow.com/questions/6150644/change-default-app-config-at-runtime
/// a solution: http://stackoverflow.com/a/6151688/2833774
/// </summary>
public abstract class AppConfigChanger : IDisposable
{
public static AppConfigChanger Change(string path)
{
return new AppConfigSubstitutor(path);
@xtrmstep
xtrmstep / RangesToArray
Created December 14, 2015 14:07
Convert text ranges to int array and back
public static int[] ToIntArray(this string text)
{
if (string.IsNullOrWhiteSpace(text))
{
return new int[]
{
};
}
List<int> result = new List<int>();
@xtrmstep
xtrmstep / cleanup-objbin.ps1
Created March 29, 2016 09:02
PowerShell script to delete all \bin and \obj folders
Get-ChildItem .\ -include bin,obj -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse }
@xtrmstep
xtrmstep / Div auto heigh resizing.html
Created July 7, 2016 22:39
How DIV can be automatically resized during resizing of the window
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="robots" content="noindex, nofollow">
<meta name="googlebot" content="noindex, nofollow">
<script src="http://code.jquery.com/jquery-git.min.js"></script>
<style type="text/css">
body {
margin: 0px;
padding: 0px;
@xtrmstep
xtrmstep / SqlHelpers-01.sql
Last active October 10, 2017 14:21
SQL code snippets and helpers
/*
- Get default constraints of database with definition
- Several scripts to deal with locks in database
- Convert rows to columns in SQL
- SQL to select from XML
- Get table sizes
*/
@xtrmstep
xtrmstep / log4net-01.cs
Created October 10, 2017 14:54
log4net snippets
// variable declaration
private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// You have several options to make it alive
// 1) AssemblyInfo.cs
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
// 2) manual kick in the beginning of program execution
XmlConfigurator.Configure();
@xtrmstep
xtrmstep / ToJson.cs
Created February 8, 2018 17:58
Get object dump in JSON with Google ProtocolBuffers
public static string ToJson(this object obj)
{
var messageLite = obj as IMessageLite;
if (messageLite != null)
return Google.ProtocolBuffers.Extensions.ToJson(messageLite);
return JsonConvert.SerializeObject(obj);
}
@xtrmstep
xtrmstep / git-ssh-auth-win-setup.md
Created May 20, 2019 09:43 — forked from bsara/git-ssh-auth-win-setup.md
Setup SSH Authentication for Git Bash on Windows

Setup SSH Authentication for Git Bash on Windows

Prepararation

  1. Create a folder at the root of your user home folder (Example: C:/Users/uname/) called .ssh.
  2. Create the following files if they do not already exist (paths begin from the root of your user home folder):
  • .ssh/config