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 tracer, { Span } from "dd-trace"; | |
import pg from "pg"; | |
/** | |
* Patches pg.Pool to add tracing. | |
*/ | |
export function patchPgPool(serviceName: string) { | |
const name = "pg-pool.connect"; | |
const service = `${serviceName}-postgres`; |
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 _, { range } from "lodash"; | |
import os from "os"; | |
import { TestedLogger } from "./TestedLogger"; | |
describe("LogStream", () => { | |
it("should write synchronously", () => { | |
// Arrange | |
const testedLogger = new TestedLogger(); | |
// Act |
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 typing import Any | |
from typing import Dict | |
from typing import Type | |
from typing import TYPE_CHECKING | |
from typing import TypeVar | |
| |
from pynamodb.attributes import MapAttribute | |
| |
| |
MapT = TypeVar('MapT', bound=MapAttribute) |
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 gc | |
import sys | |
import types | |
import unittest.mock | |
from typing import Any | |
from typing import Callable | |
from typing import Generator | |
from typing import Optional | |
from typing import TYPE_CHECKING |
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 Foo(): | |
message = 'foo' | |
def bar(self): | |
print('bar') | |
from unittest.mock import patch | |
def baz(self): | |
print(self.message) |
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 datetime import datetime | |
import pytz | |
import dateutil.tz | |
from pynamodb.models import Model | |
from pynamodb.attributes import NumberAttribute, UTCDateTimeAttribute | |
class MyModel(Model): | |
class Meta: | |
table_name = 'my_model' |
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
<?php | |
use DateTime; | |
use DrSlump\Protobuf; | |
use google\protobuf\Timestamp; | |
class PhpArrayModernCodec extends \DrSlump\Protobuf\Codec\PhpArray { | |
protected function encodeMessage(Protobuf\Message $message) | |
{ | |
if ($message instanceof Timestamp) { |
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 contextlib import contextmanager | |
from functools import wraps | |
from socket import socket as socket_type, MSG_PEEK | |
from typing import Set | |
import flask | |
import gevent | |
def _abort_on_eof_watchdog(socket: socket_type, greenlets: Set[gevent.Greenlet]) -> bool: |
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
""" | |
Implements a behavior similar to: | |
- Go srv's cancelation of context on downstream disconnect | |
- PHP (unless `ignore_user_abort` is true) | |
""" | |
import gevent.monkey | |
gevent.monkey.patch_all() | |
from contextlib import contextmanager | |
from flask import Flask |
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 mongoengine import Document, StringField, ListField, EmbeddedDocument, EmbeddedDocumentField | |
# ******** before remodel: ********** | |
class FailedChargeAttempt_Old(EmbeddedDocument): | |
id = StringField() | |
failed_reason = StringField() | |
NewerOlder