- 1
Пидарашки, приведите реальный пример говнокода.
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−2
Пидарашки, приведите реальный пример говнокода.
−2
TOCTOU race condition in Docker allows root access to the filesystem of the host platform.[4]
+2
<?
global $DB,$APPLICATION,$USE,$USER_FIELD_MANAGER,$CACHE_MANAGER;
/* @var $DB CDatabase */
/* @var $GLOBALS['DB'] CDatabase */
/* @var $GLOBALS["DB"] CDatabase */
$DB = $GLOBALS['DB'] = $GLOBALS["DB"] = new CDatabase();
/* @var $APPLICATION CMain */
/* @var $GLOBALS['APPLICATION'] CMain */
/* @var $GLOBALS["APPLICATION"] CMain */
$APPLICATION = $GLOBALS['APPLICATION'] = $GLOBALS["APPLICATION"] = new CMain();
/* @var $USER CUser */
/* @var $GLOBALS['USER'] CUser */
/* @var $GLOBALS["USER"] CUser */
$USER = $GLOBALS['USER'] = $GLOBALS["USER"] = new CUser();
/* @var $USER_FIELD_MANAGER CUserTypeManager */
/* @var $GLOBALS['USER_FIELD_MANAGER'] CUserTypeManager */
/* @var $GLOBALS["USER_FIELD_MANAGER"] CUserTypeManager */
$USER_FIELD_MANAGER = $GLOBALS['USER_FIELD_MANAGER'] = $GLOBALS["USER_FIELD_MANAGER"] = new CUserTypeManager;
/* @var $CACHE_MANAGER CCacheManager */
/* @var $GLOBALS['CACHE_MANAGER'] CCacheManager */
/* @var $GLOBALS["CACHE_MANAGER"] CCacheManager */
$CACHE_MANAGER = $GLOBALS['CACHE_MANAGER'] = $GLOBALS["CACHE_MANAGER"] = new CCacheManager;
?>
Есть тут петухи, которые шарят в "PHP" ? Какие скобки лучше ординарные или двойные ?
+4
this.checkArrayErrors() ? (this.canSend = true) : (this.canSend = false);
Код разраба, который не прошел испытательный срок и сказал что к нему придираются.
+1
<script>
window["flags"] = {
"purcTOFlag": "true" == "true" ? true : false,
"ENBL_CANCEL_POLICY": "true" == "true" ? true : false,
"ENBL_BACKUP_CHECK_OLD_DEVICES": "false" == "true" ? true : false,
"ENBL_DIRECT_ACCESS_LINKS": "true" == "true" ? true : false,
"ENBL_NEW_ABG_URL": "true" == "true" ? true : false,
"cr_9839666": "true" == "true" ? true : false,
"cubaCRFlag": "true" == "true" ? true : false,
"cubaMultiCityCRFlag": "true" == "true" ? true : false,
"youthCRFlag": "true" == "true" ? true : false,
"ENABLE_AFOP_MODE": "true" == "true" ? true : false,
"SHARE_ITINERARY_ON_FACEBOOK": "false" == "true" ? true : false,
"cr_11668201": "true" == "true" ? true : false,
"hotelCRFlag": "true" == "true" ? true : false,
"cr_adoshareitinerary": "false" == "true" ? true : false,
"ROUNDOFF_AMOUNT_FOR_US_EDITION": "true" == "true" ? true : false,
"hideSeatPromotionalBanner": "true" == "true" ? true : false,
"enablePremiumRougeCR": "true" == "true" ? true : false,
"availFareSplit": "true" == "true" ? true : false,
"improvedMixedCabin": "true" == "true" ? true : false,
"adoPassengerPrepopulate": "true" == "true" ? true : false,
"adoIataInformation": "true" == "true" ? true : false,
"premiumRougeSeatSelection": "true" == "true" ? true : false,
"displayIntlTerminal": "true" == "true" ? true : false,
"continueDisabledLightboxIsEnabled": "true" == "true" ? true : false,
"createAeroplanFromConf": "true" == "true" ? true : false,
"contOnAvailPage": "true" == "true" ? true : false,
"alpiSpecialAssistanceCRFlag": "true" == "true" ? true : false,
"removePaxTitle": "false" == "true" ? true : false,
"perDiemInsurance": "true" == "true" ? true : false,
"isVisaCheckoutEnabled": "true" == "true" ? true : false,
"isCashRewardEnabled": "true" == "true" ? true : false,
"masterPassCRFlag": "true" == "true" ? true : false,
"masterPassAllowedEdition": "CA\-en:CA\-fr:CA\-zh",
"youthphase2CRFlag": "true" == "true" ? true : false,
"isCitylistPerfEnabled": "true" == "true" ? true : false,
"isSingleTravelOptionEnabled": "false" == "true" ? true : false,
"retainPaymentInformation": "true" == "true" ? true : false,
"hotelChildAgeCR": "true" == "true" ? true : false,
"displayGeoFirst": "true" == "true" ? true : false,
"displayDiscAvail": "true" == "true" ? true : false,
"premiumRougeUpsell": "true" == "true" ? true : false,
"enableReplaceOpinionLabs": "true" == "true" ? true : false,
"displayOalRef": "true" == "true" ? true : false,
"newTravelOptionsLayoutFlag": "true" == "true" ? true : false,
"hotelWidgetAPI": "true" == "true" ? true : false,
"enableCombinedPhoneNo": "true" == "true" ? true : false,
"hideTripSummaryForMobile": "true" == "true" ? true : false,
"enableSecureAttribute": "true" == "true" ? true : false,
"enhancedPreviewSeatMap": "true" == "true" ? true : false,
"enhancedSeatMap": "true" == "true" ? true : false,
"firstClassCabinCR": "true" == "true" ? true : false,
.
.
}
Taken from aircanada.com. Enjoy!
0
#include <iostream>
int main()
{
setlocale(LC_ALL, "Russian");
long long int num;
long long int divider = 1;
int max = 0;
int min = 9;
std::cout.unsetf(std::ostream::unitbuf);
std::cout « "Введите число: ";
std::cin » num;
while(num>=divider)
{
if(num/divider%10>max) max = num/divider%10;
if(num/divider%10<min) min = num/divider%10;
divider = divider * 10;
}
std::cout « max « " - большая цифра" « '\n';
std::cout « min « " - меньшая цифра";
return 0;
}
−3
Бомбёж по поводу Wine и Mono
Все говорят, что Wine не может с 1993 года запускать программы под винду. И всё почему? Потому что не могут господа вся опенсорса и линуксии нормально реимплементить программы с нешвабодки. Содержимое бутылки похоже на винду настолько отдалённо, как борманд на кегдана. И причём тут Mono? Притом, что в вайн засунули моно, который кривой как руки создателя 1C. И самое страшное, что ни вайн, ни моно никто не хочет сделать на 100% идентичным оригиналу. Ведь если они не будут похожи, то они просто становятся бесполезны.
+1
#include <experimental/coroutine>
#include <iostream>
#include <optional>
#include <utility>
template<typename T>
class Maybe
{
std::shared_ptr<std::optional<T>> m_maybe = std::make_shared<std::optional<T>>();
public:
Maybe() = default;
Maybe(const T& t)
: m_maybe { std::make_shared<std::optional<T>>(t) }
{
}
explicit operator bool() const { return static_cast<bool>(*m_maybe); }
T& operator* () { return **m_maybe; }
const T& operator*() const { return **m_maybe; }
void reset() { m_maybe->reset(); }
template<typename U>
void emplace(U&& u) { m_maybe->emplace(std::forward<U>(u)); }
};
template<typename T>
void printMaybe(const Maybe<T>& opt)
{
if (opt)
std::cout << *opt << std::endl;
else
std::cout << "<empty>" << std::endl;
}
template<typename T, typename... Args>
struct std::experimental::coroutine_traits<Maybe<T>, Args...>
{
struct promise_type
{
Maybe<T> m_maybe;
auto get_return_object() { return m_maybe; }
std::experimental::suspend_never initial_suspend() { return {}; }
std::experimental::suspend_never final_suspend() { return {}; }
void unhandled_exception() { m_maybe.reset(); }
template<typename U>
void return_value(U&& u) { m_maybe.emplace(std::forward<U>(u)); }
};
};
template<typename T>
auto operator co_await(const Maybe<T>& maybe)
{
struct Awaiter
{
const Maybe<T>& input;
bool await_ready() { return static_cast<bool>(input); }
auto await_resume() { return *input; }
void await_suspend(std::experimental::coroutine_handle<> coro) { coro.destroy(); }
};
return Awaiter { maybe };
}
Maybe<int> maybeAdd(const Maybe<int>& maybeA, const Maybe<int>& maybeB)
{
auto a = co_await maybeA;
auto b = co_await maybeB;
co_return a + b;
}
int main()
{
/*
printMaybe(maybeAdd({ 1 }, { 2 }));
printMaybe(maybeAdd({}, { 2 }));
printMaybe(maybeAdd({ 1 }, {}));
*/
const auto res = maybeAdd({ 1 }, { 2 });
return res ? *res : 0;
}
do-нотация в плюсах
−3
namespace raytracing
{
struct Scene::Implementation
{
std::vector<std::unique_ptr<RenderObject>> renderObjects;
std::vector<Light> lights;
Camera camera;
};
}
Scene::Scene() :
implementation{std::make_unique<Implementation>()}
{
}
void Scene::insertObject(RenderObject* renderObject) noexcept
{
implementation->renderObjects.push_back(std::unique_ptr<RenderObject>{renderObject});
}
const RenderObject* Scene::getIntersectedObject(Ray ray, vec3f* intersectionPoint) const noexcept
{
const auto& renderObjects = implementation->renderObjects;
if (renderObjects.empty())
return nullptr;
struct IntersectionData
{
const RenderObject* renderObject;
float t;
bool isIntersect;
vec3f intersectionPoint;
} temp{};
for (decltype(implementation->renderObjects)::const_iterator iter = renderObjects.cbegin();
iter != renderObjects.cend(); ++iter)
{
IntersectionData intersectionData;
intersectionData.renderObject = (*iter).get();
intersectionData.isIntersect = (*iter)->isIntersect(ray, intersectionData.t,
&intersectionData.intersectionPoint);
if (intersectionData.isIntersect)
{
if (temp.isIntersect)
{
if (temp.t > intersectionData.t)
temp = intersectionData;
}
else
temp = intersectionData;
}
}
if (intersectionPoint)
*intersectionPoint = temp.intersectionPoint;
return temp.renderObject;
}
namespace raytracing
{
struct Renderer::Implementation
{
vec3f trace(const Scene& scene, Ray ray) const noexcept
{
vec3f intersectionPoint;
const RenderObject* const renderObject = scene.getIntersectedObject(ray, &intersectionPoint);
vec3f color{};
if (!renderObject)
return color;
for (Light l : scene.getLights())
{
const Ray lightRay{intersectionPoint, (l.position - intersectionPoint).normalize()};
float brightness = renderObject->getNormal(intersectionPoint).dot(lightRay.direction);
if (brightness < 0.0F)
brightness = 0.0F;
color += renderObject->getColor(intersectionPoint) * 255.0F * brightness;
}
return color;
}
}
}
Сумеете ли вы найти ошибку?
−288
http://blogs.msdn.com/b/oldnewthing/archive/2010/09/17/10063629.aspx
Что за хрень? С каких пор \ в виндовой консоли эксейпит кавычки? Эскейпящий символ же ^?