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 functools import cached_property | |
class DataProxy: | |
def __init__(self, user): | |
self.user = user | |
@cached_property | |
def plan(self): | |
return DBModel.objects.get(id=67) | |
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 os | |
import re | |
def find_functions(file_path): | |
""" | |
Extracts functions and their line counts from a given Python file. | |
""" | |
with open(file_path, 'r') as file: | |
lines = file.readlines() |
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
SKIP_MODULES = ('django', 'simple_history') | |
ACCESS_FILES = [ | |
'/var/log/nginx/access.log', | |
'/var/log/nginx/access.log.1', | |
'/var/log/nginx/access.log.2', | |
] + ['/var/log/nginx/access.log.{}.gz'.format(i) for i in range(3, 31)] | |
RE_SEARCH_URL = r'(?:(?:POST)|(?:GET)|(?:PATCH)|(?:PUT)|(?:OPTIONS)|(?:DELETE)|(?:HEAD))\s([^\s\?]+)' | |
def SKIP_MATCH(url): | |
return requested_url.startswith('/static/') |
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 ContextDecorator | |
from django.db import connections | |
class overwrite_default_connection(ContextDecorator): | |
prev_default = None | |
write_connection = None | |
def __init__(self, write_connection): | |
self.write_connection = write_connection | |
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 gen import players, crystalite_farm, sentry_gun, command_center, attack_craft | |
PLAYERS = players([ | |
command_center([28, 18], level=2), | |
crystalite_farm([25, 19], level=2), | |
sentry_gun('def_code.py', [27, 23], level=1), | |
attack_craft(1, 'attacker.py', unit_quantity=6) | |
]) |
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 battle import commander | |
# create craft object | |
craft_client = commander.CraftClient() | |
# command to craft - start landing units | |
craft_client.do_land_units() | |
def unit_landed(data): | |
# create unit object | |
unit_client = commander.UnitClient(data['id']) |
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
var commander = require("battle/commander.js"); | |
// create craft object | |
var craftClient = new commander.CraftClient(); | |
// command to craft - start landing units | |
craftClient.doLandUnits(); | |
function unitLanded(data) { | |
// create unit object | |
var unitClient = new commander.UnitClient(data['id']); |
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 numpy as np | |
import json | |
from collections.abc import Iterator, Sequence | |
class CiOJSEncoderEncoder(json.JSONEncoder): | |
def default(self, obj): | |
if isinstance(obj, np.ndarray): | |
return obj.tolist() | |
if isinstance(obj, np.generic): | |
return obj.item() |
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
$ sudo pip3 install checkio-client |
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
sudo pip3 install checkio-client |
NewerOlder