This file contains 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 mock | |
def returnList(items): | |
def func(): | |
for item in items: | |
yield item | |
yield mock.DEFAULT | |
generator = func() |
This file contains 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 python | |
"""Port test | |
Python script to test open outgoing ports from local network | |
""" | |
import socket | |
for port in range(1,65000): | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
This file contains 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
S & Z - intersection | |
S | Z - union | |
S - Z - difference | |
S ^ Z - symetric difference |
This file contains 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
def decorator(fn): | |
def inner(name): | |
return '<a>' + fn(name) + '</a>' | |
return inner | |
def decorator_parameterized(html_tag): | |
def decorator(fn): | |
def inner(name): | |
return '<{}>'.format(html_tag) + fn(name) + '</{}>'.format(html_tag) | |
return inner |
This file contains 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
+refs/heads/dev:refs/heads/dev +refs/pull/*:refs/remotes/origin/pr/* |
This file contains 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 LoginRequiredMixin(object): | |
""" | |
View mixin which requires that the user is authenticated. | |
""" | |
@method_decorator(login_required) | |
def dispatch(self, request, *args, **kwargs): | |
return super(LoginRequiredMixin, self).dispatch( | |
self, request, *args, **kwargs) |
This file contains 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 django.db import connection | |
from django.utils.log import getLogger | |
logger = getLogger(__name__) | |
class QueryCountDebugMiddleware(object): | |
""" | |
This middleware will log the number of queries run | |
and the total time taken for each request (with a | |
status code of 200). It does not currently support |
This file contains 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
+-------------------+-----------------+------------------------------+ | |
| Greedy quantifier | Lazy quantifier | Description | | |
+-------------------+-----------------+------------------------------+ | |
| * | *? | Star Quantifier: 0 or more | | |
| + | +? | Plus Quantifier: 1 or more | | |
| ? | ?? | Optional Quantifier: 0 or 1 | | |
| {n} | {n}? | Quantifier: exactly n | | |
| {n,} | {n,}? | Quantifier: n or more | | |
| {n,m} | {n,m}? | Quantifier: between n and m | | |
+-------------------+-----------------+------------------------------+ |
This file contains 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
\d - digit [0,9] | |
\w - digit, ASCII letter or underscore | |
\s - whitespace, i.e. space, tab, newline(\n), carriage return(\r), vertical tab(Ctrl + K) <-vertical tab not useful anymore | |
\D == [^\d] - 1 character which is not digit | |
\W == [^\w] - 1 character which is not ASCII letter, digit and underscore | |
\S == [^\s] - 1 character which is not type of whitespace | |
--------------------------------------------------------------------------------------- |