Skip to content

Instantly share code, notes, and snippets.

View michalczukm's full-sized avatar

Michał Michalczuk michalczukm

View GitHub Profile
@michalczukm
michalczukm / docker-copy-from-host
Created August 23, 2015 15:28
Docker copy file from host to container
$ cat /local/file/path | docker exec -i <running-container-id> sh -c 'cat > /inside/docker/file/path'
@michalczukm
michalczukm / Base26Converter.cs
Created September 2, 2015 10:27
Save file with prefix and next letter as counter
public static class Base26Converter
{
private const string CharList = "abcdefghijklmnopqrstuvwxyz";
public static String Encode(long input)
{
if (input < 0) throw new ArgumentOutOfRangeException("input", input, "input cannot be negative");
char[] clistarr = CharList.ToCharArray();
var result = new Stack<char>();
@michalczukm
michalczukm / docker-expose-a-port
Created August 23, 2015 19:37
Docker expose a port on live container
# check boot2docker ip
boot2docker ip
# get container ip
docker inspect container_name | grep IPAddress
# expose port in boot2docker vm
boot2docker ssh
docker@boot2docker:~$ sudo iptables -t nat -A DOCKER -p tcp --dport port_number -j DNAT --to-destination container-ip:port_number
# if wont work call `iptables-save`
@michalczukm
michalczukm / .bat
Created September 30, 2015 12:19
Find IP address by MAC in local net
# ping all adresses in subnet for seed arp table
for /L %N in (1,1,254) do start /b ping -n 1 -w 200 192.168.5.%N
arp -a | find "<MAC you're searching for>"
@michalczukm
michalczukm / BaseServerTests.cs
Last active February 28, 2016 22:33
asp.net in-memory WebAPI tests
namespace Sample.Web.IntegrationTests.Api.Controllers
{
public class BaseServerTests
{
private TestServer _server;
private HttpClient _client;
private TransactionScope _transactionScope;
protected HttpClient Client => _client;
@michalczukm
michalczukm / prepareConnectionString.ps1
Created April 7, 2016 14:03
Prepare connection strings file by simple copy and replace .ps1 script
# example: .\prepareConnectionString.ps1 -connectionName "DbConnection" -connectionString "Server=server_name;Database=db_name;User ID=xyz;Password=passw;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;"
param($connectionName, connectionString)
$solItemsFolder = 'SolutionItems'
$srcFile = 'ConnectionStrings.config.example'
$destinationFile = 'ConnectionStrings.config'
Join-Path $solItemsFolder -ChildPath $srcFile | echo
$connectionStingsXml = [xml](Get-Content -Path (Join-Path $solItemsFolder -ChildPath $srcFile))
@michalczukm
michalczukm / clear_db.sql
Created July 13, 2016 14:10
Clear MSSQL database - both data and schema
/* Drop all non-system stored procs */
DECLARE @name VARCHAR(128)
DECLARE @SQL VARCHAR(254)
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'P' AND category = 0 ORDER BY [name])
WHILE @name is not null
BEGIN
SELECT @SQL = 'DROP PROCEDURE [dbo].[' + RTRIM(@name) +']'
EXEC (@SQL)
@michalczukm
michalczukm / ng-package.json
Created April 22, 2017 00:26
npm scripts with shorts for angular-cli
{
"scripts": {
"cf": "ng g component --spec false --flat --inline-style --inline-template",
"c": "ng g component --spec false"
}
}
@michalczukm
michalczukm / vsc-extensions-list
Last active April 26, 2017 11:55
VS Code TypeScript development extensions
# general
alefragnani.Bookmarks
code-spell-checker
Shan.code-settings-sync
# .ts & angular dev
christian-kohler.npm-intellisense
christian-kohler.path-intellisense
eg2.tslint
rbbit.typescript-hero ##### currently has some problems, doesn't work on VSC v.1.9.1