Instantly share code, notes, and snippets.

View .gitignore
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
View value-types.ts
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) {
}
View how-to-add-image-to-gist.md

How to add an image to a gist

  1. Create or find a gist that you own.
  2. Clone your gist (replace <hash> with your gist's hash):
    # with ssh
    git clone git@gist.github.com:<hash>.git mygist
    
    # with https
    git clone https://gist.github.com/<hash>.git mygist
View extensions.json
{
// 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",
View vscode-extensions.sh
##!/bin/bash
# ======= Generate extensions list by:
#code --list-extensions | while read line; do
# echo code --install-extension $line
#done
# ======== My current extensions list
code --install-extension Angular.ng-template
code --install-extension EditorConfig.EditorConfig
code --install-extension PeterJausovec.vscode-docker
View els-reindex.sh
curl -X POST http://localhost:9200/_reindex?pretty=true -d '{
"source": {
"index": "dev_1"
},
"dest": {
"index": "dev_2"
}
}'
View get-els-data.sh
curl -X GET http://localhost:9200/dev-1/categorysearchproductmodel/_search?pretty=true -d '{
"sort" : [
{ "_uid" : {"order" : "asc"}}
],
"query": {
"match_all": {}
}
}' > els-now.json
View mysql-docker.sh
# 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
View docker-compose.yaml
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:
View azure-function-get-ip.js
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;