Skip to content

Instantly share code, notes, and snippets.

View michalczukm's full-sized avatar

Michał Michalczuk michalczukm

View GitHub Profile
@michalczukm
michalczukm / zipRun.ts
Created September 2, 2019 23:32
Zip run commands - on array elements in same order
const zipRun: <T>(items: T[], commands: Array<(item: T) => unknown>) => void = (items, commands) => {
items.forEach((item, index) => commands[index](item));
}
@michalczukm
michalczukm / .gitignore
Created December 7, 2018 00:08
.NET Core apps minimal .gitignore (including publication settings)
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
@michalczukm
michalczukm / value-types.ts
Last active August 9, 2018 23:20
Example of using values as types - with type assertion
const Foo = {
aFoo: 'SomeAfoo' as 'SomeAfoo',
bFoo: 'SomeBfoo' as 'SomeBfoo',
cFoo: 'SomeCfoo' as 'SomeCfoo',
};
type FooValueTypes = (typeof Foo)[keyof typeof Foo];
function doStuff(value: FooValueTypes) {
}
@michalczukm
michalczukm / extensions.json
Last active July 9, 2018 00:07
VS Code recommended workspace extensions for any Angular project (and not only :) )
{
// See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"angular.ng-template",
"mikael.angular-beastcode",
"msjsdiag.debugger-for-chrome",
"ryu1kn.annotator",
@michalczukm
michalczukm / els-reindex.sh
Created January 22, 2018 14:31
Clone index to another (reindex) in Elastic Search (ELS)
curl -X POST http://localhost:9200/_reindex?pretty=true -d '{
"source": {
"index": "dev_1"
},
"dest": {
"index": "dev_2"
}
}'
@michalczukm
michalczukm / get-els-data.sh
Created January 22, 2018 10:06
Get Elastic Search (ELS) data via cURL, to file
curl -X GET http://localhost:9200/dev-1/categorysearchproductmodel/_search?pretty=true -d '{
"sort" : [
{ "_uid" : {"order" : "asc"}}
],
"query": {
"match_all": {}
}
}' > els-now.json
@michalczukm
michalczukm / mysql-docker.sh
Created November 25, 2017 19:14 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@michalczukm
michalczukm / docker-compose.yaml
Created November 23, 2017 16:29
elasticsearch + kibana docker-compose
version: "2.2"
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.0.0
container_name: elasticsearch
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
@michalczukm
michalczukm / azure-function-get-ip.js
Created November 13, 2017 10:44
Azure function - ask for my current IP
const https = require('https');
module.exports = function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');
https.get('https://ifconfig.co/json', res => {
res.setEncoding('utf8');
let body = '';
res.on('data', data => {
body += data;