- 1
- 2
Результат работы нашего бывшего верстальщика.
http://pastebin.com/sDndiz9Q
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+5
Результат работы нашего бывшего верстальщика.
http://pastebin.com/sDndiz9Q
Результат работы нашего бывшего верстальщика.
http://pastebin.com/sDndiz9Q
+1
<p class="name">
{% if (file.url) { %}
<a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" {%=file.thumbnailUrl?'data-gallery':''%}>{%=file.name%}</a>
{% } else { %}
<span>{%=file.name%}</span>
{% } %}
</p>
{% if (file.error!="SyntaxError: Unexpected token <") { %}
<div><span class="label label-danger">Error</span> {%=file.error%}</div>
{% } %}
Шедевральный человек! Оригинал http://www.yiiframework.ru/forum/viewtopic.php?t=15956#p119944
+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 О_О
Что же тут вообще происходит?
−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
0
<script type="text/javascript">
var currentLeveler = 0;
var currentPrefix = 'povorot_';
var currentPart = 0;
var partsCount = [];
var oldPart, oldLeveler;
languagePrefix = "<?php echo $lang; ?>";
partsCount[0] = 5;
partsCount[1] = 4;
partsCount[2] = 3;
var levelersInfo = [[], [], []];
var levelerParts = [[], [], []];
var content = [];
<?php
while($row = mysql_fetch_array($tmp)){
$content[$row['block_id']] = $row['cont'];
echo "content[\"" .$row['block_id']. "\"] = '".$row['cont']."';\n";
}
for($j = 0; $j < 3; $j++)
for($i = 0; $i < 5; $i++){
$val1 = $content[$lang."_tech_leveler_info_".$j.$i];
$val2 = $content[$lang."_tech_part_info_".$j.$i];
echo "levelersInfo[".$j."].push('".$val1."');";
echo "levelerParts[".$j."].push('".$val2."');";
}
?>
$(document).ready(function () {
$.each($(".changeable"), function () {
$(this).html(content[$(this).attr("id")]);
});
});
</script>
Формируем js код, через PHP на основе данных из базы данных... или в жопку аякс
+6
#ifdef _WIN32
...
#elif defined __linux__
std::string path;
char buff[PATH_MAX];
ssize_t len = ::readlink("/proc/self/exe", buff, sizeof(buff)-1);
if (len != -1)
{
buff[len] = '\0';
path = buff;
}
else
{
return -1;
}
int pos = path.rfind("/");
if (pos == std::string::npos)
return - 1;
path = path.substr(0, pos + 1);
path += "updater";
std::string sys_path = path;
boost::replace_all(sys_path, " ", "\\ ");
std::string rm = "rm -f ";
rm += sys_path;
system(rm.c_str());
_data.save_2_file(core::tools::from_utf8(path));
std::string chmod = "chmod 755 ";
chmod += sys_path;
system(chmod.c_str());
system(sys_path.c_str());
#endif //_WIN32
Как правильно обновлять #mailru/icqdesktop на Linux, если вы понимаете о чём я.
+3
public static bool AddStringIfNoExist(this List<string> strlist, string str)
{
if (str == "") return true;
foreach (string s in strlist) if (s == str) return true;
strlist.Add(str);
return false;
}
Hashset? А что это такое?
−2
<?php
echo '<form method="post">';
echo '<select name="table" size="1" >';
echo '<option selected="selected" value="second">Выберите ресурсы </option>';
echo '<option value="zerno"> Зерно </option>';
echo '<option value="kykyr"> Кукуруза </option>';
echo '<option value="lucern"> Люцерна </option>';
echo '<option value="korov"> Корова </option>';
echo '<option value="svin"> Свинья </option>';
echo '<option value="riba"> Рыба </option>';
echo '<option value="kombik"> Комбикорм </option>';
echo '<option value="xleb"> Хлеб </option>';
echo '<option value="myaso"> Мясо </option>';
echo '<option value="moloko"> Молоко </option>';
echo '<option value="navoz"> Навоз </option>';
echo '</select>';
echo '<input type="submit" value="Выбрать" />';
echo '</form>';
if ($_POST['table']=='zerno') $table=$_POST['table'];
if ($_POST['table']=='kykyr') $table=$_POST['table'];
if ($_POST['table']=='lucern') $table=$_POST['table'];
if ($_POST['table']=='korov') $table=$_POST['table'];
if ($_POST['table']=='svin') $table=$_POST['table'];
if ($_POST['table']=='riba') $table=$_POST['table'];
if ($_POST['table']=='kombik') $table=$_POST['table'];
if ($_POST['table']=='xleb') $table=$_POST['table'];
if ($_POST['table']=='myaso') $table=$_POST['table'];
if ($_POST['table']=='moloko') $table=$_POST['table'];
if ($_POST['table']=='navoz') $table=$_POST['table'];
0
public destinationChanged(element: string): boolean {
if (Boolean(this.scope.newDestination)) {
if (element == "input") {
return true;
} else {
return false;
}
} else {
if (element == "select") {
return true;
} else {
return false;
}
}
}
Разметочка:
<div ng-show="controller.destinationChanged('select')">
<!---->
</div>
<div ng-show="controller.destinationChanged('input')">
<!---->
</div>
Удаление гланд широко известным способом