Skip to content

Instantly share code, notes, and snippets.

Avatar

Jasdeep Khalsa jasdeepkhalsa

  • London, UK
View GitHub Profile
@jasdeepkhalsa
jasdeepkhalsa / docker-compose.yml
Created Aug 18, 2020
Wordpress in Docker & Docker Compose
View docker-compose.yml
version: '3.3'
services:
wordpress:
depends_on:
- db
- phpmyadmin
image: wordpress:latest
ports:
- 8000:80
@jasdeepkhalsa
jasdeepkhalsa / postgres.md
Last active Aug 17, 2020
Postgres Commands
View postgres.md

Install

apt-get install postgresql-12

Login to Postgres as the default user

sudo -u postgres psql
View pipe.js
const pipe = (...fns) => x => fns.reduce((v, f) => f(v), x);
const fn1 = s => s.toLowerCase();
const fn2 = s => s.split('').reverse().join('');
const fn3 = s => s + '!'
const newFunc = pipe(fn1, fn2, fn3);
const result = newFunc('Time'); // emit!
@jasdeepkhalsa
jasdeepkhalsa / compose.js
Created Jul 24, 2020 — forked from ericelliott/compose.js
Compose implementation
View compose.js
const compose = (...fns) => x => fns.reduceRight((v, f) => f(v), x);
@jasdeepkhalsa
jasdeepkhalsa / rsyncAB.sh
Last active Apr 3, 2020
rsync A->B - Transfer a directory from a source server (A) into a directory on a target server (B) via SSH & rsync
View rsyncAB.sh
#!/usr/bin/env bash
# This script will transfer a directory from a source server (A)
# into a directory on a target server (B)
# Pre-requisites: The script must be run by a user who has SSH / passwordless access to both server A & B
# From StackExchange.com (https://unix.stackexchange.com/a/317815) - Authored by David I. (https://unix.stackexchange.com/users/71948/david-i) adapated from an answer by roaima (https://unix.stackexchange.com/users/100397/roaima) - Under the license: cc by-sa 4.0 with attribution required (https://creativecommons.org/licenses/by-sa/4.0/)
# Slight modifications may have been made to the original script, which are in no way endorsed by the original authors of this script
# Specific alterations include:
# - the rsync parameters checking files by checksum instead of date/time/size
@jasdeepkhalsa
jasdeepkhalsa / mysqlAB.sh
Last active Apr 3, 2020
MySQL A->B - Pipe a MySQL database from a source server (A) into a target MySQL database on another server (B)
View mysqlAB.sh
#!/usr/bin/env bash
# This script will pipe a MySQL database from a source server (A)
# into a target MySQL database on another server (B)
# From StackExchange.com (https://dba.stackexchange.com/a/180) - Authored by David Hall - Under the license: cc by-sa 4.0 with attribution required (https://creativecommons.org/licenses/by-sa/4.0/)
# Slight modifications may have been made to the original script, which are in no way endorsed by the original author(s) of this script
# Specific alterations include:
# - Adding both a source & target hostname & database
# - Updating the command-line options in line with the latest versions of the `mysqldump` & `mysql` command-line tools
@jasdeepkhalsa
jasdeepkhalsa / script.sh
Last active Apr 9, 2020
Automatically determining values in a Bash script
View script.sh
#!/usr/bin/env bash
APP=a
if [[ "$1" ]]; then
APP="$1"
fi
# This is automatically determined by the $APP variable
CONFIG="app-default.config"
case "$APP" in
@jasdeepkhalsa
jasdeepkhalsa / build-and-run-docker-image.md
Last active Mar 31, 2020
Build and run a Docker image
View build-and-run-docker-image.md

Build Image

cd into the project root and then...

docker build --tag "app:latest" --file "app.dockerfile" .

Run Image

@jasdeepkhalsa
jasdeepkhalsa / waitForWindowCypress.js
Last active Jan 23, 2020
Cypress waitForWindow recursive promise function
View waitForWindowCypress.js
export default function waitForWindow(property, timeout = 10000, interval = 500, attempts = 0) {
if (!property) {
return Promise.reject(new Error('No window property added to the function'))
}
return cy.window()
.then(
(win) => {
if (win[property] !== undefined) {
return true
}
@jasdeepkhalsa
jasdeepkhalsa / querystrings.js
Created Jan 12, 2020
Read URL Query Strings for Data Prepopulation
View querystrings.js
// Data pre-population
var queryStrings = decodeURIComponent(location.search).split(/[?&]/).reduce(function(total, qs) {
total[qs.split('=')[0]] = qs.split('=')[1];
return total;
}, {});
if (queryStrings) {
var inviteeEmailValue = queryStrings['Email'];
var inviteeFullNameValue = queryStrings['Name'];
var inviteeMobileValue = queryStrings['mobile'];
You can’t perform that action at this time.