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 typing import Callable | |
| from django.db import connection | |
| from django.db import models | |
| from django.views.generic import ListView | |
| class QuerySetWithCustomCount: | |
| """Wrapper for Queryset class that replaces .count() method with a custom callable""" |
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
| # Template python-build | |
| # This template allows you to validate your python code. | |
| # The workflow allows running tests and code linting on the default branch. | |
| image: python:3.8 | |
| pipelines: | |
| default: | |
| - parallel: |
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 RequestBodyMiddleware(object): | |
| def __init__(self, get_response): | |
| self.get_response = get_response | |
| def __call__(self, request): | |
| """ | |
| Access request.body before request. | |
| We need it for request.body to still be accessible after request | |
| for example while handling exceptions in Sentry | |
| See https://github.com/encode/django-rest-framework/issues/4050 |
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
| <key id="start_date" for="node" attr.name="start_date" attr.type="string" tag="true" /> |
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 requests_futures.sessions import FuturesSession | |
| def hello(future): | |
| print(future.result().text) | |
| s = FuturesSession(max_workers=10) | |
| future = s.get('http://requestb.in/tedj6fte') | |
| future.add_done_callback(hello) |
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 re | |
| INPUT = 'in.txt' | |
| OUTPUT = 'out.txt' | |
| with open(INPUT, 'r') as input_file: | |
| data = input_file.read().strip() | |
| data = re.sub(r'a', r'b', data) |
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
| { | |
| 'ringdowns': [ | |
| {'uid': 'user1-long-uid'}, | |
| ,,, | |
| ], | |
| 'hoots': [ | |
| { | |
| 'uid': 'user2-long-uid', | |
| 'position': 1, | |
| }, |
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
| { | |
| "children": { | |
| "_": { | |
| "children": { | |
| "_": { | |
| "children": {}, | |
| "data": { | |
| "id": "c0d2e6e84b0fa99d4ea351e3308822b0", | |
| "name": "angeltorontostaging-vm", | |
| "pvt_type": "vmbox" |
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
| <html> | |
| <head> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
| <script> | |
| $(document).ready(function(){ | |
| $.getJSON('http://prope.rs/api/<username>', function(props) { | |
| $(props).each(function(id) { | |
| root = $('<li />').addClass('prop').append( | |
| '<span class="text" />', | |
| '<br/>', |