Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jheerman's full-sized avatar

John Heerman jheerman

View GitHub Profile
@jheerman
jheerman / gist:1a15a0a504a35eb99018d750c3f45c40
Last active November 2, 2023 20:30
Get AWS roles where last usage is greater than specified date
aws iam list-roles | jq -r '.Roles[].RoleName' | xargs -I % aws iam get-role --role-name % | jq --arg cutoff '2023-04-01T00:00' '.[] | select(.RoleLastUsed.LastUsedDate | . <= $cutoff ) | {RoleName: .RoleName, LastUsedDate: .RoleLastUsed.LastUsedDate}' | jq -s '.' > roles_last_used_april.json
#!/bin/bash
if [ $# -ne 2 ];
then echo -e "\nUsage: '$0 <path to mp4 clips> <name of finalized video>'\n"
exit 1
fi
cd $1
readlink -f *.MP4 > files.txt
sed -i -e 's/^/file /' files.txt
@jheerman
jheerman / update_log-retention_policy.sh
Last active December 18, 2021 04:44
Update AWS Cloudwatch Retention Policy on Log Groups
#!/bin/bash
# This script takes the number of days to retain AWS Cloudwatch logs as an argument
# and updates all AWS Cloudwatch logs policy to the desired retention length
if [ $# -eq 0 ]
then
echo "Please specify the number of days to retain AWS Cloudwatch Logs"
echo "Usage: update-log-retention-policy 90"
echo "Done"
@jheerman
jheerman / gist:15d1c75c40bf57ab5ab3cde6dcae80cd
Created June 25, 2020 04:45
Compress video file using ffmpeg
ffmpeg -i input.mp4 -s 640x480 -c:a copy output.mp4
@jheerman
jheerman / gist:d1dfe85f603bac7b0fba4ed26465a1ca
Created June 25, 2020 04:43
ffmpeg join multiple mp4 files
ffmpeg -f concat -i join.txt -c copy output.mp4
ffmpeg -f gif -i infile.gif outfile.mp4
@jheerman
jheerman / gist:4142537
Created November 25, 2012 05:49
M4A Spinner Focus
var spinMeUp = FindViewById<Spinner>(Resource.Id.spinMeUp);
var items = new string[] {"Up", "Down", "Left", "Right", "B", "A", "Select", "Start" };
var adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerItem, items);
spinMeUp.Adapter = adapter;
spinMeUp.Focusable = true;
spinMeUp.FocusableInTouchMode = true;
spinMeUp.RequestFocus (FocusSearchDirection.Up);
@jheerman
jheerman / gist:4107842
Created November 18, 2012 22:19
Mono for Android Alert Dialog Example
var builder = new AlertDialog.Builder(this);
builder.SetTitle ("Test");
builder.SetIcon (Resource.Drawable.Icon);
builder.SetMessage ("Click a button");
builder.SetPositiveButton ("Yes", (sender, e) => {
Toast.MakeText (this, "You clicked positive button", ToastLength.Short).Show ();
});
builder.SetNegativeButton ("No", (sender, e) => {
@jheerman
jheerman / gist:3802802
Created September 29, 2012 01:06
M4A TextView EditorAction Implementation
var editText = FindViewById<EditText>(Resource.Id.search);
editText.EditorAction += (object sender, TextView.EditorActionEventArgs e) => {
if (e.ActionId == ImeAction.Search) {
//do something here when search action button pressed
}
return;
};
@jheerman
jheerman / gist:3788834
Created September 26, 2012 15:53
M4A sample to center child view in relative layout
var viewContainer = new RelativeLayout(this);
var layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FillParent, RelativeLayout.LayoutParams.FillParent);
AddContentView (viewContainer, layoutParams);
var btn = new Button(this) { Text = "Centered" };
var btnParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
btnParams.AddRule (LayoutRules.CenterInParent);
viewContainer.AddView (btn, btnParams);