Skip to content

Instantly share code, notes, and snippets.

View chrisgilbert's full-sized avatar

Chris Gilbert chrisgilbert

View GitHub Profile
- name: Get list of databases
command: cat /etc/oratab
register: databases
changed_when: false
- name: Download latest create_db scripts
local_action: "git [email protected]:infrastructure/mosaic_infra_scripts.git dest=/tmp/mosaic_infra_scripts version={{ branch }}"
def authorize_key_for_root(config, *key_paths)
[*key_paths, nil].each do |key_path|
if key_path.nil?
fail "Public key not found at following paths: #{key_paths.join(', ')}"
end
full_key_path = File.expand_path(key_path)
if File.exists?(full_key_path)
config.vm.provision 'file',
@chrisgilbert
chrisgilbert / gist:58f57c82f74162ed5c0f
Last active June 25, 2021 19:17
Run Ansible or Ansible-Playbook from Rundeck
#!/bin/bash
# Interpret whether the input needs to go to ansible, or ansible-playbook and run appropriately
# First update the git repos for each project
/usr/bin/update-git-repos
export ANSIBLE_FORCE_COLOR=1
export ANSIBLE_RETRY_FILES_ENABLED=False
@chrisgilbert
chrisgilbert / ci-cd-ideas.cake
Last active March 19, 2019 17:57
Ideas for CI/CD implementation
// The basic ideas are:
// 1. We could use the cake Setup method thing to configure what the build does.
// 2. We can use implementation of interfaces to signal what needs to happen for each build step.
// 3. Custom steps would involve using a generic class, or creating your own and implementing required interfaces.
// 4. Each step would have to store state, e.g. a lock file to show it has been run.
// 5. The delivery step would use the strong typing to know which artefacts _should_ be there and what it should do with them.
// 6. You can pass a single parameter to the cake script and run it multiple times in parallel (maybe). You can also just run the "build-all" task to do it sequentially.
@chrisgilbert
chrisgilbert / reset-identity-columns.sql
Last active July 29, 2020 14:30
Reset SQL Server Identity Columns With a Gap
DECLARE @column_name varchar(MAX);
DECLARE @table_name varchar(MAX);
DECLARE curs CURSOR FOR
SELECT
identity_columns.name as ColumnName,
tables.name as TableName
FROM sys.tables tables
JOIN sys.identity_columns identity_columns
ON tables.object_id=identity_columns.object_id
ORDER BY tables.name;
@chrisgilbert
chrisgilbert / findLongRunningOp.js
Created September 14, 2020 08:57 — forked from kylemclaren/findLongRunningOp.js
Find and (safely) kill long running MongoDB ops
db.currentOp().inprog.forEach(
function(op) {
if(op.secs_running > 5) printjson(op);
}
)
function ecr-login()
{
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 761584570493.dkr.ecr.us-east-1.amazonaws.com
}
@chrisgilbert
chrisgilbert / keybase.md
Created September 22, 2021 10:37
keybase.md

Keybase proof

I hereby claim:

  • I am chrisgilbert on github.
  • I am chrisg42 (https://keybase.io/chrisg42) on keybase.
  • I have a public key ASBHG45-1jFJEKScKrsTKaAmQe2R3Hopwxa5yUguyN4nugo

To claim this, I am signing this object:

@chrisgilbert
chrisgilbert / gist:6cb797163e025500d35154305a99c3cd
Created October 11, 2021 08:56
OCC Photo Preview Generator With Quality Settings
#
# See: https://ownyourbits.com/2019/06/29/understanding-and-improving-nextcloud-previews/
#
OCC="sudo -u www-data php /var/www/nextcloud/occ"
$OCC config:app:set previewgenerator squareSizes --value="32 256"
$OCC config:app:set previewgenerator widthSizes --value="256 384"
$OCC config:app:set previewgenerator heightSizes --value="256"
$OCC config:system:set preview_max_x --value 2048
$OCC config:system:set preview_max_y --value 2048
@chrisgilbert
chrisgilbert / test.md
Last active March 18, 2022 14:55
Test mermaid
graph TD
    A[Github PR]-->|Check code changes| B{Any changed terraform envs}
    B -->|Users| C[Terraform Init]
    B -->|Backups| C
    B -->|Prod| C
    B -->|Dev| C
    C --> D[Terraform Plan]