+1
- 001
- 002
- 003
- 004
- 005
- 006
- 007
- 008
- 009
- 010
- 011
- 012
- 013
- 014
- 015
- 016
- 017
- 018
- 019
- 020
- 021
- 022
- 023
- 024
- 025
- 026
- 027
- 028
- 029
- 030
- 031
- 032
- 033
- 034
- 035
- 036
- 037
- 038
- 039
- 040
- 041
- 042
- 043
- 044
- 045
- 046
- 047
- 048
- 049
- 050
- 051
- 052
- 053
- 054
- 055
- 056
- 057
- 058
- 059
- 060
- 061
- 062
- 063
- 064
- 065
- 066
- 067
- 068
- 069
- 070
- 071
- 072
- 073
- 074
- 075
- 076
- 077
- 078
- 079
- 080
- 081
- 082
- 083
- 084
- 085
- 086
- 087
- 088
- 089
- 090
- 091
- 092
- 093
- 094
- 095
- 096
- 097
- 098
- 099
- 100
SELECT
`1000, 1000000 field`
(SELECT group_concat(band_category_languages.name SEPARATOR ', ')
FROM calendar_entry_categories
LEFT JOIN band_category_languages ON band_category_languages.band_category_id = calendar_entry_categories.band_category_id
WHERE calendar_entry_categories.calendar_entry_id = calendar_entries.id
AND band_category_languages.language_id = 1
GROUP BY calendar_entry_categories.calendar_entry_id) AS band_category_string,
(SELECT entry.id
FROM calendar_entries AS entry
WHERE entry.entry_kind_parent_id = calendar_entries.id
AND entry.profile_type_id = 10869
AND entry.profile_type = 1) AS move_to_personal_calendar,
(SELECT count(moved_entry.id)
FROM calendar_entries AS moved_entry
WHERE moved_entry.entry_kind_parent_id = calendar_entries.id
AND moved_entry.status = 3) AS count_moved,
(SELECT user_images.image
FROM calendar_entries AS calendar_entries1
LEFT JOIN user_images ON user_images.id = calendar_entries1.image
WHERE calendar_entries1.id = calendar_entries.entry_kind_parent_id
AND calendar_entries.entry_kind = 4) AS festival_image,
(SELECT countries1.code
FROM calendar_entries AS calendar_entries1
LEFT JOIN locations AS locations1 ON locations1.id = calendar_entries1.location_id
LEFT JOIN countries AS countries1 ON countries1.id = locations1.country_id
WHERE calendar_entries1.id = calendar_entries.entry_kind_parent_id
AND calendar_entries.entry_kind = 4) AS festival_country_code,
(SELECT count(*)
FROM calendar_entry_likes
WHERE calendar_entry_likes.calendar_entry_id = calendar_entries.id) AS count_of_likes,
(SELECT count(*)
FROM calendar_entry_likes
WHERE calendar_entry_likes.calendar_entry_id = calendar_entries.id
AND calendar_entry_likes.user_id = 10869 ) AS is_like,
(SELECT group_concat(entry_type_languages.name SEPARATOR ', ')
FROM calendar_entry_types
LEFT JOIN entry_type_languages ON entry_type_languages.entry_type_id = calendar_entry_types.entry_type_id
WHERE (calendar_entry_types.calendar_entry_id = calendar_entries.id
OR calendar_entry_types.calendar_entry_id = calendar_entries.entry_kind_parent_id)
AND entry_type_languages.language_id = 1
GROUP BY calendar_entry_types.calendar_entry_id) AS entry_types_string,
(SELECT band_addresses.city_name
FROM band_addresses
WHERE band_addresses.band_id = calendar_entries.profile_type_id) AS band_city_name,
(SELECT countries.code
FROM band_addresses
LEFT JOIN countries ON countries.id = band_addresses.country_id
WHERE band_addresses.band_id = calendar_entries.profile_type_id) AS band_country_code,
(SELECT group_concat(genre_languages.name SEPARATOR ', ')
FROM calendar_entry_genres
LEFT JOIN genre_languages ON genre_languages.genre_id = calendar_entry_genres.genre_id
WHERE calendar_entry_genres.calendar_entry_id = calendar_entries.id
AND genre_languages.language_id = 1
GROUP BY calendar_entry_genres.calendar_entry_id) AS genre_string
FROM `calendar_entries`
LEFT JOIN `locations` ON `locations`.`id` = `calendar_entries`.`location_id`
LEFT JOIN `calendar_entries` AS `festival` ON `festival`.`id` = `calendar_entries`.`entry_kind_parent_id`
LEFT JOIN `locations` AS `festival_location` ON `festival_location`.`id` = (
SELECT calendar_entries1.id
FROM calendar_entries AS calendar_entries1
WHERE calendar_entries1.id = calendar_entries.entry_kind_parent_id
AND calendar_entries.entry_kind = 4
)
LEFT JOIN `countries` ON `countries`.`id` = `locations`.`country_id`
LEFT JOIN `country_languages` ON `country_languages`.`country_id` = `locations`.`country_id`
LEFT JOIN `states` ON `states`.`id` = `locations`.`state_id`
LEFT JOIN `bands` ON `bands`.`id` = `calendar_entries`.`profile_type_id`
AND `bands`.`soft_delete` = 0
AND `bands`.`status` = 1
LEFT JOIN `band_images` ON `band_images`.`id` = `calendar_entries`.`image`
LEFT JOIN `band_privacy_settings` ON `band_privacy_settings`.`band_id` = `calendar_entries`.`profile_type_id`
WHERE (`bands`.`soft_delete` = 0 OR `bands`.`soft_delete` IS NULL)
AND (`bands`.`status` = 1 OR `bands`.`status` IS NULL)
AND ((
(SELECT count(*)
FROM band_administrators
WHERE band_administrators.band_id = bands.id
AND band_administrators.user_id = 10869 ) > ? OR `band_privacy_settings`.`band_privacy_level` != ?
) AND (
(SELECT user_type
FROM users
WHERE users.id = 10869 ) = ? OR `band_privacy_settings`.`band_privacy_level` != ?
) AND (
(SELECT count(*)
FROM user_bands
WHERE user_bands.band_id = bands.id
AND user_bands.status = 1
AND user_bands.user_id = 10869 ) > ? OR `band_privacy_settings`.`band_privacy_level` != ?
) OR `band_privacy_settings`.`band_privacy_level` IS NULL
) AND (`festival`.`entry_kind` = ? OR `festival`.`id` IS NULL)
AND (date(`calendar_entries`.`date_from`) >= ?)
AND `calendar_entries`.`soft_delete` = ?
AND (`country_languages`.`language_id` = ? OR `country_languages`.`language_id` IS NULL)
AND `calendar_entries`.`entry_kind` IN (?, ?)
AND `calendar_entries`.`event_class` IN (?, ?)
AND `calendar_entries`.`status` = ?
GROUP BY `1000, 1000000 field`
ORDER BY calendar_entries.date_from
LIMIT 1000, 20
Сидить замовник такий не тужить тай думку гадає, а що це я буду платити півтори куска спеціалусту за роботу, як є "профі" за 500 доларів, а тут ше і Вася програміст каже, а шо це ти будеш платити таку суму, як я зроблю дешевше за 300! Настрій хороший, угода укладена, робота кипить. Проходить не так багато часу, як замовник каже, а що це сторінка 2хв грузиться, а Вася каже, то нічо ми то все оптимізуємо! Проходить ще декілька місяців, а результату нема. Тоді замовнек розуміє, що Вася не профі і шукає профі в Х рази дорощого! Не так багато часу пройшло, як профі за 1000 каже, я в два рази оптимізував, більше не реально! Замовник пригнічений, шукає профі, і в один прекрасний момент знаходиться дійсно профі, який по домовленості в зарплату X оптимізував, повикидував, переписав, дописав і в результаті 50 мс при 500000 записів. Підсумок: 300 + 1000 + X != 300 :)
silverreve23,
12 Августа 2020
+1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
$data = [];
$firstGenreId = Genre::where('homepage_filter_band', 1)->first()->id;
$bandSearch = [
'limit' => request('limit') ?? 6,
'genre' => $firstGenreId,
'category' => BandCategory::where('homepage_filter', 1)->first()->id,
'status' => 1
];
$subGenres = Genre::getGenresByCategory($bandSearch['genre']);
$bandSearch['genre'] = [$bandSearch['genre']];
foreach ($subGenres as $subGenre){
array_push($bandSearch['genre'], $subGenre->id);
}
$data['bandsGenre']['bands'] = Band::getBandsLimitListByGenre($bandSearch);
$data['bandsGenre']['filters'] = Genre::isExistGenreByBandFilter();
$data['bandsGenre']['active_filter'] = $firstGenreId;
$data['bandsGenre']['type'] = 'genre';
$data['bandsCategories']['bands'] = Band::getBandsLimitListByCategory($bandSearch);
$data['bandsCategories']['filters'] = BandCategory::isExistCategoryByBandFilter();
$data['bandsCategories']['active_filter'] = $bandSearch['category'];
$data['bandsCategories']['type'] = 'category';
$data['bandsStatus']['bands'] = Band::getBandsLimitListByStatus($bandSearch);
$data['bandsStatus']['active_filter'] = 1;
$data['bandsStatus']['filters'] = (object)[
0 => [
'id' => 1,
'name' => trans('validation-custom.newest')
],
1 => [
'id' => 2,
'name' => trans('validation-custom.lastUpdated')
]
];
$data['bandsStatus']['type'] = 'status';
$firstGenreId = Genre::where('homepage_filter_musician', 1)->first()->id;
$firstInstrumentId = Instrument::where('homepage_filter', 1)->first()->id;
$musicianSearch = [
'limit' => request('limit') ?? 6,
'genre' => $firstGenreId,
'instrument' => $firstInstrumentId,
'status' => 1
];
$subGenres = Genre::getGenresByCategory($musicianSearch['genre']);
$musicianSearch['genre'] = [$musicianSearch['genre']];
foreach ($subGenres as $subGenre){
array_push($musicianSearch['genre'], $subGenre->id);
}
$subInstruments = Instrument::getInstrumentsByCategory($musicianSearch['instrument']);
$musicianSearch['instrument'] = [$musicianSearch['instrument']];
foreach ($subInstruments as $subInstrument){
array_push($musicianSearch['instrument'], $subInstrument->id);
}
$data['musiciansGenre']['musicians'] = User::getMusiciansLimitListByGenre($musicianSearch);
$data['musiciansGenre']['filters'] = Genre::isExistGenreByFilter();
$data['musiciansGenre']['active_filter'] = $firstGenreId;
$data['musiciansGenre']['type'] = 'genre';
$data['musiciansInstrument']['musicians'] = User::getMusiciansLimitListByInstrument($musicianSearch);
$data['musiciansInstrument']['filters'] = Instrument::isExistInstrumentByFilter();
$data['musiciansInstrument']['active_filter'] = $firstInstrumentId;
$data['musiciansInstrument']['type'] = 'instrument';
$data['musiciansStatus']['musicians'] = User::getMusiciansLimitListByStatus($musicianSearch);
$data['musiciansStatus']['active_filter'] = 1;
$data['musiciansStatus']['filters'] = (object)[
0 => [
'id' => 1,
'name' => trans('validation-custom.newest')
],
1 => [
'id' => 2,
'name' => trans('validation-custom.lastUpdated')
]
];
$data['musiciansStatus']['type'] = 'status';
return response()->json($data, 200);
Кажуть - шота сторінка довго грузиться :)
silverreve23,
07 Августа 2020
+1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
class MyEvents extends \Event\EventsHandler {
static $key = 1;
public function BeforeQuery() {
Timer::start(self::$key);
}
public function AfterQuery() {
Timer::step(self::$key++);
if(Timer::$last['different'] > 1) {
$debug_backtrace = debug_backtrace();
foreach($debug_backtrace as $k=>$v) {
if($v['function'] == 'q') {
$error = "QUERY: ".$v['args'][0]."\n".
"file: ".$v['file']."\n".
"line: ".$v['line']."\n".
"date: ".date("Y-m-d H:i:s")."\n".
"===================================";
file_put_contents('./logs/slowquery.log',$error."\r\n",FILE_APPEND);
break;
}
}
}
}
public function ShutDownSystem() {
echo microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"];
}
}
Event::setEventHandler('MyEvents');
q("SELECT * FROM `table` ORDER BY RAND()");
q("SELECT NOW()");
echo Timer::result();
Измеряем время запросов и время загрузки страницы
https://school-php.com/tricks/23/dokumentatsiya-po-fw
6a6yuH,
07 Августа 2020
+1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
while (true) {
if ($current === $requested) {
break;
}
if (! in_array($requested, $available)) {
break;
}
session()->put('locale', $requested);
break;
}
Edd,
05 Августа 2020
+1
#26: https://govnokod.ru/26050 https://govnokod.xyz/_26050
#27: https://govnokod.ru/26340 https://govnokod.xyz/_26340
#28: https://govnokod.ru/26372 https://govnokod.xyz/_26372
#29: https://govnokod.ru/26385 https://govnokod.xyz/_26385
#30: https://govnokod.ru/26413 https://govnokod.xyz/_26413
#31: https://govnokod.ru/26423 https://govnokod.xyz/_26423
#32: https://govnokod.ru/26440 https://govnokod.xyz/_26440
#33: https://govnokod.ru/26449 https://govnokod.xyz/_26449
#34: https://govnokod.ru/26456 https://govnokod.xyz/_26456
#35: https://govnokod.ru/26463 https://govnokod.xyz/_26463
#36: https://govnokod.ru/26508 https://govnokod.xyz/_26508
#37: https://govnokod.ru/26524 https://govnokod.xyz/_26524
#38: https://govnokod.ru/26539 https://govnokod.xyz/_26539
#39: https://govnokod.ru/26556 https://govnokod.xyz/_26556
#40: https://govnokod.ru/26568 https://govnokod.xyz/_26568
#41: https://govnokod.ru/26589 https://govnokod.xyz/_26589
#42: https://govnokod.ru/26600 https://govnokod.xyz/_26600
#43: https://govnokod.ru/26604 https://govnokod.xyz/_26604
#44: https://govnokod.ru/26627 https://govnokod.xyz/_26627
#45: https://govnokod.ru/26635 https://govnokod.xyz/_26635
#46: (vanished) https://govnokod.xyz/_26646
#46: (vanished) https://govnokod.xyz/_26654
#47: https://govnokod.ru/26671 https://govnokod.xyz/_26671
#48: https://govnokod.ru/26707 https://govnokod.xyz/_26707
#49: https://govnokod.ru/26750 https://govnokod.xyz/_26750
#49: https://govnokod.ru/26776 https://govnokod.xyz/_26776
#50: https://govnokod.ru/26804 https://govnokod.xyz/_26804
#51: https://govnokod.ru/26809 https://govnokod.xyz/_26809
#52: https://govnokod.ru/26817 https://govnokod.xyz/_26817
#53: https://govnokod.ru/26833 https://govnokod.xyz/_26833
nepeKamHblu_nemyx,
03 Августа 2020
+1
#1: https://govnokod.ru/26503 https://govnokod.xyz/_26503
#2: https://govnokod.ru/26541 https://govnokod.xyz/_26541
#3: https://govnokod.ru/26583 https://govnokod.xyz/_26583
#4: https://govnokod.ru/26689 https://govnokod.xyz/_26689
nepeKamHblu_nemyx,
03 Августа 2020
+1
- 1
Бесконечный оффтоп имени Борманда #4
#1: https://govnokod.ru/25864 https://govnokod.xyz/_25864
#2: https://govnokod.ru/25921 https://govnokod.xyz/_25921
#3: https://govnokod.ru/26544 https://govnokod.xyz/_26544
nepeKamHblu_nemyx,
03 Августа 2020
+1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
from numba import jit
def mults_no_jit(start, end, step):
min_i = min(start, end)
for i in range(start, end, step):
if i < min_i:
return
for j in range(i, end, step):
x = i * j
x_orig = x
x_reverse = 0
while x > 0:
x_reverse *= 10
x_reverse += x % 10
x //= 10
if x_orig == x_reverse:
min_i = max(min_i, j)
yield x_orig
break
@jit(nopython=True)
def mults_jit(start, end, step):
min_i = min(start, end)
for i in range(start, end, step):
if i < min_i:
return
for j in range(i, end, step):
x = i * j
x_orig = x
x_reverse = 0
while x > 0:
x_reverse *= 10
x_reverse += x % 10
x //= 10
if x_orig == x_reverse:
min_i = max(min_i, j)
yield x_orig
break
print(timeit.timeit('max(mults_no_jit(999, 99, -1))', globals=globals(), number=100))
# 4.2907474 секунды
print(timeit.timeit('max(mults_jit(999, 99, -1))', globals=globals(), number=100))
# 0.1662201 секунд первый запуск, 0.0333973 последующие
Теперь я за «Numba».
gost,
02 Августа 2020
+1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
package com.company;
public class Main {
public static void main(String[] args) {
int answer = 0;
for (int i = 100; i < 1000; i++){
for (int j = 100; j < 1000; j++){
int result = i * j;
String str = String.valueOf(result); //convert
String revers = new StringBuffer(str).reverse().toString(); //revers
int newb = Integer.parseInt(revers); //convert
if (newb == result){
int answer001 = result;
if (answer001 > answer) answer = answer001;
}
}
}
System.out.println(answer);
}
}
реализация четвёртой задачки из проекта эйлера
warzon131,
01 Августа 2020
+1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
Запрос = Новый Запрос;
Запрос.Текст = "ВЫБРАТЬ
| БИТ_Отель_ДоговорыЭквайринга.Ссылка
|ИЗ
| Справочник.БИТ_Отель_ДоговорыЭквайринга КАК БИТ_Отель_ДоговорыЭквайринга
|ГДЕ
| БИТ_Отель_ДоговорыЭквайринга.ДоговорВзаиморасчетов = &ДоговорВзаиморасчетов";
Запрос.УстановитьПараметр("ДоговорВзаиморасчетов", СтруктураПарам.БИТ_Отель_ДоговорЭквайринга.ДоговорВзаиморасчетов);
Результат = Запрос.Выполнить().Выгрузить();
Струк = Новый Структура;
Струк.Вставить("ВидОплаты", ВидОплаты);
Если Результат.Количество() Тогда
РезОтбора = Результат[0].Ссылка.ТарифыЗаРасчетноеОбслуживание.НайтиСтроки(Струк);
Если РезОтбора.Количество() Тогда
ПроцентТорговойУступки = РезОтбора[0].ПроцентТорговойУступки;
Иначе
ПроцентТорговойУступки = 0;
Предупреждение("Не указан процент торговой уступки!");
ЭлементыФормы.ПанельДокумента.ТекущаяСтраница = ЭлементыФормы.ПанельДокумента.Страницы.Эквайринг;
ЭлементыФормы.ПроцентТорговойУступки.ОтметкаНезаполненного = Истина;
ЭлементыФормы.СуммаТорговойУступки.ОтметкаНезаполненного = Истина;
ТекущийЭлемент = ЭлементыФормы.ПроцентТорговойУступки;
КонецЕсли;
Иначе
ПроцентТорговойУступки = 0;
Предупреждение("Не указан процент торговой уступки!");
ЭлементыФормы.ПанельДокумента.ТекущаяСтраница = ЭлементыФормы.ПанельДокумента.Страницы.Эквайринг;
ЭлементыФормы.ПроцентТорговойУступки.ОтметкаНезаполненного = Истина;
ЭлементыФормы.СуммаТорговойУступки.ОтметкаНезаполненного = Истина;
ТекущийЭлемент = ЭлементыФормы.ПроцентТорговойУступки;
КонецЕсли;
уже шестой год я работаю с этой "конфой", жаль что ее целиком нельзя сюда выложить, там, не считая исходной бух части, сплошной креатив каких то ДЦП на обеденной перемене классе во втором.
jah,
31 Июля 2020