- 1
if (!this) return;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+57
if (!this) return;
+154
// Цитата №1: массив регулярных выражений из введённых пользователем строк
var strings = what.filter(function(e){ return e.replace(/s+/g,'').length; }).map(function(e){ var re = new RegExp(e, 'g' + (ignoreCase ? 'i' : '')); return re; });
// Цитата №2: проверяется наличие введённых строк в тексте и выводит результаты
function processText(pid, cid, text){
if(strings.every(function(re){
return re.test(text);
})){
// совпало
// тут выводится информация о совпадении для поста/комментария
// кроме вывода в консоль побочных эффектов нет
....
}
}
// Цитата №3: запуск поиска
posts.forEach(function(post){
processText(post.id, null, post.author.name + ' ' + post.text);
processText(post.id, null, post.author.name + ' ' + post.description);
post.comments.forEach(function(comment){
processText(post.id, comment.id, comment.author.name + ' ' + comment.text);
});
});
Цитаты из скрипта поиска по ГК.
Казалось бы, write-only питушня, работает - не трогать. Но, прочитав, http://govnokod.ru/16577#comment246821, решил поискать упоминания доктора по званию. Открываю найденный пост X, а там не все упоминания найдены. Меняю список постов, в которых искать - для X меняется список найденных комментариев.
Откуда такая питушня? processText почти чистая, strings, posts не меняется. Может, вывод на консоль как-то влияет?
Все волосы на жопе вырвал пока нашел в чем ошибка.
Внимание, вопрос. В чем гавно? (c) ursus
+155
// Отладочная информация
if(1)
{
print "<!--\r\n";
$time_end = microtime(true);
$exec_time = $time_end-$time_start;
if(function_exists('memory_get_peak_usage'))
print "memory peak usage: ".memory_get_peak_usage()." bytes\r\n";
print "page generation time: ".$exec_time." seconds\r\n";
print "-->";
}
Simpla CMS, красавцы! :D
+135
public string ExportToFile(string filename, string filepath, DataSet dsInput)
{
string sFlag = "Error";
System.IO.StreamWriter sw = new StreamWriter("");
try
{
if (filename.Trim() != "" && filepath != "" && dsInput.Tables[0].Rows.Count != 0)
{
sw = new System.IO.StreamWriter(filepath + filename + ".xls");
int iCol = dsInput.Tables[0].Columns.Count;
for (int i = 0; i < iCol; i++)
{
sw.Write(dsInput.Tables[0].Columns[i]);
if (i < iCol - 1)
{ sw.Write("\t"); }
sw.Write(sw.NewLine);
foreach (DataRow dr in dsInput.Tables[0].Rows)
{
for (int i = 0; i < iCol; i++)
{
if (!Convert.IsDBNull(dr[i]))
{
sw.Write(dr[i].ToString());
}
if (i < iCol - 1)
{ sw.Write("\t"); }
}
sw.Write(sw.NewLine);
}
sw.Close();
sFlag = "Success";
}
}
return sFlag;
}
catch (Exception)
{
return sFlag;
}
}
С какого-то китайского сайта:
http://www.datazx.cn/Forums/en-US/2d129cdc-2705-4035-90e2-063c4c399ae5/action?threadDisplayName=wpf-datagrid-remove-whitespace-from-string-on-clipboard-copy&forum=wpf
Нафиг эксепшены, лучше вернем строку "Error"! Ну или "Success", если этот чудо-код еще и не грохнется.
+158
<?php
include 'config.php';
$title = "Форум - $maintitle";
$topic = $_GET['topic'];
$board = $_GET['board'];
$main = $_GET['main'];
include 'core/funcs.php';
include 'core/pdoconnect.php';
include 'te/heads.php';
echo '
<div class="clear"></div>
<!-- Content Section -->
<div id="content_sec">
<!-- Column 1 -->
<div class="col1">
<!-- Featured Playlist -->
<div class="featured_playlist">
<h3 class="heading">',$title,'</h3>
';
if (isset($topic)){
echo '<table>
<tbody>
<tr><th> Тема</th><th>Автор</th><th>Посл.обн.</th>
</tr>';
}
if ($board > 0){
echo '<table>
<tbody>
<tr><th> Тема</th><th>Автор</th><th>Посл.обн.</th>
</tr>';
$prepare = $db->prepare("SELECT * from `forum` where `board_id` = :bo_id order by `last_update` DESC");
$prepare->bindParam(":bo_id", $board, PDO::PARAM_INT);
$prepare -> execute();
//print_r($prepare->errorinfo());
if ($prepare->rowCount() == 0){
echo '<p class = "error-box">В этом разделе еще не создано ни одной темы!</p>';
}else{
while($bo = $prepare->fetch(PDO::FETCH_BOTH)){
echo '<tr><td><a href="forum-topic',$bo['id'],' "> ',$bo['title'],' </a></td><td> ',$bo['author'],'</td><td> ',$bo['last_author'],'</td></tr>';
}
}
}
if (isset($_GET['main'])){
$i = 1;
echo '
<table>
<tbody>
<tr>
<th>Основной</th><th>Новое</th>
</tr>
<tr><td><a href = "forum-board',$i++,' ">Работа сайта</a></td><td>',$last['0'],'</td></tr>
<tr><td><a href = "forum-board',$i++,' ">Пожелания и предложения</a></td><td>',$last['1'],'</td>
<tr><th>Общение</th><th>Новое</th></tr>
<tr><td><a href = "forum-board',$i++,' ">Общение</a></td><td>',$last['2'],'</td></tr>
<tr><th>Работа</th><th>Новое</th></tr>
<tr><td><a href = "forum-board',$i++,' ">Оффтоп</td><td>$last['3']</td></tr>
<tr><td><a href = "forum-board',$i++,' ">Студенты</td><td>$last['4']</td></tr>
<tr><td><a href = "forum-board',$i++,' ">Преподаватели</td><td>$last['5']</td></tr>
<tr><td><a href = "forum-board',$i++,' ">Помощь</td><td>$last['6']</td></tr>
<tr><td><a href = "forum-board',$i++,' ">Литература</td><td>$last['7']</td></tr>
';
}
echo '</tbody></table></div></div>';
include 'te/foot.php';
?>
В общем, добрался до исходников сайта нашего инста.
Сам сайт имеет всего несколько частей - форум, лента новостей и ЛК.
Это скрипт "форума".
К слову, написано преподавателем со стажем работы 6 лет, как сам он нам доказывал и доказывает - часто фрилансит и все довольны. Чет не верится.
И этот человек учит других...
+64
int r = 5;
if (r ==5) {
throw new Exception();
}
+73
Class <? extends Object> currentClass = Class.forName( clazz )
Продолжаем разговор...
+156
Generator.prototype.update = function () {
var t = this.timer++,
d = this.delay,
s = this.samples,
m = this.minDistance,
w = this.width,
h = this.height,
g = this.global,
c = this.cid,
ttl = this.ttl--,
l = s.length,
rand = Math.random,
floor = Math.floor,
x,
y,
r,
i,
j,
d2,
n;
if (ttl > 0) {
while (t > d) {
r = s[floor(rand() * l)].copy();
if (m) {
i = 1000;
while (i--) {
x = rand() * w - w * 0.5;
y = rand() * h - h * 0.5;
for (j in this) if (j instanceof Entity) {
n = this[i];
d2 = (x - n.x) * (x - n.x) + (y - n.y) * (y - n.y);
if (d2 * d2 > m) {
i = 0;
}
}
}
} else {
x = rand() * w - w * 0.5;
y = rand() * h - h * 0.5;
}
r.x = x;
r.y = y;
if (!g) {
r.parent = this;
}
this[c] = r;
this.cid = c += 1;
this.time = t -= d;
}
} else {
delete this.update;
}
};
асм-диалект яваскрипта
+75
db.insertInto(VISIBILITY_CONSTRAINT,
VISIBILITY_CONSTRAINT.UUID,
VISIBILITY_CONSTRAINT.VERSION,
VISIBILITY_CONSTRAINT.FIRST_NAME_HIDDEN,
VISIBILITY_CONSTRAINT.MIDDLE_NAME_HIDDEN,
VISIBILITY_CONSTRAINT.LAST_NAME_HIDDEN,
VISIBILITY_CONSTRAINT.BIRTHDAY_HIDDEN,
VISIBILITY_CONSTRAINT.GENDER_HIDDEN,
VISIBILITY_CONSTRAINT.EMAIL_HIDDEN,
VISIBILITY_CONSTRAINT.COUNTRY_HIDDEN,
VISIBILITY_CONSTRAINT.REGION_HIDDEN,
VISIBILITY_CONSTRAINT.CITY_HIDDEN,
VISIBILITY_CONSTRAINT.STREET_HIDDEN,
VISIBILITY_CONSTRAINT.ZIP_CODE_HIDDEN,
VISIBILITY_CONSTRAINT.PHONE_NUMBER_HIDDEN,
VISIBILITY_CONSTRAINT.HOME_PAGE_HIDDEN,
VISIBILITY_CONSTRAINT.HOBBIES_HIDDEN
).values(
visibilityConstraintId,
UInteger.valueOf(0),
0.byteValue(),
0.byteValue(),
0.byteValue(),
0.byteValue(),
0.byteValue(),
0.byteValue(),
0.byteValue(),
0.byteValue(),
0.byteValue(),
0.byteValue(),
0.byteValue(),
'0', // shit happens
0.byteValue(),
0.byteValue()
).execute()
Пока писал тесты к говнопроекту, нашел PHONE_NUMBER_HIDDEN VARCHAR(64) NOT NULL. Hibernate по умолчанию ставил туда null. Там еще много всего, но остальное сюда не уместится.
+134
if (paramList[i].GetType().Equals(typeof(String)))
...