Skip to content

Instantly share code, notes, and snippets.

@bozhink
bozhink / install-dotnet-web-application-linux.md
Last active September 13, 2020 10:30
Install dotnet web application on Debian/Ubuntu-like Linux distribution

Install dotnet web application on Debian/Ubuntu-like Linux distribution

Fresh install of the OS

  1. Update the index of packages
$ sudo apt update
  1. Update (upgrade) installed packages
$ sudo apt upgrade
# See https://stackoverflow.com/questions/48341920/git-branch-command-behaves-like-less
git config --global pager.branch false
@bozhink
bozhink / disable-back.js
Created May 14, 2018 05:57
Disable back button with JavaScript
// See https://codepen.io/dhavalt10/pen/rGLBzB
history.pushState(null, null, location.href);
window.onpopstate = function () {
history.go(1);
};
@bozhink
bozhink / serialize-object.js
Created December 20, 2017 09:42
jQuery: serialize form to object
$.fn.serializeObject = function () {
var i, len, item, object = {}, array = $(this).serializeArray() || [];
len = array.length;
for (i = 0; i < len; i += 1) {
item = array[i];
object[item.name] = item.value;
}
return object;
}
@bozhink
bozhink / ReportPrinter.cs
Created November 7, 2017 10:59
C# WinForms Report Printer
public class ReportPrinter : IDisposable
{
private int currentPageIndex;
private IList<Stream> streams;
private DataTable LoadSalesData()
{
// Create a new DataSet and read sales data file
// data.xml into the first DataTable.
DataSet dataSet = new DataSet();
// See https://github.com/elastic/elasticsearch-net/issues/2860
public class MyDocument
{
public string RecordType { get; set; }
}
var client = new ElasticClient();
client.Search<MyDocument>(s => s
@bozhink
bozhink / stop-telemetry.ps1
Created September 9, 2017 19:55
PowerShell: turn off Telemetry in Windows10
Stop-Service DiagTrack
Set-Service DiagTrack -StartupType Disabled
@bozhink
bozhink / npoisi.cs
Created August 11, 2017 07:43
NPOI Summary Information
/// See https://stackoverflow.com/questions/11143303/how-to-set-author-name-to-excel-file-using-poi
public static void SetAuthor(this IWorkbook workbook, string author)
{
if (workbook is NPOI.XSSF.UserModel.XSSFWorkbook)
{
var xssfWorkbook = workbook as NPOI.XSSF.UserModel.XSSFWorkbook;
var xmlProps = xssfWorkbook.GetProperties();
var coreProps = xmlProps.CoreProperties;
coreProps.Creator = author;
return;
@bozhink
bozhink / GetCallingMethodName.cs
Created August 10, 2017 10:04
Get calling mathod name C#
internal class Helpers
{
internal string GetCallingMethodName()
{
string result = "unknown";
StackTrace trace = new StackTrace(false);
for (int i = 0; i < trace.FrameCount; i++)
{
StackFrame frame = trace.GetFrame(i);
MethodBase method = frame.GetMethod();
@bozhink
bozhink / gist:8486502fdac7a0293f6ac5052951cf11
Created July 10, 2017 19:44
Remove Windows 10 activation key
slmgr.vbs -upk