Skip to content

Instantly share code, notes, and snippets.

@ridakk
ridakk / sql-find-duplicate-rows.sql
Last active March 31, 2022 11:20
sql-find-duplicate-rows
select * from (
SELECT id,
ROW_NUMBER() OVER(PARTITION BY <column>, <column> ORDER BY id asc) AS Row
FROM <table_name>
) dups
where
dups.Row > 1
@ridakk
ridakk / Dockerfile
Created October 14, 2019 07:48
NodeJs TypeScript Multi-Stage Dockerfile
# 1st Stage for installing dependencies
FROM node:10.16.3 AS build-deps
COPY package*.json /build/
WORKDIR /build
RUN npm install
# 2nd Stage for compiling typescript
FROM node:10.16.3 AS compile-env
RUN mkdir /compile
COPY --from=build-deps /build /compile
@ridakk
ridakk / Jenkinsfile
Created September 11, 2019 08:13
git add & commit if there are changes
node {
stage('commit if changed') {
sh 'git diff --quiet && git diff --staged --quiet || git commit -am "chore: commit pipeline changes"'
}
}
@ridakk
ridakk / webpack.js
Created August 16, 2019 12:19
async function calculating hash of static folders and adding to DefinePlugin with webpack.merge
const fs = require('fs');
const webpack = require('webpack');
const merge = require('webpack-merge');
const TerserPlugin = require('terser-webpack-plugin');
const config = require('config');
const { hashElement } = require('folder-hash');
const base = require('./webpack.base');
const packageJson = require('./package.json');
const definePluginConfig = {
@ridakk
ridakk / Jenkinsfile
Created August 16, 2019 12:17
jenkinsfile scm with local branch to push remote repository
node {
nodejs('[email protected]') {
stage('checkout') {
checkout([
$class: 'GitSCM',
branches: [[name: '*/development']], // solves detached head issue
extensions: [[$class: 'LocalBranch', localBranch: '**']], // required to push changes to remote repo
userRemoteConfigs: scm.userRemoteConfigs
])
}
@ridakk
ridakk / Vagrantfile
Last active August 16, 2019 12:20
vagrantfile for ubuntu 16 with docker
Vagrant.configure(2) do |config|
(0..0).each do |i|
config.vm.define "utility" do |node|
node.vm.box = "ubuntu/xenial64"
node.vm.provision "shell", inline: "apt-get update -y && \
apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common && \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && \
apt-key fingerprint 0EBFCD88 && \
@ridakk
ridakk / Jenkinsfile
Last active August 16, 2019 12:20
read package.json version in jenkinsfile
stage('Version') {
env.Version=readJSON(file: 'package.json').version
}
@ridakk
ridakk / Dockerfile
Last active August 16, 2019 12:23
using ssh key in docker image
# add credentials on build
ARG SSH_PRIVATE_KEY
RUN mkdir /root/.ssh/
RUN echo "${SSH_PRIVATE_KEY}" > /root/.ssh/id_rsa
RUN chmod 600 /root/.ssh/id_rsa
# make sure your domain is accepted
RUN touch /root/.ssh/known_hosts
RUN ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts