Skip to content

Instantly share code, notes, and snippets.

View snobear's full-sized avatar
🎸

Jason Ashby snobear

🎸
  • NC
  • 04:37 (UTC -04:00)
View GitHub Profile
@snobear
snobear / clone-github-org-repos.sh
Created October 26, 2021 14:44
Clone all repos for a Github organization
# clone all public and private repos for a github org. user must have full access to repos.
USERNAME=someuser
ORGNAME=myorg
# personal access token
TOKEN=abc123tokenstringhere
# num repos to return per page - max 100
PERPAGE=100
BASEURL="https://api.github.com/orgs/${ORGNAME}/repos"
TOTALPAGES=`curl -I -i -u $USERNAME:$TOKEN -H "Accept: application/vnd.github.v3+json" -s ${BASEURL}\?per_page\=${PERPAGE} | grep -i link: 2>/dev/null|sed 's/link: //g'|awk -F',' -v ORS='\n' '{ for (i = 1; i <= NF; i++) print $i }'|grep -i last|awk '{print $1}' | tr -d '\<\>' | tr '\?\&' ' '|awk '{print $3}'| tr -d '=;page'`
@snobear
snobear / long_term_retention.txt
Last active February 9, 2021 14:58
DEBUG output: azurerm_mssql_database long_term_retention InvalidParameterValue
######### Long term retention request #########
[DEBUG] AzureRM Request:
PUT /subscriptions/2abcd789-1d3g-2ag8-cc77-5ja2fjbdklf9f/resourceGroups/foo-rg-prod-cnus/providers/Microsoft.Sql/servers/foo-sql-prod/databases/foo-sqldb-prod/backupLongTermRetentionPolicies/default?api-version=2017-03-01-preview HTTP/1.1
Host: management.azure.com
User-Agent: Go/go1.15.5 (amd64-darwin) go-autorest/v14.2.1 Azure-SDK-For-Go/v49.2.0 sql/v3.0 HashiCorp Terraform/0.14.6 (+https://www.terraform.io) Terraform Plugin SDK/1.13.1 terraform-provider-azurerm/2.46.1 pid-222c6c49-1b0a-5959-a213-6608f9eb8820
Content-Length: 2
Content-Type: application/json; charset=utf-8
X-Ms-Correlation-Request-Id: 2450b752-580d-91e9-d0ac-701bf6049f79
Accept-Encoding: gzip
@snobear
snobear / expire-s3-bucket.sh
Last active May 8, 2023 19:31
Expire all objects in an S3 bucket with a lifecycle rule using aws cli
#!/bin/bash
# set an s3 bucket to expire after one day. Faster than waiting to delete all the files.
# check back after a day or so (depending on size of bucket) and delete the bucket from s3
if [ "$#" -lt 2 ]; then
echo "error: run_report expects at least 2 arguments; got $#."
echo "Usage:"
echo " ./$(basename $0) region bucket"
exit 1
fi
@snobear
snobear / install.MD
Last active July 2, 2020 08:29
Installing Alfresco and Citeck EcoS on Linux

Launch CentOS 7 64-bit instance on AWS - use t2.medium since 2GB of mem is the minimum requirement for Alfresco.

Open port 8080 in AWS security firewall settings.

Update all server packages

# login with centos user
sudo yum update -y
# reboot if kernel is updated
@snobear
snobear / opentok_screenshare.js
Last active December 17, 2019 03:22
chrome screen share - page js
/*
* Check if user has extension installed and launch
*
*/
function shareScreen() {
// Chrome screen-sharing extension ID
var extensionId = 'dgckdhnehiggafbppghjpnapieoegekl';
// check that the extension is installed by looking for a
@snobear
snobear / cancel-pulp-tasks.sh
Last active June 21, 2019 12:54
script to cancel all pulp tasks
#!/bin/bash
#
# Cancel all pulp tasks that are just in a specifiedstate
tmpfile=/tmp/tasks
read -p "Enter task state to kill, e.g. Waiting: " ans
echo ""
if [ "${#ans}" -gt 0 ]
then
@snobear
snobear / views.py
Last active August 29, 2015 14:15
getstream return enriched as json
# this throws: <stream_django.enrich.EnrichedActivity object at 0x7f8ffc86e250> is not JSON serializable
from django.http import HttpResponse, HttpResponseServerError
from stream_django.enrich import Enrich
from stream_django.feed_manager import feed_manager
import json
def enrich_feed(request):
context = {}
try:
# raw feed data
@snobear
snobear / gist:908fe9c7ac19548d4ae7
Created February 5, 2015 16:07
fpm perl metadata error
root@test01~$ /usr/bin/fpm --rpm-use-file-permissions --debug -n perl-JKL-Authen-Smb --package /home/banjer --workdir /tmp_nfs --no-cpan-test --rpm-auto-add-directories --no-auto-depends --cpan-perl-lib-path /usr/local/perl-5.16.2/lib/site_perl/5.16.2 --cpan-cpanm-bin /usr/local/bin/cpanm -s cpan --description 'Packaged with fpm. To be used exclusively by JKL, Inc.' -t rpm Authen::Smb"
{:level=>:info, :file=>"fpm/command.rb", :method=>"execute", :timestamp=>"2015-02-05T10:47:45. %6N-0500", :message=>"Setting workdir", :line=>"279", :workdir=>"/tmp_nfs"}
{:level=>:debug, :file=>"fpm/command.rb", :method=>"execute", :timestamp=>"2015-02-05T10:47:45. %6N-0500", :message=>"Setting attribute", :line=>"323", :output_type=>"rpm"}
{:level=>:debug, :input_type=>"cpan", :file=>"fpm/command.rb", :method=>"execute", :timestamp=>"2015-02-05T10:47:45. %6N-0500", :message=>"Setting attribute", :line=>"323"}
{:level=>:debug, :file=>"fpm/command.rb", :method=>"execute", :timestamp=>"2015-02-05T10:47:45. %6N-0500",
@snobear
snobear / mco-cheat-sheet
Last active December 10, 2021 16:51
MCollective cheat sheet
# MCollective Cheat Sheet
MCollective is a server orchestration tool that is built by Puppet Labs and so is tightly integrated with the puppet infrastructure. Commands a run from the control aka "client" server.
## Finding/listing hosts
List all
```
mco find
@snobear
snobear / clone.py
Last active October 17, 2023 06:39
Clone VM from template with pyVmomi
#!/usr/bin/env python
"""
NOTE:
This gist has been moved to EZmomi:
https://github.com/snobear/ezmomi
Give it a star or fork. Contributions are more than welcome. I'm hoping it will become an easy cli tool for
common VMware tasks.