Skip to content

Instantly share code, notes, and snippets.

View dodbrian's full-sized avatar

Denis Zimin dodbrian

View GitHub Profile
@dodbrian
dodbrian / Program.cs
Created December 5, 2015 10:46
Using .xlsx file as a report template
using System;
using System.IO;
using System.Linq;
using OfficeOpenXml;
using SpreadsheetLight;
namespace XlsxTemplateTest
{
internal static class Program
{
@dodbrian
dodbrian / String2Lambda.cs
Last active February 2, 2018 09:34
Convert string column name into property accessor
public Expression<Func<TEntity, TProperty>> ColumnByName<TEntity, TProperty>(string columnName)
{
var propInfo = typeof(TEntity).GetProperty(columnName);
var parameter = Expression.Parameter(typeof(TEntity));
var memberAccess = Expression.MakeMemberAccess(parameter, propInfo);
var exp = Expression.Lambda<Func<TEntity, TProperty>>(memberAccess, parameter);
return exp;
}
@dodbrian
dodbrian / git-commands.md
Last active November 19, 2020 10:31
Useful git commands

Useful Git Commands

undo last rebase

  1. Run git reflog and find first line from the top without rebase:
  2. Take that line number, for instance: HEAD@{5}
  3. Run git reset --hard HEAD@{5} to revert to the original state

undo last commit/merge

git reset --hard HEAD~1

@dodbrian
dodbrian / docker-compose.yml
Last active February 15, 2019 18:22
Gitlab Docker
web:
image: 'gitlab/gitlab-ce:latest'
container_name: gitlab
restart: always
hostname: 'localhost'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://localhost:32700'
# Add any other gitlab.rb configuration here, each on its own line
ports:
@dodbrian
dodbrian / rm-kernels.sh
Last active March 14, 2021 19:07
Bash script to remove old kernels
#!/bin/bash
# NAME: rm-kernels
# PATH: /usr/local/bin
# DESC: Provide zenity item list of kernels to remove
# DATE: Mar 10, 2017. Modified Aug 5, 2017.
# NOTE: Will not delete current kernel.
@dodbrian
dodbrian / js-array-vs-set.js
Created April 8, 2019 20:49
Benchmarking JavaScript Arrays and Sets
let arr = [], set = new Set(), n = 1000000;
for (let i = 0; i < n; i++) {
arr.push(i);
set.add(i);
}
function checkArr(arr, value) {
return arr.indexOf(value);
}
@dodbrian
dodbrian / python3-install.md
Last active May 13, 2019 15:57
Python 3 installation steps

Python 3 installation steps

Install pyenv

curl https://pyenv.run | bash

Install dependencies

sudo apt install build-essential zlib1g-dev libffi-dev libssl-dev

Install Python

pyenv install 3.7.3

@dodbrian
dodbrian / Hyper-V Installer.bat
Created May 20, 2019 18:29
Install Hyper-V on Windows 10 Home
@echo off
echo Checking for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
echo Permission check result: %errorlevel%
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
@dodbrian
dodbrian / guid.ts
Created May 23, 2019 14:24
JavaScript Guid generation
export class Guid {
static newGuid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
}
@dodbrian
dodbrian / reset-rabbitmq.sh
Last active July 25, 2019 11:46
Clean up RabbitMQ (remove queues and exchanges)
#!/bin/bash
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl start_app