Skip to content

Instantly share code, notes, and snippets.

View TryTryAgain's full-sized avatar
🎯
Focusing

Michael Lawler TryTryAgain

🎯
Focusing
View GitHub Profile
@jpetitcolas
jpetitcolas / snippet.sh
Created February 24, 2020 14:07
Getting AWS CloudWatch Insight results from CLI
aws logs start-query \
--profile [PROFILE] \
--log-group-name [GROUP_NAME] \
--start-time `date --date="-30 minutes" "+%s"` \
--end-time `date "+%s"` \
--query-string 'fields @message | limit 50' \
| jq '.queryId' \
| xargs -I{} aws --profile [PROFILE] logs get-query-results --query-id {} \
| jq '.results | .[][0].value'
@psa-jforestier
psa-jforestier / lambda_function_ALBS3Logs_to_CloudWatchLogs.py
Created November 5, 2019 13:04
A lambda function to stream Application Load Balancer logs dropped in S3 to CloudWatch Logs
'''
This function send Application Load Balancer logs to CloudWatch Logs. So you can use CloudWatch tools, like Insight or custom metrics.
By default, ALB log its access in gz file in S3, and there is no way yo send the log directly to a Log Group / Log Stream.
This lambda function is triggered on S3 "PUT" action (when ALB write its log file). It then download the file localy, unzip it, sort it, and stream it to a CloudWatch log groups.
Installation
Activate ALB logs, and indicate the S3 bucket and the prefix for the log files. Enable, on the bucket, the deletion of old log files
@dagronf
dagronf / ShowSystemPreferencePanes.swift
Last active April 29, 2024 17:21
macOS: Open system preferences at a specified pane using Swift (or Objective-C) using x-apple.systempreferences
// Applescript: tell application "System Preferences" to get anchors of current pane
// Result:
// { anchor "Privacy_Reminders" of pane id "com.apple.preference.security" of application "System Preferences",
// anchor "Privacy_SystemServices" of pane id "com.apple.preference.security" of application "System Preferences",
// anchor "Privacy_Calendars" of pane id "com.apple.preference.security" of application "System Preferences",
// anchor "Firewall" of pane id "com.apple.preference.security" of application "System Preferences",
// anchor "Privacy_Assistive" of pane id "com.apple.preference.security" of application "System Preferences",
// anchor "Privacy_LinkedIn" of pane id "com.apple.preference.security" of application "System Preferences",
// anchor "Privacy_Accessibility" of pane id "com.apple.preference.security" of application "System Preferences",
@paulgregg
paulgregg / README.md
Last active February 6, 2024 09:34
Converting a gitlab export to simple git repo

Converting a gitlab export to simple git repo

Gitlab exports a tar.gz file which contains a file called project.bundle. We can convert this file into a normal git repo using the following steps:

Extract the project.bundle file

$ tar xvfz GitLabExport.gz
@RichardBronosky
RichardBronosky / touchid_sudo.sh
Last active April 18, 2024 03:17
Use TouchID for sudo on modern MacBook Pro machines
#!/bin/bash
# curl -sL https://gist.githubusercontent.com/RichardBronosky/31660eb4b0f0ba5e673b9bc3c9148a70/raw/touchid_sudo.sh | bash
# This script is ready to copy-paste in whole, or just the line above (without the leading #)
# Use TouchID for sudo on modern MacBook Pro machines
# This script adds a single line to the top of the PAM configuration for sudo
# See: https://apple.stackexchange.com/q/259093/41827 for more info.
touchid_sudo(){
@darrenrogan
darrenrogan / AWS remove delete markers from S3
Created October 16, 2018 22:54
AWS CLI to remove delete markers (to enable the deletion of the S3 bucket)
aws s3api delete-objects --bucket bucket-name --delete "$(aws s3api list-object-versions --bucket "bucket_name" --output=json --query='{Objects: DeleteMarkers[].{Key:Key,VersionId:VersionId}}')"
@pkazi
pkazi / cloudTrailEventNames.list
Last active March 23, 2024 09:37
List of values for parameter EventName in AWS Cloudtrail events
AbortDocumentVersionUpload
AbortEnvironmentUpdate
AbortMultipartUpload
AbortVaultLock
AcceptAccountMapping
AcceptCertificateTransfer
AcceptDelegate
AcceptDirectConnectGatewayAssociationProposal
AcceptFxPaymentCurrencyTermsAndConditions
AcceptHandshake
@kinlane
kinlane / automox-api.json
Created July 4, 2018 08:33
automox api
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "Automox API",
"description": "The Automox API is a powerful interface that allows you to integrate Automox reporting data into you applications and control the various settings of your account.\n\nAll endpoints are only accessible via https and are located at\n`api.automox.com`. For instance: you can see events associated with your account by accessing the following URL with your ID:\n(replace API-KEY with your own):\n```\n https://console.automox.com/api/events?api_key=API-KEY\n```\n## Limits\nBe nice. If you're sending too many requests too quickly, we'll send back a\n`429` error code (Too Many Requests).\nYou are limited to 5000 requests per hour per `api_key` overall. Practically, this means you should (when possible) authenticate\nusers so that limits are well outside the reach of a given user.\n",
"termsOfService": "https://www.automox.com/",
"contact": {
"name": "support@automox.com"
}
@apolloclark
apolloclark / lock_down_public_s3_buckets.md
Last active January 27, 2023 08:10
Bash one-liner to find public facing AWS S3 buckets, and make them private

Command

aws s3api list-buckets --query 'Buckets[*].[Name]' --output text | xargs -I {} bash -c 'if [[ $(aws s3api get-bucket-acl --bucket {} --query '"'"'Grants[?Grantee.URI==`http://acs.amazonaws.com/groups/global/AllUsers` && Permission==`READ`]'"'"' --output text) ]]; then aws s3api put-bucket-acl --acl "private" --bucket {} ; fi'



1. List all of the user's buckets, and output the name, as text.

@kizzx2
kizzx2 / with-env.ps1
Last active December 3, 2023 23:06
Run command with environment variables in PowerShell
$ori = @{}
Try {
$i = 0
# Loading .env files
if(Test-Path $args[0]) {
foreach($line in (Get-Content $args[0])) {
if($line -Match '^\s*$' -Or $line -Match '^#') {
continue
}