Skip to content

Instantly share code, notes, and snippets.

@vahanNasibyan
vahanNasibyan / buffertowav.js
Created February 22, 2017 12:43 — forked from kevincennis/buffertowav.js
Buffer to WAV
// assuming a var named `buffer` exists and is an AudioBuffer instance
// start a new worker
// we can't use Recorder directly, since it doesn't support what we're trying to do
var worker = new Worker('recorderWorker.js');
// initialize the new worker
worker.postMessage({
command: 'init',
@vahanNasibyan
vahanNasibyan / GIT fork update
Created July 9, 2017 18:49
FORK update from upstream
### 1. Clone your fork:
git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git
### 2. Add remote from original repository in your forked repository:
cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@vahanNasibyan
vahanNasibyan / rm_locks.sql
Created February 1, 2018 19:14
Remove all blocking lock from Postgresql
//view all blocking locks
SELECT
*
FROM
pg_locks pl
LEFT JOIN pg_stat_activity psa ON pl.pid = psa.pid
WHERE
wait_event_type = 'Lock' AND pl.pid <> pg_backend_pid()
ORDER BY
query_start ASC
@vahanNasibyan
vahanNasibyan / timezone.js
Created February 5, 2018 14:52
Where wrapper to ignore Timezone in Postgres
const condition = {
test: this.sequelize.literal(
`timezone('UTC', modified::timestamptz) > '${moment(
this.config.last_parse,
).format('YYYY-MM-DD HH:mm:ss +00:00')}'`,
),
}
-- kill running query
SELECT pg_cancel_backend(procpid);
-- kill idle query
SELECT pg_terminate_backend(procpid);
@vahanNasibyan
vahanNasibyan / postgres_queries_and_commands.sql
Created April 2, 2018 14:55 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
##Full vacuum of postgres daatabase
#docs https://www.postgresql.org/docs/9.5/static/app-vacuumdb.html
/usr/local/bin/vacuumdb -h [postgres_server_host] -U [username] -d [database] -fze
@vahanNasibyan
vahanNasibyan / before_commit_hook
Created September 13, 2018 10:58
Setting up eslint and tests running before each commit.
##Setting up eslint and tests running before each commit.
1. `npm install --save-dev husky`
2. `npm install --save-dev lint-staged`
4. Add husky config to run lint-staged script before every commit
```
"husky": {
"hooks": {
"pre-commit": "lint-staged"
@vahanNasibyan
vahanNasibyan / Dockerfile
Last active October 2, 2018 08:44
multistage builds for docker images
# Stage-1 dependencies
FROM node:8.12.0-alpine as pre
RUN apk add --update git && \
rm -rf /tmp/* /var/cache/apk/*
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json package.json
# Stage-1 dependencies
FROM node:8.12.0-alpine as pre
RUN apk add --no-cache git
RUN apk add --no-cache --virtual .build-deps alpine-sdk python \
&& npm install --production --silent \
&& apk del .build-deps