- 1
Вчера в полдень страшно завыла сирена и напугала меня. У вас тоже воют, или только у нас?
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
Вчера в полдень страшно завыла сирена и напугала меня. У вас тоже воют, или только у нас?
Не к добру это. Ох, не к добру.
−1
#include <iostream>
// Truthiness
struct true_type{static const bool value = true;};
struct false_type{ static const bool value = false;};
// Pick type based on bool value
template <bool B, typename T, typename U>struct conditional{typedef T type;};
template <typename T, typename U>struct conditional<false, T, U>{typedef U type;};
// Compare two types
template <typename T, typename U>struct is_same : public false_type{};
template <typename T>struct is_same<T, T> : public true_type{};
// Division predicate
template <int a, int b>struct divides{static const bool value = (a % b == 0);};
// Type traits
template <typename T, int N = 0>
struct fizzbuzz_traits{
typedef T type;
static const int value = N;
};
template <> struct fizzbuzz_traits<char*, 0>{typedef char* type;};
// fizzbuzz type initializers
template <bool A, bool B> struct fizzbuzz{};
template <> struct fizzbuzz<true, false> : public fizzbuzz_traits<char*> {static const char* value;};
typedef fizzbuzz<true, false> fizz_type;
const char* fizz_type::value = "fizz"; // static const char* can only be initialized out of line
template <> struct fizzbuzz<true, true> : public fizzbuzz_traits<char*> {static const char* value;};
typedef fizzbuzz<true, true> fizzbuzz_type;
const char *fizzbuzz_type::value = "fizzbuzz";
template <> struct fizzbuzz<false, true> : public fizzbuzz_traits<char*> {static const char* value;};
typedef fizzbuzz<false, true> buzz_type;
const char *buzz_type::value = "buzz";
template <> struct fizzbuzz<false, false> : fizzbuzz_traits<void>{};
// FizzBuzz solver
template <int N>
class FizzBuzz{
private:
struct is_divisible : public true_type{
struct by3 : public divides<N, 3>{};
struct by5 : public divides<N, 5>{};
};
public:
typedef fizzbuzz< is_divisible::by3::value, is_divisible::by5::value > solution_type;
// stores string or 'false'
typedef fizzbuzz_traits<int, N> non_divisible_type;
// stores number
typedef typename conditional< !is_same<void, typename solution_type::type>::value,
solution_type,
non_divisible_type>::type print_type;
// stores value to print
};
// Looping from N to M
template <int N, int M>
struct static_for{
static void value(){
std::cout << FizzBuzz<N>::print_type::value << std::endl;
static_for<N + 1, M>::value();
}
};
template <>
struct static_for<101, 100>
{
static void value(){};
};
int main(){
static_for<1, 100>::value();
}
Физзбазз на шаблонах без type_traits
0
'''
Main file of bot
Главный фаил бота
'''
from discord.ext import commands
import wotb_api
import settings
import messages as m
from messages_gen import pars
from settings import bot_settings
class App():
'''
Main class of bot
Главный класс бота
'''
def __init__(self):
self.pars = pars()
self.msg = m.msg()
self.api = wotb_api.API()
self.bot = commands.Bot(command_prefix=
bot_settings['command_prefix'])
self.__token__ = settings.bot_settings['TOKEN']
def error_handler(self,data):
'''
Сопостовляем полученную ошибку со словарём
и возвращаем True если данные совпадают
со словарём ошибок.
'''
for i in self.api.error_list:
if data == i:
return True
return False
def main(self):
'''
Здесь описанна логика бота, и его взаимодействие
с другими модулями
'''
@self.bot.command()
async def stats(ctx):
command = ctx.message.content
command = command.split(' ')
print(f'Запрос: {command}')
if len(command) == 2:
player_data = self.api.get_player_stats(command[1])
if self.error_handler(player_data):
await ctx.send(embed = self.
msg.return_error_emb(player_data))
else:
embed = self.pars.get_data(player_data,
self.api.last_id)
await ctx.send(embed = embed)
elif len(command) == 3:
player_data = self.api.get_player_stats(command[1],
command[2])
if self.error_handler(player_data):
await ctx.send(embed = self.
msg.return_error_emb(player_data))
else:
embed = self.pars.get_data(player_data,
self.api.last_id)
await ctx.send(embed = embed)
elif len(command) > 3:
await ctx.send(embed = self.msg.return_error_emb('CFE'))
else:
await ctx.send(embed = self.msg.return_error_emb('NN'))
@self.bot.command()
async def ver(ctx):
await ctx.send(embed = self.msg.about_embed())
@self.bot.command()
async def server(ctx):
command = ctx.message.content
command = command.split(' ')
if len(command) == 2:
if command[1].lower() == 'all':
s_status = ''
s_status = self.api.get_server_status('all')
if self.error_handler(s_status):
embed = ''
embed = self.msg.return_error_emb(s_status)
await ctx.send(embed = embed)
else:
embed = ''
embed = self.pars.server_status_all(s_status)
await ctx.send(embed = embed)
Как вам код в плане читаемости. Pylint дал мне 9.78/10 балов (это не полный код)
0
private void calculateOverallTime() {
if (overallTimeTimer.isTimeOut()) {
if (overallTime[0] <= 58) {
overallTime[0] += 1;
}
else {
overallTime[0] = 0;
if (overallTime[1] <= 58) {
overallTime[1] += 1;
}
else {
overallTime[1] = 0;
overallTime[2] += 1;
}
}
}
}
0
Хрюкни #23
._ __,
|\,../'\
,'. . `.
.-- '`.
( `' , ;
,`--' _, ,'\
,`.____ `.
/ `, |
' \, '
| / /`,
`, . ,` ./ |
' `. ,' |;,' ,@
______| | _________,_____jv______
`. `. ,'
,'_,','_,
`' `'
#1: (vanished) https://govnokod.xyz/_26863
#2: (vanished) https://govnokod.xyz/_26868
#3: https://govnokod.ru/26881 https://govnokod.xyz/_26881
#4: https://govnokod.ru/26896 https://govnokod.xyz/_26896
#5: https://govnokod.ru/26928 https://govnokod.xyz/_26928
#6: (vanished) https://govnokod.xyz/_26952
#7: https://govnokod.ru/26955 https://govnokod.xyz/_26955
#8: https://govnokod.ru/27043 https://govnokod.xyz/_27043
#9: https://govnokod.ru/27175 https://govnokod.xyz/_27175
#10: https://govnokod.ru/27472 https://govnokod.xyz/_27472
#11: https://govnokod.ru/27517 https://govnokod.xyz/_27517
#12: https://govnokod.ru/27636 https://govnokod.xyz/_27636
#13: (vanished) https://govnokod.xyz/_27711
#14: https://govnokod.ru/27713 https://govnokod.xyz/_27713
#15: https://govnokod.ru/27721 https://govnokod.xyz/_27721
#16: https://govnokod.ru/27722 https://govnokod.xyz/_27722
#17: (vanished) https://govnokod.xyz/_27723
#18: https://govnokod.ru/27724 https://govnokod.xyz/_27724
#19: https://govnokod.ru/27726 https://govnokod.xyz/_27726
#20: https://govnokod.ru/27727 https://govnokod.xyz/_27727
#21: https://govnokod.ru/27870 https://govnokod.xyz/_27870
#22: https://govnokod.ru/28067 https://govnokod.xyz/_28067
−1
учетка miheich была скомпрометирована. подскажите, как поменять пароль?
-
+1
int my_strcmp(const char *out, const char *in ){
for( ;*(in) , *(out) && *(in) == *(out); *out++,*in++ );
return *in <= *out ? *out > *in : -1 ;
}
Бульк
−3
Блять, какое же lua говно блять...
−2
https://youtu.be/3p5VCRZMCBM?t=401
ОБМАНУТЫЙ РОССИЯНИН
−2
https://youtu.be/3p5VCRZMCBM?t=401
[size=20]ОБМАНУТЫЙ РОССИЯНИН[/b]