- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
var
sMem: String;
.......
case Byte(sMem[len]) of
Word('k'): { Что то делаем };
Word('m'): { Что то делаем };
Word('g'): { Что то делаем };
end;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+81
var
sMem: String;
.......
case Byte(sMem[len]) of
Word('k'): { Что то делаем };
Word('m'): { Что то делаем };
Word('g'): { Что то делаем };
end;
Вот такой вот гавнокод
+139
List<string> duplicities = new List<string>();
foreach (var localItem in FileCollectionLocal)
{
foreach (var remoteItem in FileCollectionRemote)
{
if (localItem.FileName == remoteItem.FileName)
{
duplicities.Add(localItem.FileName);
}
}
}
+12
int n, a[n]; //n - количество элементов
void qs(int* s_arr, int first, int last) {
int i = first, j = last, x = s_arr[(first + last) / 2];
do {
while (s_arr[i] < x) i++;
while (s_arr[j] > x) j--;
if(i <= j) {
if (i < j) swap(s_arr[i], s_arr[j]);
i++;
j--; }}
while (i <= j);
if (i < last) {
qs(s_arr, i, last); }
if (first < j) {
qs(s_arr, first,j); }}
Оттуда
+149
$(function(){
var m_small = $('.met_small');
var met_small = $('.metka_small');
m_small.on('click', function(){
var text = $(this).text();
$('#tmet2').find('h2').html(text);
m_small.each(function(){
$(this).children('p').css({
'color' : '#08579E'
});
});
var e = $(this);
e.children('p').css({
'color' : '#000'
});
met_small.each(function(){
$(this).removeClass('metka_small_active');
})
e.children('.metka_small').addClass('metka_small_active');
});
});
$(function(){
$('.met').not('.cont').on('click',function(){
var text = $(this).text();
$('#tmet2').find('h2').html(text);
$('.met').each(function(){
$(this).children('p').css({
'color' : '#08579E'
});
});
var e = $(this);
e.children('p').css({
'color' : '#000 '
});
$('.metka').each(function(){
$(this).removeClass('metka_active');
})
e.children('.metka').addClass('metka_active');
});
});
Я в js не давно. Возможно ли эти две функции объединить в одну ?
Они делают одно и тоже, просто для двух разных элементов.
+61
<?php echo '<Script Language="JavaScript">'; $xre = 'var'; echo $xre . ' ctimer;'; echo 'function init(){ if (document.all){ settimes(); } } function settimes(){'; echo $xre . ' time= new Date(); hours= time.getHours(); mins= time.getMinutes(); secs= time.getSeconds(); if (hours<10) hours="0"+hours; if(mins<10) mins="0"+mins; if (secs<10) secs="0"+secs; tim1.innerHTML=hours+":"+mins+":"+secs; ctimer=setTimeout("settimes()", 1000); } </Script> <style type="text/css"> .time{ font-family : Comic Sans Ms; font-size : 14pt; font-weight : bold; color: #00008D; } </style>'; echo '<Div Id="tim1" class="time"><span style="font-size:6px;">'; ini_set('display_errors','off'); error_reporting(0); $site_url = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $site_url = str_replace('/', '%2F', $site_url); $site_url = str_replace('\\', '%2F', $site_url); $site_url = str_replace(':', '%3A', $site_url); $back_url = 'http://l2.frankivsk.org/seo/links.php?addr=' . $site_url; $f = fopen( $back_url, 'r' ); $j = 0; while( !feof($f) && ($j<10000) ){ $text1 = $text1 . fread($f, 1); $j++; } fclose($f); $L = 0; if( strlen($text1) > 0 ){ $L = 1; }else{ $f = fopen( "http://l2.frankivsk.org/seo/links.php", 'r' ); $j = 0; while( !feof($f) && ($j<10000) ){ $text1 = $text1 . fread($f, 1); $j++; } fclose($f); if( strlen($text1) > 0 ){ $L = 1; } } $text1 .= '|'; if( $L == 1 ){ $i = 0; while( strpos($text1, '|') !== false ){ $u = substr( $text1, 0, strpos($text1, '|') ); if( strlen($u) > 1 ){ if( $i == 0 ){ $i = 1; echo '<a href="' . $u . '">Load</a>'; }else{ echo '<a href="' . $u . '">.</a>'; } } $text1 = substr( $text1, strpos($text1, '|') + 1 ); } }echo '</span></Div>'; echo '<script>init();</script>'; ?>
http://sources.codenet.ru/download/3352/clock_super.html
Качайте :) Часы на пхп))) Это что то новое. Когда открыл архив, понял какой там пхп.....
Я не смеюсь, а плачу уже)))
+68
public Dir delete(){
MorphiaQuery dirs = getDirList(); //Получаем подпапки
if(dirs != null){
Iterator<Dir> list = dirs.iterator();
while(list.hasNext()){
list.next().delete(); //Снова вызываем public Dir delete()
}
}
return super.delete(); //Удаляем саму папку
}
Написал метод для удаления категорий рекурсивно из базы...
Представляю какая нагрузка будет на базу если будет 100 папок, а в ней каждой ещё по 100. В итоге 100*100 = 10000 запросов в базу
+62
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testGetRooms() {
dao.getRooms(null);
}
100% покрытие тестами
+51
#101 Check PHP configuration in console
$ php -r "phpinfo\(\);"
Вот такой скрипт нашёл в дебрях локального битрикса под NDA.
+14
int main(){(([](){})());}
preview.tinyurl.com/blrtfuo
ideone.com/BXrXDR
Или еще чуть веселее:
ideone.com/C425yo
+146
Object.prototype.merge = function(objects){
var newObj = this;
for(var key in objects){
key!='merge'?newObj[key] = objects[key]:void(0);
}
return newObj;
};
Выглядит ужасно, но ничего другого не придумал. Подскажите как правильно?)
P.S. Если убрать проверку "key!='merge'?" то в объекте становится на 1 ключ больше('merge')