Skip to content

Instantly share code, notes, and snippets.

@mamapi
mamapi / gist:0691ea44f102518539a3b6aef525a479
Created February 15, 2021 19:54
SQL Service Broker - New Broker Id
select service_broker_guid,* from sys.databases
ALTER DATABASE TEST_AUDIOKLAN SET NEW_BROKER WITH ROLLBACK IMMEDIATE;
@mamapi
mamapi / README.md
Created December 13, 2020 11:04 — forked from mosquito/README.md
Add doker-compose as a systemd unit

Docker compose as a systemd unit

Create file /etc/systemd/system/docker-compose@.service. SystemD calling binaries using an absolute path. In my case is prefixed by /usr/local/bin, you should use paths specific for your environment.

[Unit]
Description=%i service with docker compose
Requires=docker.service
After=docker.service
@mamapi
mamapi / eventEmitter.js
Created May 18, 2020 20:56
Javascript Event Emitter
class EventEmitter {
constructor() {
this.events = {}
}
emit(key, data) {
debugger
if (!this.events[key]) return
this.events[key].forEach(callback => callback(data))
}
@mamapi
mamapi / readme.md
Created April 25, 2020 15:55 — forked from rjozefowicz/readme.md
stacja.it - Wprowadzenie do serverless w chmurze AWS - 25.04.2020
@mamapi
mamapi / _Instructions
Created April 5, 2020 09:45 — forked from benmccallum/_Instructions.md
nuxtjs, bootstrap-vue with custom bootstrap build
1. Install bootstrap as a dev dependency, and its dependencies (node-sass and sass-loader)
`npm install --save-dev bootstrap@4.0.0-beta.2 node-sass sass-loader`
2. Install nuxt plugin of bootstrap vue (includes bootstrap-vue as a dependency)
`npm install @nuxtjs/bootstrap-vue`
3. Register plugin as module in nuxt.config.js (see below)
4. Create app.scss entry point (see below)
@mamapi
mamapi / myblog-db-backup.sh
Created July 9, 2019 17:46
Bash script to backup mysql db
#!/bin/bash
#----------------------------------------
# OPTIONS
#----------------------------------------
USER='user'
PASSWORD='secret_pass'
DB_NAME='dbname'
DAYS_TO_KEEP=5 # 0 to keep forever
GZIP=1 # 1 = Compress
BACKUP_PATH='/backups/mysql'
@mamapi
mamapi / myblog-www-backup.sh
Created July 9, 2019 17:40
Bash script to backup www folder
#!/bin/bash
#----------------------------------------
# OPTIONS
#----------------------------------------
WWW_DIR='/var/www/myblog'
BACKUP_PATH='/backups/www'
DAYS_TO_KEEP=5 # 0 to keep forever
FTP_SERVER='ftp.s
@mamapi
mamapi / es6.js
Last active July 5, 2019 10:02
ES6 recipe
//Remove duplicates from js array
1.
[11, 22, 22, 33].reduce((x, y) => x.includes(y) ? x : [...x, y], [])
2.
const dupArr = [1, 1, 2, 3, 1];
const uniqueArr = [... (new Set(dupArr))]
//Converting an Array of Objects to an Object
@mamapi
mamapi / file.js
Created December 11, 2018 16:58
Change item of array in React state
handleBuyClick = id => {
this.setState(previousState => {
const products = previousState.products.map(p => p.id === id ? { ...p, isSold: true } : { ...p })
return { products }
})
}
@mamapi
mamapi / getLastInMap.js
Created December 11, 2018 11:59 — forked from tizmagik/getLastInMap.js
ES6 Last Item in Map()
// Since ES6 Map()'s' retain their order of insertion, it can sometimes be useful to get the last item or value inserted:
export const getLastItemInMap = map => Array.from(map)[map.size-1]
export const getLastKeyInMap = map => Array.from(map)[map.size-1][0]
export const getLastValueInMap = map => Array.from(map)[map.size-1][1]
// Obviously getLastKey and getLastValue can reuse getLastItem, but for maximum portability I opted for verbosity.