Skip to content

Instantly share code, notes, and snippets.

View regme's full-sized avatar
🤠

Andrey Katamanov regme

🤠
View GitHub Profile
@regme
regme / pre-commit.sh
Last active August 29, 2015 14:27 — forked from akfish/pre-commit.sh
Run MSBuild and MSTest for C# project from git pre-commit hook
#!/bin/sh
# Helper
safeRunCommand() {
typeset cmd="$*"
typeset ret_code
echo cmd=$cmd
eval $cmd
ret_code=$?
@regme
regme / example.msbuild.xml
Created October 26, 2015 14:00 — forked from fearthecowboy/example.msbuild.xml
Super Simple PowerShell task for MSBuild.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- @FearTheCowboy's Simple PowerShell Task for MSBuild -->
<UsingTask TaskName="PowerShell" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup><ScriptBlock ParameterType="System.String" Required="true" /></ParameterGroup>
<Task><Reference Include="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll"/><Code Type="Class" Language="cs"><![CDATA[
public class PowerShell : Microsoft.Build.Tasks.Exec {
public string ScriptBlock {set { EchoOff=true; Command = string.Format( "@powershell \"Invoke-Command -ScriptBlock {{ $errorActionPreference='Stop'; {0} ; exit $LASTEXITCODE }} \"", value.Replace("\"","\"\"").Replace("\r\n",";").Replace("\n",";").Replace("\r",";")); } }
}]]></Code></Task>
</UsingTask>
@regme
regme / Install-VisualStudio.ps1
Created March 7, 2016 12:59 — forked from altrive/Install-VisualStudio.ps1
Unattend install script for Visual Studio 2012 and Visual Studio 2012 Update 2
function Install-VisualStudio
{
[CmdletBinding()]
param (
[string] $ImagePath,
[string[]] $ArgumentList,
[string] $InstallPath,
[string] $ProductKey
)
Write-Verbose "Install Visual Studio 2012..."
@regme
regme / dotnetlayout.md
Created January 19, 2018 08:58 — forked from davidfowl/dotnetlayout.md
.NET project structure
$/
  artifacts/
  build/
  docs/
  lib/
  packages/
  samples/
  src/
 tests/
@regme
regme / Docker connect to remote server.md
Created February 25, 2018 20:23 — forked from kekru/Docker connect to remote server.md
Connect to another host with your docker client, without modifying your local Docker installation

Run commands on remote Docker host

This is how to connect to another host with your docker client, without modifying your local Docker installation or when you don't have a local Docker installation.

Enable Docker Remote API

First be sure to enable the Docker Remote API on the remote host.

This can easily be done with a container.
For HTTP connection use jarkt/docker-remote-api.
For HTTPS connection use whiledo/docker-remote-api-tls.

// Restify Server CheatSheet.
// More about the API: http://mcavage.me/node-restify/#server-api
// Install restify with npm install restify
// 1.1. Creating a Server.
// http://mcavage.me/node-restify/#Creating-a-Server
var restify = require('restify');
@regme
regme / docker-rm-images.md
Created February 28, 2019 21:11 — forked from alferov/docker-rm-images.md
Remove all (untagged) images and containers from Docker
# Delete all containers
docker rm $(docker ps -aq)
# Delete all images
docker rmi $(docker images -q)
# Delete all untagged images
docker rmi $(docker images -q --filter "dangling=true")

References:

@regme
regme / pyodbc-unixODBC-lambda-layer
Created May 2, 2019 12:40 — forked from diriver63/pyodbc-unixODBC-lambda-layer
pyodbc and unixODBC for MSSQL as a lambda layer
# use https://github.com/lambci/docker-lambda to simulate a lambda environment
docker run -it --rm --entrypoint bash -e ODBCINI=/opt/odbc.ini -e ODBCSYSINI=/opt/ lambci/lambda:build-python3.7
# download and install unixODBC
# http://www.unixodbc.org/download.html
curl ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-2.3.7.tar.gz -O
tar xzvf unixODBC-2.3.7.tar.gz
cd unixODBC-2.3.7
./configure --sysconfdir=/opt --disable-gui --disable-drivers --enable-iconv --with-iconv-char-enc=UTF8 --with-iconv-ucode-enc=UTF16LE --prefix=/opt

Enable Docker Remote API with TLS client verification

Docker's Remote API can be secured via TLS and client certificate verification.
First of all you need a few certificates and keys:

  • CA certificate
  • Server certificate
  • Server key
  • Client certificate
  • Client key

Create certificate files

@regme
regme / latency.txt
Created May 25, 2020 08:27 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD