- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
<HTML>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
</meta>
<BODY>
<style>
<? include "style.css"; ?>
</style>
<?
include "menu.php";
include "main.php";
?>
</BODY>
</HTML>
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+164.6
<HTML>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
</meta>
<BODY>
<style>
<? include "style.css"; ?>
</style>
<?
include "menu.php";
include "main.php";
?>
</BODY>
</HTML>
Своеобразный способ подключения стилей)))
Из ЛС вконтакта.
+349.7
define("_WINDOWS_",file_exists("c:\autoexec.bat") ? TRUE : FALSE);
:)
+15.2
BOOL ConvertDays(UINT32 days, SYSTEMTIME* lpTime)
{
int dayofweek, month, year;
UINT8 *month_tab;
//Calculate current day of the week
dayofweek = GetDayOfWeek(days);
year = ORIGINYEAR;
while (days > 365)
{
if (IsLeapYear(year))
{
if (days > 366)
{
days -= 366;
year += 1;
}
}
else
{
days -= 365;
year += 1;
}
}
// Determine whether it is a leap year
month_tab = (UINT8 *)((IsLeapYear(year))? monthtable_leap : monthtable);
for (month=0; month<12; month++)
{
if (days <= month_tab[month])
break;
days -= month_tab[month];
}
month += 1;
lpTime->wDay = days;
lpTime->wDayOfWeek = dayofweek;
lpTime->wMonth = month;
lpTime->wYear = year;
return TRUE;
}
То что вызвало зависание всех MS Zune 30Gb по всему миру.
+1
DDoS
0
// https://github.com/flipperdevices/flipperzero-firmware/blob/2a6a3a1bf7ba1ecb42b8cbfc1b1856a54f2878b7/applications/plugins/music_player/music_player.c#L74
static bool is_white_note(uint8_t semitone, uint8_t id) {
switch(semitone) {
case 0:
if(id == 0) return true;
break;
case 2:
if(id == 1) return true;
break;
case 4:
if(id == 2) return true;
break;
case 5:
if(id == 3) return true;
break;
case 7:
if(id == 4) return true;
break;
case 9:
if(id == 5) return true;
break;
case 11:
if(id == 6) return true;
break;
default:
break;
}
return false;
}
static bool is_black_note(uint8_t semitone, uint8_t id) {
switch(semitone) {
case 1:
if(id == 0) return true;
break;
case 3:
if(id == 1) return true;
break;
case 6:
if(id == 3) return true;
break;
case 8:
if(id == 4) return true;
break;
case 10:
if(id == 5) return true;
break;
default:
break;
}
return false;
}
Хуйня какая-то. То ли дело "паттерн матчинг".
0
def foo(n):
f = True
k = n % 10
while n > k:
n //= 10
if n % 10 != k:
f = False
break
return f
array = [
[22, 14, 8, 14],
[22, 13, 70, 95],
[22, 12, 51, 10], # Для тестирования
[20, 11, 51, 56],
[49, 10, 36, 85]
]
f2 = True
for i in range(len(array[0])):
c = 0
for j in range(len(array)):
if foo(array[j][i]):
c += 1
if c > 3:
f2 = False
break
print("True" if f2 else "False")
0
type User = {
status: 'lamer' | 'junior' | 'govnokoder';
login: string;
iq: number;
}
type ChangeListener<T, K extends keyof T> = {
name: `${K & string}_Listener`;
on(newValue: T[K])
}
const UserIqListener: ChangeListener<User, 'iq'> = {
name: "iq_Listener", //ничто другое не скомпилируется
on(event: number) { //понятно, что string тут не скомпилируется
}
}
const UserStatusListener: ChangeListener<User, 'status'> = {
name: "status_Listener",
on(newValue: User["status"]) {
switch (newValue) {
case "govnokoder": { //понятно, что неверный тип тут не скомпилируется
}
}
}
}
Почему у нас нет "TypeScript"?
+1
<?php
$data = file_get_contents('https://music.yandex.ru/users/[данные удалены]/playlists/[данные удалены]');
$data = json_decode($data);
$tracks = $data->result->tracks;
$track = $tracks[$argv[1]]; // передаём номер песни из плейлиста
/* Step 1 */
$trackId = $track->track->id;
$albumId = $track->track->albums[0]->id;
$time = strval(time()) . '000';
$url1 = 'https://music.yandex.ru/api/v2.1/handlers/track/' . $trackId . '%3A' . $albumId . '/web-user_playlists-playlist-track-saved/download/m?hq=0&external-domain=music.yandex.ru&overembed=no&__t=' . $time;
$options['http']['header'] = "Accept: application/json; q=1.0, text/*; q=0.8, */*; q=0.1\r\n"
. "X-Retpath-Y: https%3A%2F%2Fmusic.yandex.ru%2F\r\n"
. "X-Requested-With: XMLHttpRequest\r\n"
. "User-Agent: Mozilla/5.0 [данные удалены]\r\n"
. "Cookie: [данные удалены]\r\n";
$context = stream_context_create($options);
$data = file_get_contents($url1, false, $context);
$data = json_decode($data);
/* Step 2 */
$time = strval(time()) . '000';
$url2 = 'https:' . $data->src . '&format=json&external-domain=music.yandex.ru&overembed=no&__t=' . $time;
$data = file_get_contents($url2);
$data = json_decode($data);
/* Step 3 */
$salt = 'XGRlBW9FXlekgbPrRHuSiA';
$hash = md5($salt . substr($data->path, 1) . $data->s);
$url3 = 'https://' . $data->host . '/get-mp3/' . $hash . '/' . $data->ts . $data->path;
$name = $track->track->title;
if(isset($track->track->version)) {
$name .= ' (' . $track->track->version . ')';
}
$artists = array();
foreach($track->track->artists as $artist) {
$artists[] = $artist->name;
}
$name = implode(',', $artists) . ' - ' . $name;
$name = strtr($name, ':/\\*?<|>', '________');
$name = str_replace('"', '”', $name);
$name = mb_substr($name, 0, 255-4);
copy($url3, $name . '.mp3');
Найдётся всё.
0
https://journal.tinkoff.ru/diary-quality-manager-moscow-950k/
+5
#include <iostream>
#include <set>
#include <unicode/brkiter.h>
#include <unicode/unistr.h>
#include <unicode/coll.h>
#include <unicode/sortkey.h>
bool hasRepeatingCharacters(const icu::UnicodeString &word)
{
icu::Locale locale = icu::Locale::getDefault();
UErrorCode status = U_ZERO_ERROR;
std::unique_ptr<icu::BreakIterator> it{icu::BreakIterator::createCharacterInstance(locale, status)};
if (U_FAILURE(status)) throw 42;
it->setText(word);
std::unique_ptr<icu::Collator> collator{icu::Collator::createInstance(status)};
if (U_FAILURE(status)) throw 42;
collator->setStrength(icu::Collator::SECONDARY);
auto less = [](const icu::CollationKey &k1, const icu::CollationKey &k2){
UErrorCode status = U_ZERO_ERROR;
bool isLess = k1.compareTo(k2, status) == UCOL_LESS;
if (U_FAILURE(status)) throw 42;
return isLess;
};
std::set<icu::CollationKey, decltype(less)> cache(less);
int32_t p = it->first();
while (p != icu::BreakIterator::DONE) {
int32_t q = it->next();
if (q == icu::BreakIterator::DONE)
break;
icu::CollationKey key;
collator->getCollationKey(word.tempSubStringBetween(p, q), key, status);
if (U_FAILURE(status)) throw 42;
if (cache.find(key) != cache.end())
return true;
cache.insert(key);
p = q;
}
return false;
}
int main()
{
icu::UnicodeString words(u8"Example english Боб мир כוכב 民主主義語こんにちは", "utf-8");
icu::Locale locale = icu::Locale::getDefault();
UErrorCode status = U_ZERO_ERROR;
std::unique_ptr<icu::BreakIterator> it{icu::BreakIterator::createWordInstance(locale, status)};
if (U_FAILURE(status)) throw 42;
it->setText(words);
int32_t p = it->first();
while (p != icu::BreakIterator::DONE) {
int32_t q = it->next();
if (q == icu::BreakIterator::DONE)
break;
if (it->getRuleStatus() != UBRK_WORD_NONE)
{
icu::UnicodeString word{words.tempSubStringBetween(p, q)};
bool hasRepeats = hasRepeatingCharacters(word);
std::string wordUtf8;
word.toUTF8String(wordUtf8);
std::cout << (hasRepeats ? "Has repeats: " : "No repeats: ") << wordUtf8 << std::endl;
}
p = q;
}
return 0;
}
По мотивам https://govnokod.ru/27025
Сформировать строку из слов исходной строки, содержащих повторяющиеся буквы.
В 60 строк, к сожалению, не уложился :(