charlwillia6
charlwillia6
Reputation Top 1%
Charles
5 Snippets  (173rd place)
Published
1 Channel
Created
8 Channels
Following
Nov 7, 2017
Last Visit
Aug 14, 2017
Registered
208 points  (133rd place)
Reputation
Serious Code Generator
Junior Popular Coder
Junior Autobiographer
Serious Autobiographer

Recent Snippets See all snippets by charlwillia6

public by charlwillia6 created Feb 21, 2017  125  0  2  0

Uninstall package.json

Uninstall package.json: npm_uninstall.sh
# /bin/bash 

npm uninstall `ls -1 node_modules | tr '/\n' ' '`

																								
;

public by charlwillia6 created Apr 6, 2017  112  1  2  0

Powershell command to rename files to lowercase

Powershell command to rename files to lowercase: batch_rename_to_lowercase.txt
Get-ChildItem "C:\Path\To\Pics" -recurse | Where {-Not $_.PSIsContainer} | Rename-Item -NewName {$_.FullName.ToLower()}

																								
;

public by cwilli34 created Feb 21, 2017  78  2  1  0

Center images with caption aligning beneath the image.

Center images with caption aligning beneath the image.: center_image.html
<div style="display: block; text-align: center;">
  <div style="display: inline-block">
    <div class="wrapper" style="display: table; text-align: left">
      <a href="#" target="_blank"><img alt="Wib Ami Video" src="/assets/225577/fullsize/wib_ami_video.jpg" style="display: block; text-align: center;"></a>
      <div class="caption" style="display: table-caption; caption-side: bottom;">Ami: Network means an open, helping hand</div>
    </div>
  </div>
</div>

;

public by cwilli34 created Feb 21, 2017  60  0  1  0

Set SQL database to single user mode

Set SQL database to single user mode: database_single_user.sql
USE master;
GO
ALTER DATABASE AdventureWorks2012
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE;
GO
ALTER DATABASE AdventureWorks2012
SET READ_ONLY;
GO
ALTER DATABASE AdventureWorks2012
SET MULTI_USER;
GO

;

public by Peter Daugavietis created Sep 13, 2015  132  0  2  0

Complete git repository backup script to AWS S3

Complete git repository backup script to AWS S3: git-backup-to-AWS-S3.sh
#!/bin/bash

# Script to backup git repo to S3
# Set bucket, dir, password and account to use for the backup.  I keep mine in local env vars 
# These are set by localrc which lives on an encrypted home directory and is executed by my bashrc
bucket=$GITHUB_BACKUP_BUCKET
dir=$GITHUB_BACKUP_DIR
password=$GITHUB_BACKUP_PASSWORD
account=$GITHUB_ACCOUNT

# Setup repository to $1
repository=$1

date=`date '+%Y%m%d%H%M%S'`

# Create the backup directory
mkdir -p $dir

echo "Backing up $repository"

git clone --mirror git@github.com:$account/$repository.git $dir/$repository.$date.git
if [ $? -ne 0 ]; then
  echo "Error cloning $repository"
  exit 1
fi

tar cpzf $dir/$repository.$date.git.tar.gz $dir/$repository.$date.git
if [ $? -ne 0 ]; then
  echo "Error compressing $repository"
  exit 1
fi

#Optional file encryption
#echo $password | gpg -c --passphrase-fd 0 $dir/$repository.$date.git.tar.gz
#if [ $? -ne 0 ]; then
#  echo "Error encrypting $repository"
#  exit 1
#fi

if [ -f $dir/$repository.$date.git.tar.gz ]; then
  s3cmd put $dir/$repository.$date.git.tar.gz s3://$bucket/git.$repository.$date.git.tar.gz
fi

if [ $? -ne 0 ]; then
  echo "Error uploading $repository to S3"
  exit 1
fi

#delete tar file and checked out folder
/bin/rm $dir/$repository.$date.git.tar.gz
/bin/rm -rf $dir/$repository.$date.git
if [ $? -ne 0 ]; then
  echo "Error removing $repository"
  exit 1
fi

echo "Succesfully backed up $repository"

;