Skip to content

Instantly share code, notes, and snippets.

SELECT route.id, route.title, route.created_at FROM route
SELECT routes_points_m2m.route_id AS routes_points_m2m_route_id, routes_points_m2m.point_id AS routes_points_m2m_point_id, routes_points_m2m.start AS routes_points_m2m_start, routes_points_m2m."end" AS routes_points_m2m_end, routes_points_m2m."order" AS routes_points_m2m_order, anon_1.route_id AS anon_1_route_id FROM (SELECT route.id AS route_id FROM route) AS anon_1 JOIN routes_points_m2m ON anon_1.route_id = routes_points_m2m.route_id ORDER BY routes_points_m2m."order" ASC
-- Этот подзапрос не отдает поля "ST_X(point.coordinates) AS lat" и "ST_Y(point.coordinates) AS lon"
SELECT anon_1.id AS anon_1_id, anon_1.title AS anon_1_title, ST_AsEWKB(anon_1.coordinates) AS anon_1_coordinates, anon_1.created_at AS anon_1_created_at
FROM (SELECT point.id AS id, point.title AS title, point.coordinates AS coordinates, point.created_at AS created_at, ST_X(point.coordinates) AS lat, ST_Y(point.coordinates) AS lon, routes_points_m2m.start AS start, routes_points
@Ingco
Ingco / easy_localization_keys_extractor.dart
Last active January 20, 2022 13:12 — forked from spiritinlife/easy_localization_keys_extractor.dart
Extract language keys from your source code and merge them into existing translations.
/// This is inspired by intl_translation extract command https://github.com/dart-lang/intl_translation/blob/8a5e883d7fe07b0244adbaf3489ceb3b08385483/bin/extract_to_arb.dart
/// and is a slimed down rough version of it. Most of the code is from this package which is an excellent learning resource for anyone who wants
/// to play around with the dart analyzer.
/// This is a rough script, to extract localization keys for the easy_localization library. It will analyze the souce
/// code and find occurrences of tr and plural ( you could add other method names e.g. gender etc ) and extract the argument at index $argumentIndex
/// which should be the translation key. It then merges those keys to your current translated keys and spits the merged version where the
/// untranslated keys have a value of "MISSING".
/// Known issues
/// tr( isSomething ? "true_key" : "false_key", context ) -> will get this as key isSomething ? "true_key" : "false_key"
import 'dart:async';
shellScript {
content = """
psql -v ON_ERROR_STOP=1 --username ${'$'}POSTGRES_USER <<-EOF
CREATE EXTENSION IF NOT EXISTS dblink;
DO \$$
BEGIN
IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = ${'$'}DB_USER) THEN
CREATE USER ${'$'}DB_USER PASSWORD ${'$'}DB_PASSWORD;
ALTER USER ${'$'}DB_USER CREATEDB;
END IF;
from django_tenants.test.client import TenantClient
from rest_framework.test import APIClient
class CustomTenantClient(TenantClient):
def __init__(self, enforce_csrf_checks=False, **defaults):
tenant = defaults.pop("tenant")
super().__init__(tenant, enforce_csrf_checks, **defaults)
import os
import pytest
from django.apps import apps
from django.conf import settings
from django.core.management import call_command
from django.db import connection
from django.utils import translation
from django_tenants.test.client import TenantClient
from django_tenants.utils import (
class RecommendationStream {
RecommendationStream() {
...
_notificator.outEvent.listen((event) {
print('ЭТОТ ТЕКСТ ПЕЧАТАЕТ ДВАЖДЫ');
if (event == ProfileScreenEvents.UPDATE_LOCAL) {
send();
} else if (event == ProfileScreenEvents.UPDATE_REMOTE) {
sendNew();
}
extension StringExtension on String {
/// Truncate a string if it's longer than [maxLength] and add an [ellipsis].
String truncate(int maxLength, [String ellipsis = "…"]) => length > maxLength
? '${substring(0, maxLength - ellipsis.length)}$ellipsis'
: this;
}
void main() {
print('lsdkf osfk sifhsoidfj'.truncate(10));
Environment:
Request Method: GET
Request URL: http://iowadent.saas.local:8000/en/panel/
Django Version: 2.2.20
Python Version: 3.8.2
Installed Applications:
['django_tenants',
@Ingco
Ingco / main.dart
Last active April 5, 2021 10:52
Основы Dart 2; Губатенко Артем
/// 1. Capitalize users
List<String> users = ['anna', 'viKtor', 'Mike', 'aleX', 'dan'];
List<String> capitalizeNames(List<String> names) {
return names.map((String name) {
return "${name[0].toUpperCase()}${name.substring(1).toLowerCase()}";
}).toList();
}
/// 2. Searching hero
class DynamicTimeZoneMiddleware:
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
dynamic_settings = gpr.manager()
try:
time_zone_name = dynamic_settings["main_settings__time_zone"]
except KeyError: