- 1
guest не нужен
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+19
guest не нужен
+5
\message{Russian hyphenation patterns by D. Vulis,}
\message{modified by M.Vorontsova and S.Lvovski.}
\message{Version date: 24.02.96}
--- неинтересная часть пропущена ---
{
\lccode`\a=`\м
\lccode`\b=`\г
\lccode`\c=`\у
\lccode`\d=`\е
\lccode`\e=`\с
\lccode`\f=`\х
\lccode`\g=`\у
\lccode`\h=`\к
\lccode`\i=`\г
\lccode`\j=`\х
\lccode`\k=`\м
\lccode`\l=`\н
\lccode`\n=`\ъ
\lccode`\o=`\з
\lccode`\p=`\й
\lccode`\q=`\ю
\lccode`\r=`\д
\lccode`\s=`\у
\lccode`\t=`\д
\lccode`\u=`\х
\lccode`\v=`\я
\lccode`\w=`\ы
\lccode`\x=`\z
\lccode`\y=`\ь
\lccode`\z=`\ч
\lowercase{
\patterns{
6jcp. 6usv. 6fgq. 6ucdk.
}
}
}
Отрывок из образцов переноса слов для TeX'а. Авторы постеснялись написать открытым текстом четыре образца (строка 35), поэтому зашифровали их простой подстановкой.
Читателю предлагается расшифровать эти образцы и догадаться, чего испугались авторы.
0
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Task 8_1</title>
<script type="text/javascript">
function charRemover(item) {
var charsMoreThanTwoTimes = "";
var charsMoreThanTwoTimes2 = "";
var tmpString="";
var result = "";
var almostResult = "";
var nextWordBeginning = 0;
for (var a = 0; a < item.length; a++) {
if ((a == nextWordBeginning+1)&&(nextWordBeginning > 0)) {tmpString="";}
if ((a!=item.length-1)&&((item[a]!=' ') && (item[a]!=',') && (item[a]!='.') && (item[a]!=';') && (item[a]!=':') && (item[a]!='!') && (item[a]!='?')))
{
tmpString = tmpString + item[a];
}
else if ((a == item.length -1 ) && ((item[a]!=' ') && (item[a]!=',') && (item[a]!='.') && (item[a]!=';') && (item[a]!=':') && (item[a]!='!') && (item[a]!='?')))
{
tmpString = tmpString + item[a];
for (var j = 0; j < tmpString.length; j++)
{
var counter = 0;
for (var k = 0; k < tmpString.length; k++)
{
if (tmpString[k] == tmpString[j]) {counter++; }
}
if (counter == 1) {almostResult = almostResult + tmpString[j];}
if (counter > 1) { charsMoreThanTwoTimes = charsMoreThanTwoTimes + tmpString[j];}
}
}
else if ((a != item.length-1)&&((item[a]==' ') || (item[a]==',') || (item[a]=='.') || (item[a]==';') || (item[a]==':') || (item[a]=='!'))){
for (var j = 0; j < tmpString.length; j++)
{
var counter = 0;
for (var k = 0; k < tmpString.length; k++)
{
if (tmpString[k] == tmpString[j]) {counter++;}
}
if (counter == 1) {almostResult = almostResult + tmpString[j];}
if (counter > 1) { charsMoreThanTwoTimes = charsMoreThanTwoTimes + tmpString[j];}
}
almostResult = almostResult + item[a];
nextWordBeginning = a;
}
}
counter = 0;
//пройдемся еще раз и удалим символы, которые встречаются более одного раза
for (var i = 0; i < almostResult.length; i++)
{
var shoundCharToBeRemoved = false;
for (var j = 0 ; j < charsMoreThanTwoTimes.length; j++)
{
if (almostResult[i] == charsMoreThanTwoTimes[j]) {shoundCharToBeRemoved = true;}
}
if (shoundCharToBeRemoved == true) {}
else {result = result + almostResult[i];}
}
return result;
}
var sourceString = "У попа была собака";
var destString = charRemover(sourceString);
</script>
</head>
<body>
<script type="text/javascript">
document.write(destString);
</script>
</body>
</html>
Только что начал изучать JavaScript. Знаю, что говнокод, так что не судите строго !
Сама задача: Нanucaть функцuю, нa вxoд кoтoрoй nрuxoдuт cтрoкa, cocтoящaя uз неcкoлькux cлoв. cлoвa
рaзделены nрoбельнымu cuмвoлaмu (nрoбел, тaбуляцuя) u знaкaмu nреnuнaнuя (?!:;,.). Нужнo
вернуть cтрoку, в кoтoрoй будут удaлены вcе cuмвoлы, noвтoряющuеcя xoть в oднoм uз cлoв бoлее
oднoro рaзa.
+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();
}
}
});