This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Add to your own config at ~/.config/mise/config.toml | |
| [tasks."docker:prune-preview"] | |
| description = "Dry-run of docker system prune: show what each prune flavour WOULD remove" | |
| run = ''' | |
| {% raw %} | |
| hr() { printf '\n\033[1m== %s\033[0m\n' "$1"; } | |
| hr "STOPPED CONTAINERS (removed by: docker container/system prune)" | |
| docker ps -a --filter status=exited --filter status=created \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| #MISE description="Dismiss/reopen all open code-scanning alerts for a CVE, with a comment" | |
| #MISE dir="{{cwd}}" | |
| # | |
| # Bulk-triage GitHub code-scanning alerts by rule/CVE id. | |
| # | |
| # Dismiss (or reopen) EVERY open alert matching a CVE in one shot, recording a | |
| # reason + comment. Dismissing keeps the alert tracked — it leaves the active | |
| # list but is retained under `is:dismissed`, and when a later scan no longer | |
| # finds the CVE (e.g. upstream ships the fix and we bump the package) GitHub |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class OrderManager(object): | |
| """ A helper for placing and tracking orders in Quantopian. """ | |
| def __init__(self): | |
| self.orders = [] | |
| self.context = None | |
| self.data = None | |
| def update(self, context, data): | |
| self.context = context |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| This is an example of a one-or-the-other order, generalised as an any-one order. Useful when setting orders around a price point, such that if one order is triggered (begins to fill) the other orders are cancelled. | |
| """ | |
| class AnyOneOrder(object): | |
| """ A group of orders where when one order is triggered, all other open orders are cancelled. """ | |
| def __init__(self, *orders_or_ids): | |
| self.order_ids = set( | |
| map(self._get_id, orders_or_ids) | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## | |
| # Prefix a string with an icon | |
| def iconify(label, icon, options = {}) | |
| "#{ icon(icon, options) } #{ label }".strip.html_safe | |
| end | |
| ## | |
| # Create a label | |
| def llabel(text, kind = :default) | |
| content_tag(:span, text, class: [ 'label', "label-#{ kind }" ].compact) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # This should go into spec/support/auth_spec_helpers.rb | |
| module AuthSpecHelpers | |
| ## | |
| # Convenience method for setting the Digest Authentication details. | |
| # To use, pass the username and password. | |
| # The method and target are used for the initial request to get the digest auth headers. These will be translated into 'get :index' for example. | |
| # The final 'header' parameter sets the request's authentication headers. | |
| def authenticate_with_http_digest(user, password, method = :get, target = :index, header = 'HTTP_AUTHORIZATION') |