This file contains hidden or 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
#Uninstalling chef on CentOS | |
sudo yum remove -y chef.x86_64 | |
sudo rm -rf /var/chef; sudo rm -rf /etc/chef; sudo rm -rf /opt/chef |
This file contains hidden or 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
# Removing a borked terraform lock | |
terraform force-unlock bcf8815f-53db-ad60-45d5-488829a83e5d |
This file contains hidden or 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
#Nightly crontab cleanup of docker images with a 36 hour rentention window | |
# To implement: | |
# 1. > sudo crontab -e | |
# 2. insert the following into the crontab file to implement cleanups at 7 am server local time | |
0 7 * * * /usr/bin/docker image prune -a --force --filter "until=36h" | |
#3 Verifly successful run in log at: /var/spool/cron |
This file contains hidden or 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
//Change owning user and group of file | |
sudo chown centos:centos main-config.xml | |
//Give read privs to user | |
chmod u+r main-config.xml | |
//Give write/update privs to user | |
chmod u+u main-config.xml | |
//Give execute privs to user | |
chmod u+x main-config.xml |
This file contains hidden or 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
//Find the name of the related process by PID | |
ps -p 1234 -o command= |
This file contains hidden or 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
////journalctl//// | |
//Reference: https://www.digitalocean.com/community/tutorials/how-to-use-journalctl-to-view-and-manipulate-systemd-logs | |
//Display n number of most recent journalctl entries (with paging) | |
journalctl -n 500 | |
//Display n number of most recent journalctl entries (no paging, starting with most recent) | |
journalctl | tail -n 500 |
This file contains hidden or 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
CREATE TABLE dbo.DBCCInfoDump (ID INT IDENTITY(1,1),parentInfo VARCHAR(256), Object VARCHAR(256), field VARCHAR(256), value VARCHAR(256)) | |
GO | |
sp_msforeachdb @command1 = 'INSERT INTO DBCCInfoDump (parentInfo, Object, field, value) | |
EXEC (''DBCC DBINFO(?) WITH TABLERESULTS'')' |
This file contains hidden or 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
--Check Database Restore/Backup status | |
SELECT percent_complete, | |
session_id, | |
start_time, | |
status, | |
command, | |
wait_type, | |
last_wait_type | |
FROM sys.dm_exec_requests |
This file contains hidden or 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 pymongo import MongoClient | |
#setup connection | |
uri = "mongodb://testUser:xyz123@localhost/testDB?authMechanism=SCRAM-SHA-1" | |
client = MongoClient(uri) | |
db = client.TestDB | |
#setup query | |
cursor = db.TestCollection.find().limit(10) |
This file contains hidden or 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
--Find the last IDENTITY value generated for each table in a database | |
set nocount on | |
create table #CurrentIdentValues (tableName varchar(100), curIdent bigint) | |
exec sp_MSforeachtable 'insert #CurrentIdentValues select ''?'', IDENT_CURRENT( ''?'' )'; | |
select * from #CurrentIdentValues | |
ORDER by curIdent desc; |