- 1
- 2
- 3
Почитываю иногда комменты на govnokod.ru
Сложилось впечатление, что Stertor, bormand, kegdan, inkanus-gray, 1024--, и многие другие - один и тот же человек
так ли это?
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+119
Почитываю иногда комменты на govnokod.ru
Сложилось впечатление, что Stertor, bormand, kegdan, inkanus-gray, 1024--, и многие другие - один и тот же человек
так ли это?
+1
using System;
namespace Test
{
public class HttpException : Exception
{
public HttpException(int status)
{
StatusCode = status;
}
public int StatusCode { get; set; }
}
class Program
{
static void TestCatch(int status)
{
try
{
throw new HttpException(status);
}
catch (HttpException ex) when (ex.StatusCode == 404)
{
Console.WriteLine("Not Found!");
}
catch (HttpException ex) when (ex.StatusCode >= 500 && ex.StatusCode < 600)
{
Console.WriteLine("Server Error");
}
catch (HttpException ex)
{
Console.WriteLine("HTTP Error {0}", ex.StatusCode);
}
}
static void Main(string[] args)
{
TestCatch(404);
TestCatch(501);
TestCatch(101);
}
}
}
https://ideone.com/zXstg3
Именно поэтому я за «C#».
+143
private void bSaveLog_Click(object sender, EventArgs e)
{
String x = Game.choosen().name;
String y = "Data\\" + x + ".txt";
FileInfo file = new FileInfo(y);
DirectoryInfo di = Directory.CreateDirectory("Data\\");
if (file.Exists == false)
{
file.Create();
using (StreamWriter sw = file.AppendText())
{
sw.WriteLine("Hello");
sw.WriteLine("And");
sw.WriteLine("Welcome");
sw.Flush();
sw.Close();
}
}
}
Помогите советом мудрым, почему при записи в файл выдаёт "Процесс не может получить доступ к файлу..."? Как сделать правильно?
+155
var htmlContent = "<li class='savedAdItem' data-savedid='" +
adToAdd.cid + "' title='" +
Company.i18n("ads_manager.ClickToSeeDestination") +
(adToAdd.get("title") ? adToAdd.get("title") :
adToAdd.get("url")) +
"' data-url='" + adToAdd.get("url") +
"' ><div class='title landing'>" +
(adToAdd.get("title") ? adToAdd.get("title") : "URL") +
"</div><div class='landingUrl hide'>" +
this.getDomainName(adToAdd.get("url")) + "</div>" +
(adToAdd.get("imageUrl") ?
"<div style='text-align:center;'><img src='" +
adToAdd.get("imageUrl") +
"' style='max-width: 99px;max-height: 72px;' /></div>" :
"<div class='img-target-" + adToAdd.get("targetType") +
"'> </div>") +
"<div class='btnDelete' title='" +
Company.i18n("ads_manager.Remove") +
"'></div></li>";
Ах как хочется найти автора этих строк...
0
Game::Game()
{
run = true;//флаг признак нажатия кнопки выхода F5
Matrix = new int* [8];//Поле 64 ячейки - значения 0 - для пустой ячейки, для игрока каждая пешка-шашка от 1 до 9, для компьютера значения в матрице от 10 до 18
for (int i = 0; i < 8; i++)
Matrix[i] = new int[8];
//Квадраты координат нужны чтобы программа знала какие ячейки над указателем мыши, 64 квадрата
QuadCoorXleft = new int* [8];//каждой ячейки матрицы Matrix соответстует квадрат координат для мыши xleft означает левую координату x
QuadCoorXright = new int* [8];//xright - правая x
QuadCoorYdown = new int* [8];//верхняя y координата
QuadCoorYup = new int* [8];//нижняя y координата
for (int i = 0; i < 8; i++)
{
QuadCoorXleft[i] = new int[8];
QuadCoorXright[i] = new int[8];
QuadCoorYdown[i] = new int[8];
QuadCoorYup[i] = new int[8];
}
//Координаты пешек для отрисовки
ChessX = new double[18];//X
ChessY = new double[18];//Y
//Выделяемая пешка ее координаты и значения
ActiveX = -1;//X
ActiveY = -1;//Y
Active = -1;//Value
firstplayer = true;//флаг того что можете игрок 1й ходить
secondplayer = false;//флаг того что можете игрок 2й ходить
ai = new bool[18];//ячейки флаги того что пешка на финишной позиции
chessai tmp;
for (int i = 0; i < 18; i++)
{
ai[i] = false;
if (i > 8)
{
tmp.ai = ai[i];
tmp.value = i+1;
Ai.push_back(tmp);//Вектор с флагами финиша каждой пешки для искуственного интеллекта
}
}
aicountfirstrow = 0;//счетчик кол-ва пешек ИИ(искуственного интеллекта) на верхней строчке(0-я)
aicountsecondrow = 0;//счетчик кол-ва пешек ИИ на предверхней строчке(1-я)
aicountthirdrow = 0;//счетчик кол-ва пешек ИИ на предпредверхней строчке(2-я)
}
https://github.com/Beginerok/DominiGames/blob/master/Domini/Chess/Chess/Game.cpp
https://habr.com/ru/post/563398/
Странные шахматы как тестовое задание
+1
############
$msg = str_replace('<?','',$msg);
$msg = str_replace('?>','',$msg);
$msg = str_replace('^','',$msg);
$msg = str_replace(';','',$msg);
$msg = str_replace('<a>','',$msg);
$msg = str_replace('</a>','',$msg);
$msg = str_replace('<A>','',$msg);
$msg = str_replace('</A>','',$msg);
$msg = str_replace('<br>','',$msg);
$msg = str_replace('</br>','',$msg);
$msg = str_replace('</BR>','',$msg);
$msg = str_replace('<BR>','',$msg);
$msg = str_replace('<p','',$msg);
$msg = str_replace('align','',$msg);
$msg = str_replace('http://','',$msg);
$msg = str_replace('wap','',$msg);
$msg = str_replace('WAP','',$msg);
$msg = str_replace('ru','',$msg);
$msg = str_replace('RU','',$msg);
$msg = str_replace('com','',$msg);
$msg = str_replace('COM','',$msg);
$msg = str_replace('h2m','',$msg);
$msg = str_replace('H2M','',$msg);
$msg = str_replace('WEN','',$msg);
$msg = str_replace('wen','',$msg);
$msg = str_replace('гu','',$msg);
$script = "waphak.ru";
$msg = str_replace('ГU','',$msg);
$msg = str_replace('HTTP://','',$msg);
$msg = str_replace('exit;','',$msg);
$msg = str_replace('EXIT();','',$msg);
$msg = str_replace('exit();','',$msg);
$msg = str_replace('()','',$msg);
$msg = str_replace('<java','',$msg);
$msg = str_replace('<JAVA','',$msg);
$msg = str_replace('</java','',$msg);
$msg = str_replace('</JAVA','',$msg);
$msg = str_replace('javascript','',$msg);
$msg = str_replace('JAVASCRIPT','',$msg);
$msg = str_replace('</','',$msg);
$msg = str_replace('</SCRIPT','',$msg);
$msg = str_replace('</script','',$msg);
$msg = str_replace('alert','',$msg);
$msg = str_replace('\r','',$msg);
$msg = str_replace('\n','',$msg);
########################
Регулярные выражения? Не слышали!
0
Политота #36
#6: (vanished) https://govnokod.xyz/_26648
#7: https://govnokod.ru/26673 https://govnokod.xyz/_26673
#8: https://govnokod.ru/27052 https://govnokod.xyz/_27052
#9: (vanished) https://govnokod.xyz/_27852
#10: https://govnokod.ru/28060 https://govnokod.xyz/_28060
#11: https://govnokod.ru/28091 https://govnokod.xyz/_28091
#12: https://govnokod.ru/28103 https://govnokod.xyz/_28103
#13: https://govnokod.ru/28144 https://govnokod.xyz/_28144
#14: https://govnokod.ru/28270 https://govnokod.xyz/_28270
#15: https://govnokod.ru/28341 https://govnokod.xyz/_28341
#16: https://govnokod.ru/28379 https://govnokod.xyz/_28379
#17: https://govnokod.ru/28394 https://govnokod.xyz/_28394
#18: https://govnokod.ru/28440 https://govnokod.xyz/_28440
#19: https://govnokod.ru/28572 https://govnokod.xyz/_28572
#20: https://govnokod.ru/28656 https://govnokod.xyz/_28656
#21: (vanished) https://govnokod.xyz/_28666
#22: https://govnokod.ru/28676 https://govnokod.xyz/_28676
#23: https://govnokod.ru/28684 https://govnokod.xyz/_28684
#24: https://govnokod.ru/28691 https://govnokod.xyz/_28691
#25: https://govnokod.ru/28698 https://govnokod.xyz/_28698
#26: https://govnokod.ru/28704 https://govnokod.xyz/_28704
#27: https://govnokod.ru/28711 https://govnokod.xyz/_28711
#28: https://govnokod.ru/28721 https://govnokod.xyz/_28721
#29: https://govnokod.ru/28728 https://govnokod.xyz/_28728
#30: (vanished) https://govnokod.xyz/_28747
#31: https://govnokod.ru/28757 https://govnokod.xyz/_28757
#32: https://govnokod.ru/28770 https://govnokod.xyz/_28770
#33: https://govnokod.ru/28835 https://govnokod.xyz/_28835
#34: https://govnokod.ru/28924 https://govnokod.xyz/_28924
#35: https://govnokod.ru/29080 https://govnokod.xyz/_29080
−1
function getPointFactory() {
class P {
x = 0;
y = 0;
}
return new P();
}
function main() {
const PointZero = getPointFactory();
print("done.");
}
все шах и мат вам... с/c++
0
// https://www.opennet.ru/opennews/art.shtml?num=51508
// Microsoft открыл код стандартной библиотеки С++, поставляемой в Visual Studio
// https://github.com/microsoft/STL/blob/7f65140761947af4ed7f9dfc11adee8c86c9e4c2/stl/inc/unordered_map#L712
#if _HAS_CXX17
template <class _Iter, class _Hasher = hash<_Guide_key_t<_Iter>>, class _Keyeq = equal_to<_Guide_key_t<_Iter>>,
class _Alloc = allocator<_Guide_pair_t<_Iter>>,
enable_if_t<
conjunction_v<_Is_iterator<_Iter>, _Is_hasher<_Hasher>, negation<_Is_allocator<_Keyeq>>, _Is_allocator<_Alloc>>,
int> = 0>
unordered_map(_Iter, _Iter, _Guide_size_type_t<_Alloc> = 0, _Hasher = _Hasher(), _Keyeq = _Keyeq(), _Alloc = _Alloc())
->unordered_map<_Guide_key_t<_Iter>, _Guide_val_t<_Iter>, _Hasher, _Keyeq, _Alloc>;
template <class _Kty, class _Ty, class _Hasher = hash<_Kty>, class _Keyeq = equal_to<_Kty>,
class _Alloc = allocator<pair<const _Kty, _Ty>>,
enable_if_t<conjunction_v<_Is_hasher<_Hasher>, negation<_Is_allocator<_Keyeq>>, _Is_allocator<_Alloc>>, int> = 0>
unordered_map(initializer_list<pair<_Kty, _Ty>>, _Guide_size_type_t<_Alloc> = 0, _Hasher = _Hasher(), _Keyeq = _Keyeq(),
_Alloc = _Alloc())
->unordered_map<_Kty, _Ty, _Hasher, _Keyeq, _Alloc>;
template <class _Iter, class _Alloc, enable_if_t<conjunction_v<_Is_iterator<_Iter>, _Is_allocator<_Alloc>>, int> = 0>
unordered_map(_Iter, _Iter, _Alloc)
->unordered_map<_Guide_key_t<_Iter>, _Guide_val_t<_Iter>, hash<_Guide_key_t<_Iter>>, equal_to<_Guide_key_t<_Iter>>,
_Alloc>;
template <class _Iter, class _Alloc, enable_if_t<conjunction_v<_Is_iterator<_Iter>, _Is_allocator<_Alloc>>, int> = 0>
unordered_map(_Iter, _Iter, _Guide_size_type_t<_Alloc>, _Alloc)
->unordered_map<_Guide_key_t<_Iter>, _Guide_val_t<_Iter>, hash<_Guide_key_t<_Iter>>, equal_to<_Guide_key_t<_Iter>>,
_Alloc>;
template <class _Iter, class _Hasher, class _Alloc,
enable_if_t<conjunction_v<_Is_iterator<_Iter>, _Is_hasher<_Hasher>, _Is_allocator<_Alloc>>, int> = 0>
unordered_map(_Iter, _Iter, _Guide_size_type_t<_Alloc>, _Hasher, _Alloc)
->unordered_map<_Guide_key_t<_Iter>, _Guide_val_t<_Iter>, _Hasher, equal_to<_Guide_key_t<_Iter>>, _Alloc>;
template <class _Kty, class _Ty, class _Alloc, enable_if_t<_Is_allocator<_Alloc>::value, int> = 0>
unordered_map(initializer_list<pair<_Kty, _Ty>>, _Alloc)->unordered_map<_Kty, _Ty, hash<_Kty>, equal_to<_Kty>, _Alloc>;
template <class _Kty, class _Ty, class _Alloc, enable_if_t<_Is_allocator<_Alloc>::value, int> = 0>
unordered_map(initializer_list<pair<_Kty, _Ty>>, _Guide_size_type_t<_Alloc>, _Alloc)
->unordered_map<_Kty, _Ty, hash<_Kty>, equal_to<_Kty>, _Alloc>;
template <class _Kty, class _Ty, class _Hasher, class _Alloc,
enable_if_t<conjunction_v<_Is_hasher<_Hasher>, _Is_allocator<_Alloc>>, int> = 0>
unordered_map(initializer_list<pair<_Kty, _Ty>>, _Guide_size_type_t<_Alloc>, _Hasher, _Alloc)
->unordered_map<_Kty, _Ty, _Hasher, equal_to<_Kty>, _Alloc>;
#endif // _HAS_CXX17
Ну и хуйня! Впрочем, разве могло быть иначе?
+1
Что-то я давно не обсирал тут хуиту, которую пишут про
плюсы на хабре
https://habr.com/post/426965/
Идеального способа для обработки ошибок не существует.
До недавнего времени в С++ были почти все возможные
способы обработки ошибок кроме монад.
В этой замечательной статье забыли упомянуть setjmp/longjmp(std::longjmp если угодно), который хоть и из Си, но в C++ его никто не запрещал.
А еще signal (std::signal, если угодно), который хоть и из Си, но в C++ его никто не запрещал.
А еще goto (почему нет std::goto? Запилите быстраблядь!), который хоть и из Си, но в C++ его никто не запрещал.
А вообще, зачем иметь в языке такое количество говна в СТАНДАРТНОЙ БИБЛИОТЕКЕ для такой хуиты?
Вот еще в тему: https://video.twimg.com/tweet_video/De78Qn2XcAAQqfS.mp4