- 1
- 2
- 3
- 4
int a = -1;
while(+a){
if(a == 0) break;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+2
int a = -1;
while(+a){
if(a == 0) break;
}
+7
function checkPermission(user, post) {
return equals(post.author, user) ||
user.role = 'admin';
}
when you see it, you'll shit bricks
+1
List<dynamic> reporting = item.company_profile_data?.AnnualFinancialStatementFiles ??
new List<dynamic>();
string annual = "";
foreach (var report in reporting)
{
if (report.File != null)
{
string name = report.File?.Info?.Name;
if (name != null) annual = annual + name.Substring(0, name.LastIndexOf('.')) + ", ";
}
}
item.Name = annual;
П - производительность.
+3
<?xml version="1.0" encoding="windows-1251"?>
<Анкета ВерсияСхемы="2.05" ДатаФормирования="2016-04-19T17:04:57" ФорматДаты="ДФ=yyyy-MM-dd; ДЛФ=DT" ФорматВремени="ДФ=ЧЧ:мм:сс; ДЛФ=T" РазделительДатаВремя="T" >
<Вопрос Ид="" Значение="">
<Ответ Тип="Простой"></Ответ>
<Ответ Тип="Комплексный">
<ЧастьВопроса Тип="Компания"></ЧастьВопроса>
<ЧастьВопроса Тип="Должность"></ЧастьВопроса>
</Ответ>
</Вопрос>
</Анкета>
Мда...
+1
void CScene::IncludeObjects()
{
// Reset All.
ExcludeObjects();
// fill Vershiny of piramid...
point3d versh[4];
point3d eye = {IniSet.ptCamPos.x, IniSet.ptCamPos.y, IniSet.ptCamPos.z};
Screen2World(0, 0, versh[0]);
Screen2World(nScreenSzX, 0, versh[1]);
Screen2World(nScreenSzX, nScreenSzY, versh[2]);
Screen2World(0, nScreenSzY, versh[3]);
// Increase before OO...
int ix, sz = parrObjs.Size();
point3d vect;
for(ix = 0; ix < 4; ix++){
sub_vectors(&vect.x, &versh[ix].x, &eye.x);
norm_vect(&vect.x);
scale_vect(&vect.x, 200.f);
versh[ix] = vect;
}
// Create faces of piramid and search collision with it...
point3d Piramid[4][3];
Piramid[0][0] = eye;
Piramid[1][0] = eye;
Piramid[2][0] = eye;
Piramid[3][0] = eye;
Piramid[0][1] = versh[0];
Piramid[0][2] = versh[1];
Piramid[1][1] = versh[1];
Piramid[1][2] = versh[2];
Piramid[2][1] = versh[2];
Piramid[2][2] = versh[3];
Piramid[3][1] = versh[3];
Piramid[3][2] = versh[0];
// Dyadya WALERA!!!!
for(ix = nObjOff; ix < sz; ix++){
CObj3d *pObj = parrObjs.e(ix);
pObj->Transform(FALSE);
point3d ptPos = pObj->GetPosition();
if(IniSet.nIncludeObjectMode == WS_INCLUDE_BARYCENTER){
point3d ptCentr = IniSet.ptCamTarget;
point3d vtVect;
sub_vectors(&vtVect.x, &ptPos.x, &ptCentr.x);
plane plGran;
point3d ptCross;
for(int jx = 0; jx < 4; jx++){
comp_plane_eqn(&plGran.a, &Piramid[jx][0].x, &Piramid[jx][1].x, &Piramid[jx][2].x);
cross_line_plane(vtVect, &plGran.a, ptCentr, ptCross);
float f1, f2;
f1 = plGran.a * ptPos.x + plGran.b * ptPos.y + plGran.c * ptPos.z + plGran.d;
f2 = plGran.a * ptCentr.x + plGran.b * ptCentr.y + plGran.c * ptCentr.z + plGran.d;
if(f1 * f2 < 0.f){
if(point_in_triangle(Piramid[jx][0], Piramid[jx][1], Piramid[jx][2], ptCross)){
ptCross = ConvertPos3D(ptCross);
if(IniSet.bMirrorH){ ptCross.y = -ptCross.y; }
if(IniSet.bMirrorV){ ptCross.x = -ptCross.x; }
if(IniSet.bMirrorD){ ptCross.z = -ptCross.z; }
transform_back_point(&ptCross, &ptCross, &IniSet.mtMatr);
pObj->ptSavedPos = ptCross;
break;
}
}
}
}else{ // XYZ Axes.
point3d vtXYZ[3] = {{1.f, 0.f, 0.f},
{0.f, 1.f, 0.f},
{0.f, 0.f, 1.f}};
BOOL bFound = FALSE;
for(int ax = 0; ax < 3; ax++){
point3d vtVect;
transform_point(&vtVect, &vtXYZ[ax], &IniSet.mtMatr);
for(int jx = 0; jx < 4; jx++){
plane plGran;
comp_plane_eqn(&plGran.a, &Piramid[jx][0].x, &Piramid[jx][1].x, &Piramid[jx][2].x);
point3d ptCentr = IniSet.ptCamTarget;
point3d ptCross;
cross_line_plane(vtVect, &plGran.a, ptPos, ptCross);
float f1, f2;
f1 = plGran.a * ptPos.x + plGran.b * ptPos.y + plGran.c * ptPos.z + plGran.d;
f2 = plGran.a * ptCentr.x + plGran.b * ptCentr.y + plGran.c * ptCentr.z + plGran.d;
point3d vtDif;
sub_vectors(&vtDif.x, &ptCross.x, &IniSet.ptCamPos.x);
if(vec_length(&vtDif.x) < 0.01f){ continue; } // avoid crossing with eye.
Гавнокод: включить все 3Д объекты в экран.
+2
public function get($userId = null, $advense = false) {
if ($userId === null) $userId = $this->currentId;
$user = DB::table('users')
->select(
'*',
DB::raw('IF(email IS NOT NULL AND email_confirm IS NULL, 1, 0) AS email_confirm'),
DB::raw('IF(phone IS NOT NULL AND phone_confirm IS NULL, 1, 0) AS phone_confirm'),
DB::raw('IF(birthday IS NOT NULL, TIMESTAMPDIFF(YEAR,birthday,CURDATE()), NULL) AS age'),
DB::raw('IF(phone IS NOT NULL AND phone_confirm IS NULL AND email IS NOT NULL AND email_confirm IS NULL AND (new_first_name IS NOT NULL OR new_last_name IS NOT NULL OR new_status_text IS NOT NULL OR new_image_url IS NOT NULL), 1, 0) AS on_moderate'))
->where('id', $userId)->first();
if ($user === null) throw new Exception ('User is not found', 404);
unset($user->password);
$user->locality = Geo::get($user->locality_id);
$rating = $this->rating($userId);
$user->rating = (float)$rating->avg;
$user->rating_counter = (int)$rating->cnt;
$user->counters = $this->getCounters($userId);
$contact = $this->contacts->isMyContact($userId);
if ($userId != $this->currentId) {
$user->created = null;
$user->updated = null;
$user->birthday = null;
$user->email_confirm = null;
$user->phone_confirm = null;
$user->subscribed = null;
$user->organizations = null;
$contact = $this->contacts->isMyContact($userId);
// Если пользователь не контакт авторизованного, сотрем контактную информацию
if ( $contact === null || $contact === 'declined') {
$user->phone = null;
$user->email = null;
$user->last_name = mb_substr($user->last_name, 0, 1, 'UTF-8');
}
} else {
if($user->new_first_name !== null) {
$user->first_name = $user->new_first_name;
}
if($user->new_last_name !== null) {
$user->last_name = $user->new_last_name;
}
if($user->new_image_url !== null) {
$user->image_url = $user->new_image_url;
}
if($user->new_status_text !== null) {
$user->status_text = $user->new_status_text;
}
$user->organizations = Organizations\Organizations::getByUserId($userId);
$user->is_followed = null;
$user->is_my_contact = null;
$user->has_my_contact = null;
$user->has_my_opinion = null;
}
unset($user->new_status_text);
unset($user->new_image_url);
unset($user->new_last_name);
unset($user->new_first_name);
unset($user->reset_code);
$user->is_followed = $this->followers->isFollowed($userId);
$user->is_my_contact = $this->contacts->isMyContact($userId);
$user->has_my_contact = $this->contacts->hasMyContact($userId);
return $user;
}
Тыдыдыдыдыыыц, laravel code О_О
Что же тут вообще происходит?
+4
// Авторизация
$app->post('/action/login', function(Request $request, Response $response)
{
global $connection, $hash;
$data = $request->getParsedBody('login');
$login = $data['login'];
$password = md5($data['password']);
$result = mysqli_query($connection, "SELECT `password` FROM `users` WHERE `login` = '$login'");
$row = $result->fetch_assoc();
if(!empty($login) and !empty($password))
{
if($password === $row['password'])
{
$_SESSION['auth'] = $hash;
echo "<script>location.href='/log';</script>";
}
else
{
redirect();
}
}
});
−10
if (0) {
unserialize ("");
is_bool ("");
is_array ("");
is_string ("");
is_integer ("");
is_float ("");
}
github.com/vk-com/kphp-kdb/blob/master/KPHP/functions.txt
+3
m =: 256$0
index =: 0
output =: 0$0
input =: 0$0
code =: 0$0
cycles =: 0$0
codeIndex =: 0
setCode =: 3 : 'code =: transform y'
transform =: '><+-.,[]'&i.
preset =: 3 : 'cycles =: 0$0 [ codeIndex =: 0 [ output =: 0$0 [ m =: 256$0 [ index=:0'
returnOutput =: 3 : 'output { a.'
changeValue =: 3 : 'm =: (index&{.,y,(>:index)&}.) m'
addCodeIndex =: 3 : 'codeIndex =: (>: codeIndex)'
setCodeIndex =: 3 : 'codeIndex =: {: cycles'
deleteCycle =: 3 : 'cycles =: }: cycles'
func_1 =: 3 : 'index =:256&|@>:index'
func_2 =: 3 : 'index =:256&|@<:index'
func_3 =: 3 : 'changeValue@(256&|)@>:@(index&{) m'
func_4 =: 3 : 'changeValue@(256&|)@<:@(index&{) m'
func_5 =: 3 : 'output=:output, ((index&{) m)'
func_6 =: 3 : '(input =: }.input)[ changeValue(256&|@{.input)'
func_7 =: 3 : 'cycles =: cycles&, codeIndex'
func_8 =: 3 : '(setCodeIndex`deleteCycle@.(0&=))@(index&{) m'
doAction =: func_1`func_2`func_3`func_4`func_5`func_6`func_7`func_8@.]
doInstuction =: 3 : '(doAction[addCodeIndex)@{.@(codeIndex&{) code'
ExitCond =: 3 : 'codeIndex = (# code)'
interpreter =: 3 : '(((,&1 [ doInstuction )`0: @. ExitCond)^:_) 0'
brainFuck =: returnOutput [ interpreter [ setCode [ preset
brainFuck '++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.'
интерпретатор брейнфака на J
−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;
}
}
}
Сумеете ли вы найти ошибку?