Skip to content

Instantly share code, notes, and snippets.

View ArthurZheng's full-sized avatar
😊

Jun ArthurZheng

😊
  • The Australian Access Federation
  • Melbourne Vic, 3000 Australia
View GitHub Profile
@ArthurZheng
ArthurZheng / cleanup.py
Created September 6, 2021 04:22 — forked from luhn/cleanup.py
An AWS Lambda function to delete old AMIs.
"""
Code adapted from and inspired by http://blog.ranman.org/cleaning-up-aws-with-boto3/.
"""
import os
import re
from datetime import datetime, timedelta
import boto3
@ArthurZheng
ArthurZheng / pr.md
Created September 10, 2021 03:55 — forked from karlhorky/pr.md
Fetch all GitHub pull requests to local tracking branches

NOTE

You may not need local branches for all pull requests in a repo.

To fetch only the ref of a single pull request that you need, use this:

git fetch origin pull/7324/head:pr-7324
git checkout pr-7324
# ...
@ArthurZheng
ArthurZheng / ActiveRecord Cheat Sheet v1
Created October 14, 2021 20:34 — forked from jessieay/ActiveRecord Cheat Sheet v1
Active Record cheat sheet with examples of queries I've needed most so far
ActiveRecord cheat sheet / EXAMPLES
INSTALL
=======
$ gem install activerecord
in GEMFILE: gem ‘activerecord’
REQUIRE
=======
require ‘active_record’
@ArthurZheng
ArthurZheng / README.md
Created November 4, 2021 01:31 — forked from Eyjafjallajokull/README.md
AWS EBS - Find unused snapshots

This script can help you find and remove unused AWS snapshots and volumes.

There is hardcoded list of regions that it searches, adjust the value to suit your needs.

Use snapshot.py snapshot-report to generate report.csv containing information about all snapshots.

snapshot.py snapshot-cleanup lets you interactively delete snapshot if it finds it is referencing unexisting resources.

./snapshots.py --help
@ArthurZheng
ArthurZheng / exception_spec.rb
Created November 14, 2021 09:34 — forked from tcnksm/exception_spec.rb
How to stub raising exceptions in rspec
class Foo
class << self
def exec
something
rescue => ex
ex.message
end
def something
"something"
@ArthurZheng
ArthurZheng / opt1_template.j2
Created February 2, 2022 23:24 — forked from halberom/opt1_template.j2
ansible - example of template if else
{# style 1 - long form #}
{% if filepath == '/var/opt/tomcat_1' %}
{% set tomcat_value = tomcat_1_value %}
{% else %}
{% set tomcat_value = tomcat_2_value %}
{% endif %}
{# style 2 - short form #}
{% set tomcat_value = tomcat_1_value if (filepath == '/var/opt/tomcat_1') else tomcat_2_value %}
@ArthurZheng
ArthurZheng / attribute-resolver-idem-ad.xml
Created October 18, 2022 05:14 — forked from daserzw/attribute-resolver-idem-ad.xml
IDEM Shibboleth Active Directory Attribute Resolver
<?xml version="1.0" encoding="UTF-8"?>
<AttributeResolver
xmlns="urn:mace:shibboleth:2.0:resolver"
xmlns:sec="urn:mace:shibboleth:2.0:security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:mace:shibboleth:2.0:resolver http://shibboleth.net/schema/idp/shibboleth-attribute-resolver.xsd
urn:mace:shibboleth:2.0:security http://shibboleth.net/schema/idp/shibboleth-security.xsd">
<!-- ========================================== -->