Skip to content

Instantly share code, notes, and snippets.

View christopher-paul-shaw's full-sized avatar
💭
The same thing we do every night, try to take over the world!

Christopher Shaw christopher-paul-shaw

💭
The same thing we do every night, try to take over the world!
View GitHub Profile
@christopher-paul-shaw
christopher-paul-shaw / reset_and_sync_local_repo_with_remote.md
Created February 4, 2022 08:33
Reset and Sync local Repo with Remote

git fetch origin && git reset --hard origin/master && git clean -f -d

@christopher-paul-shaw
christopher-paul-shaw / loop over elements in js
Created September 13, 2021 08:31
Loop Over Elements in JS
let elements = document.querySelectorAll('.selector');
<!-- LEGACY -->
for (i = 0; i < elements.length; i++) {
console.log(elements[i]);
}
<!-- New -->
elements.forEach(function(element) {
console.log(element);

stop all containers: docker kill $(docker ps -q)

remove all containers docker rm $(docker ps -a -q)

remove all docker images docker rmi $(docker images -q)

@christopher-paul-shaw
christopher-paul-shaw / deploy.sh
Last active December 30, 2019 10:04
Deployment Script For relocating streamed deployments
#!/bin/bash
REPONAME=$1
BRANCH=$2
stream_directory=/home/deployment_user/stream_$BRANCH/
deploy_directory=/var/www/qa/$REPONAME/$BRANCH/
if [ $BRANCH == "master" ]
then
@christopher-paul-shaw
christopher-paul-shaw / Download Files Keeping Directory Structure
Created September 19, 2019 09:19
PHP Script for Downloading Files from Specific URLS and keeping the Directory Structure.
<?php
$host = "https://www.example.com";
$target_dir = './download';
$urls = [
'/img/header.png',
'/js/example.js',
'/styles/global.css',
];
@christopher-paul-shaw
christopher-paul-shaw / mysql-add-col.php
Created July 19, 2019 08:13
Generating Add Column SQL from Array in php
<?php
$cols = [
'col1',
'col2',
'col3',
'col4',
'col5',
'col6',
'col7',
@christopher-paul-shaw
christopher-paul-shaw / mysqldump-progress-export
Last active November 29, 2022 09:00
MySQL Dump With Progress Bar
Exporting From DB
mysqldump -u root -ppassword databasename | pv --progress --size 10g -t -e -r -a > databasedump.sql
Importing
pv sqlfile.sql | mysql -uxxx -pxxxx dbname