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
| # get total requests by status code | |
| awk '{print $9}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | |
| # get top requesters by IP | |
| awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head | awk -v OFS='\t' '{"host " $2 | getline ip; print $0, ip}' | |
| # get top requesters by user agent | |
| awk -F'"' '{print $6}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head | |
| # get top requests by URL |
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
| $ snap install amass | |
| ... | |
| $ amass enum -d cicese.mx -src | |
| [DNS] cicese.mx | |
| [HackerTarget] imp-udb10.cicese.mx | |
| [HackerTarget] wireless-oc211.cicese.mx | |
| [RapidDNS] dhcp-ac14.cicese.mx | |
| [HackerTarget] pc-lankahuasa1.cicese.mx | |
| ... | |
| [RapidDNS] cicese-auditorio.cicese.mx |
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
| import contextlib | |
| @contextlib.contextmanager | |
| def capture(): | |
| """A context manager to capture stdout and stderr. | |
| http://stackoverflow.com/a/10743550/644075 | |
| """ | |
| import sys | |
| from cStringIO import StringIO |
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
| #!/bin/sh | |
| # Modified from kevincal version in https://gist.github.com/810399 | |
| # The following is a list of the most common PEP 8 errors and warnings; to | |
| # skip some just add them to the IGNORE variable (comma separated): | |
| # E111 indentation is not a multiple of four | |
| # E123 closing bracket does not match indentation of opening bracket's line | |
| # E201 whitespace after '(' | |
| # E202 whitespace before ')' |
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
| # -*- coding: utf-8 -*- | |
| from plone import api | |
| import transaction | |
| def get_least_used(limit=1): | |
| """List all keywords used up to limit times in content.""" | |
| catalog = api.portal.get_tool('portal_catalog') | |
| keywords = catalog.uniqueValuesFor('Subject') |
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
| # -*- coding: utf-8 -*- | |
| from plone import api | |
| import transaction | |
| def normalize(): | |
| """Remove spare spaces and transform keywords to lowercase.""" | |
| catalog = api.portal.get_tool('portal_catalog') | |
| results = catalog() |
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
| from plone import api | |
| from zope.component.hooks import setSite | |
| import transaction | |
| def spoof_request(app): | |
| from AccessControl.SecurityManagement import newSecurityManager | |
| from AccessControl.SecurityManager import setSecurityPolicy | |
| from Testing.makerequest import makerequest |
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
| >>> user, password = 'hvelarde', 'password' | |
| >>> from github3 import login | |
| >>> g = login(user, password=password) | |
| >>> o = g.organization('collective') | |
| >>> g.ratelimit_remaining | |
| 3369 | |
| >>> my_stats = [] | |
| >>> for r in o.iter_repos(): | |
| ... for c in r.iter_contributor_statistics(): | |
| ... if user in repr(c.author): |
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
| import pkg_resources | |
| import logging | |
| logger = logging.getLogger('zc.monitor') | |
| try: | |
| pkg_resources.get_distribution('zc.monitor') | |
| except pkg_resources.DistributionNotFound: |
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
| vcl 4.0; | |
| import directors; | |
| # probe definition for health checks | |
| probe healthcheck { | |
| .interval = 2s; | |
| .url = "/haproxy?monitor"; | |
| .timeout = 1s; |
NewerOlder