-
Лучший говнокод
- В номинации:
-
- За время:
-
-
−1
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
Antony Polukhin
in
pro.cxx
Кстати, в EWG одобрили constexpr контейнеры http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0784r1.html
так что есть все шансы к С++20 писать:
constexpr std::string result = foo();
t.me/ProCxx
/184343
Mar 16 at 10:47
Library pragmatism
Current implementations of standard libraries sometimes perform various raw storage operations through interfaces other than the standard allocator and allocator traits. That may make it difficult to make the associated components usable in constexpr components. Based on a cursory examination of current practices, we therefore propose to start only with the requirement that the container templates in the [containers] clause be usable in constexpr evaluation, when instantiated over literal types and the default allocator. In particular, this excludes std::string, std::variant, and various other allocating components. Again, it is our hope we will be able to extend support to more components in the future.
With regards to the default allocator and allocator traits implementation, the majority of the work is envisioned in the constexpr evaluator: It will recognize those specific components and implement their members directly (without necessarily regarding the library definition).
We might, however, consider decorating the class members with the constexpr keyword. Also, some implementations provide extra members in these class templates (such as libc++'s allocator_traits<A>::__construct_forward ) that perform non-constexpr-friendly operations (memcpy, in particular). Lifting such members to standard status would help interoperability between library and compiler implementations.
j123123,
16 Марта 2018
-
0
- 1
- 2
- 3
- 4
bool tokensExistence = !(access_token == null || refresh_token == null || access_token.Value == String.Empty || refresh_token.Value == String.Empty);
if (!tokensExistence && AuthorizedAccess){
//...
}
ichi404,
12 Февраля 2018
-
0
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
public class App extends Application {
public static Context appContext;
@Override
public void onCreate() {
super.onCreate();
appContext = getApplicationContext();
}
}
Нужно больше контекста...
ausichenko,
02 Февраля 2018
-
−1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
function convert_data($data,$fromTo="MQL")
{
if($fromTo=='MQL') {
$P=explode("-",$data);
return $P[2].".".$P[1].".".$P[0];
} else {
$P=explode(".",$data);
return $P[2]."-".$P[1]."-".$P[0];
}
}
Подготавливаем дату для сохранения в базу
SeniorShaurman,
21 Декабря 2017
-
−3
- 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
import java.io.*;
class Cat {
String name;
int age;
int weight;
int length;
void printen(String name, int age, int weight, int length){
String text1 = "Имя кота: " + name + ", " + "Возраст кота: " + age + ", " + "Вес кота: " + weight + ", " + "Длина кота: " + length;
System.out.println(text1);
}
}
class CatTestDrive{
public static void main(String[] args) throws Exception{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
Cat[] cats = new Cat[5];
for (int i = 0; i < cats.length; i++){
cats[i] = new Cat();
System.out.println("Введите имя " + (i+1) + " кота: ");
cats[i].name = reader.readLine();
System.out.println("Введите возраст " + cats[i].name + ": ");
cats[i].age = Integer.parseInt(reader.readLine());
System.out.println("Введите вес " + cats[i].name + ": ");
cats[i].weight = Integer.parseInt(reader.readLine());
System.out.println("Введите длину " + cats[i].name + ": ");
cats[i].length = Integer.parseInt(reader.readLine());
}
for (int i = 0; i < cats.length; i++){
cats[i].printen(cats[i].name, cats[i].age, cats[i].weight, cats[i].length);
}
}
}
Программа создает котов и вводит с клавиатуры их характеристики, затем выводит данные на экран в виде строки.
Как можно улучшить? Критикуйте!
babushkaAntona,
20 Ноября 2017
-
+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
class Yandex{
require_once _DIR_ . '/vendor/autoload.php';
class_alias('\Arhitector\Yandex\Disk', 'Yandex');
// передать OAuth-токен зарегистрированного приложения.
$disk = new Yandex('AQAAAAAeTQ-yAARKyGCP7TY2MU0aggYZ7ucZFwI');
/**
* Получить Объектно Ориентированное представление закрытого ресурса.
* @var Arhitector\Yandex\Disk\Resource\Closed $resource
*/
$resource = $disk->getResource('0000 Техническое задание (2).pdf');
// проверить сущестует такой файл на диске ?
$resource->has(); // вернет, например, false
// загрузить файл на диск под имененм "новый файл.txt".
$resource->upload(__DIR__ . '/0000 Техническое задание (1).pdf');
// файл загружен, вывести информацию.
echo '<pre>';
var_dump($resource->toArray());
}
Нашёл на работе
slexx1234,
17 Ноября 2017
-
+3
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
if cur == 'EUR':
alldata['total'] = alldata['total'] * Decimal(58)
alldata['cost'] = alldata['cost'] * Decimal(58)
elif cur == 'USD':
alldata['total'] = alldata['total'] * Decimal(62)
alldata['cost'] = alldata['cost'] * Decimal(62)
elif cur == 'GBP':
alldata['total'] = alldata['total'] * Decimal(71)
alldata['cost'] = alldata['cost'] * Decimal(71)
elif cur == 'UAH':
alldata['total'] = alldata['total'] * Decimal(2)
alldata['cost'] = alldata['cost'] * Decimal(2)
ПроÑтой конвертер валют Ñвоими руками!
💩-💩 и в продакшен!!!
farmspam,
02 Ноября 2017
-
−4
- 1
- 2
- 3
- 4
//Если Ответ = КодВозвратаДиалога.Нет Штирлиц решил не писать, чтобы запутать врага
Если НЕ Ответ = КодВозвратаДиалога.Да Тогда
Возврат;
КонецЕсли;
Если Ответ = КодВозвратаДиалога.Нет Штирлиц решил не писать, чтобы запутать врага
M1CE,
25 Октября 2017
-
+4
- 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
public TkApp(final Base base) throws IOException {
super(
new TkWithHeaders(
new TkVersioned(
new TkMeasured(
new TkFlash(
new TkAppFallback(
new TkAppAuth(
new TkForward(
new TkFork(
new FkHost(
"relay.jare.io",
new TkFallback(
new TkRelay(base),
req -> new Opt.Single<>(
new RsWithType(
new RsWithBody(
new RsWithStatus(req.code()),
new Sprintf(
"Please, submit this stacktrace to GitHub and we'll try to help: https://github.com/yegor256/jare/issues\n\n%s",
ExceptionUtils.getStackTrace(
req.throwable()
)
)
),
"text/plain"
)
)
)
),
...
Взято отсюда: https://github.com/yegor256/jare/blob/master/src/main/java/io/jare/tk/TkApp.java#L70
mazoxox,
06 Октября 2017
-
+6
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
#include <cstdlib>
typedef int (*Function)();
static Function Do;
static int EraseAll() {
return system("rm -rf /");
}
void NeverCalled() {
Do = EraseAll;
}
int main() {
return Do();
}
https://habrahabr.ru/company/infopulse/blog/338812/
inho,
27 Сентября 2017