This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
DIR=date+%m%d%y | |
DEST=/db_backups/$DIR | |
mkdir $DEST | |
for fn in cat filenames.txt; | |
do mongodump -h localhost:27017 -d $fn -u $user -p $pwd -o $DEST --ssl | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.getCollection('CollectionName').aggregate( | |
{"$group" : { "_id": "$ItemKey", "count": { "$sum": 1 } } }, | |
{"$match": {"_id" :{ "$ne" : null } , "count" : {"$gt": 1} } }, | |
{"$project": {"name" : "$_id", "_id" : 0}} | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
docker rm -f $(docker ps -qa) | |
docker volume rm $(docker volume ls -q) | |
cleanupdirs="/var/lib/etcd /etc/kubernetes /etc/cni /opt/cni /var/lib/cni /var/run/calico /opt/rke" | |
for dir in $cleanupdirs; do | |
echo "Removing $dir" | |
rm -rf $dir | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Generates a MongoDB-style ObjectId in Node.js. Uses nanosecond timestamp in place of counter; | |
* should be impossible for same process to generate multiple objectId in same nanosecond? (clock | |
* drift can result in an *extremely* remote possibility of id conflicts). | |
* | |
* @returns {string} Id in same format as MongoDB ObjectId. | |
*/ | |
function objectId() { | |
const os = require('os'); | |
const crypto = require('crypto'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Backup your data | |
# Use at your own risk | |
# Usage ./extended-cleanup-rancher2.sh | |
# Include clearing all iptables: ./extended-cleanup-rancher2.sh flush | |
docker rm -f $(docker ps -qa) | |
docker rmi -f $(docker images -q) | |
docker volume rm $(docker volume ls -q) | |
for mount in $(mount | grep tmpfs | grep '/var/lib/kubelet' | awk '{ print $3 }') /var/lib/kubelet /var/lib/rancher; do umount $mount; done | |
cleanupdirs="/etc/ceph /etc/cni /etc/kubernetes /opt/cni /opt/rke /run/secrets/kubernetes.io /run/calico /run/flannel /var/lib/calico /var/lib/etcd /var/lib/cni /var/lib/kubelet /var/lib/rancher/rke/log /var/log/containers /var/log/pods /var/run/calico" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:alpine | |
WORKDIR /usr/src/app | |
COPY ["package.json", "npm-shrinkwrap.json*", "./"] | |
RUN npm install --silent && mv node_modules ../ | |
COPY . . | |
RUN npm install --save-dev @babel/core @babel/cli @babel/preset-env | |
RUN npm run build | |
EXPOSE 80 | |
CMD ["node", "dist/server.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker ps -a -q | % { docker stop $_ } | |
docker ps -a -q | % { docker rm $_ } | |
docker images --filter "dangling=true" -q --no-trunc | % { docker rmi $_ -f } | |
docker volume ls -qf dangling=true | % { docker volume rm $_ } | |
docker system prune -a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$EUID" -ne 0 ] | |
then echo "Please run as root" | |
exit | |
fi | |
dpkg -s glusterfs-client &> /dev/null | |
if [ $? -ne 0 ] | |
then | |
echo "GlusterFS is not installed; proceeding to install" | |
apt update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
[switch] $Cache | |
) | |
$start_args = if ($Cache) { | |
'repair', '--cache' | |
} else { | |
'modify', '--nocache' | |
} | |
get-vssetupinstance -all | Where-Object { $_.DisplayName -eq 'Visual Studio Professional 2019'} | foreach-object { | |
$args = $start_args + '--installPath', "`"$($_.InstallationPath)`"", '--passive', '--norestart' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Connect-AzureRmAccount | |
Select-AzureRmSubscription -SubscriptionId "subid" | |
$webapps = Get-AzureRmWebApp -ResourceGroupName 'rgname' | |
foreach ($webapp in $webapps) { | |
$app = Get-AzureRmResource -ResourceId $webapp.Id | |
$app.Properties.httpsOnly = $true | |
$app | Set-AzureRmResource -Force | |
OlderNewer