- 1
qDebug() << QString("%1-%2").arg("%1").arg("foo");
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+70
qDebug() << QString("%1-%2").arg("%1").arg("foo");
+81
program matr;
uses
crt;
var
mas:array [1..100] of integer;
i,n,imin,imax,min,max,razn:integer;
begin
clrscr;
imax:=1;
imin:=1;
randomize;
write('Введите количество элементов: ');
readln(n);
for i:=1 to n do
begin
mas[i]:=random(10)-5;
write(mas[i]:4);
if mas[i]>mas[imax] then
begin
imax:=i;
end
else
if (mas[i]<mas[imin]) then
begin
imin:=i;
end;
end;
writeln;
writeln('MAX[',imax,']:=',mas[imax]);
writeln('MIN[',imin,']:=',mas[imin]);
razn:=mas[imax]+mas[imin];
writeln('Сумма MAX и MIN:=',razn);
end.
Написано by "ТАМБОВСКИЙ ВОЛК. Профессионал".
Знатное говнецо нынче пишут "профессионалы".
http://www.programmersforum.ru/showthread.php?t=98747
+100
<?php
$a=0;
$b=null;
echo $a==$b?1:0; //1
Разрабы пхп троллят.
+70
public class ImportException extends Exception {
public static final int NOT_CRITICAL = 1;
public static final int CRITICAL = 2;
private int criticality = NOT_CRITICAL;
public ImportException(String message) {
this.message = message;
}
/**
* С критичностью
* @param message
* @param criticality
*/
public ImportException(String message, int criticality) {
this.message = message;
this.criticality = criticality;
}
public int getCriticality() {
return criticality;
}
public void setCriticality(int criticality) {
this.criticality = criticality;
}
}
изобретение типа bool
+21
template <int N>
void Ololo ()
{
var
i : integer;
begin
for i := 0 to N-1 do begin
WriteLn(i, ' ');
end;
end;
}
int main ()
{
return 0;
}
Compiling...
Test.cpp
Linking...
Build log was saved at "file://c:\Users\TarasB\Documents\Visual Studio Projects\Test\Debug\BuildLog.htm"
Test - 0 error(s), 0 warning(s)
---------------------- Done ----------------------
Build: 1 succeeded, 0 failed, 0 skipped
MSVS2003
+83
// java.io.FilterOutputStream
public void close() throws IOException {
try {
flush();
} catch (IOException ignored) {
}
out.close();
}
// тестовый код
try (OutputStream os = new BufferedOutputStream(new FileOutputStream("/tmp/little_virtual_fs/1.txt"))) {
byte[] buf = new byte[2028544];
os.write(buf, 0, 2028544); // максимальный размер файла, который влезает на нашу фс
os.write(buf, 0, 5); // и еще немножко
//os.flush();
}
А сейчас, на арене нашего цирка - очередная жабопроблема!
Как думаете, каков результат выполнения тестовой программы?
Запишет 2028549 байт? Хрен там, места маловато.
Выдаст IOException на write()? Хрен там, буферизация.
Выдаст IOException на close()? Хрен там, его сожрала реализация FilterOutputStream.
Результат: файл не дописался, исключения нет.
Решение: всегда дергать flush() перед close() самому или не юзать буферизованный поток.
+166
if (substr(json_encode($row['list']), 0, 1) == '[') {
Такой вот аналог is_array()
+13
typedef std::queue<Msg> Queue;
struct SharedQueue
{
private:
Queue m_queue;
boost::mutex m_mux;
boost::condition_variable m_condvar;
private:
struct is_empty
{
Queue& queue;
is_empty( Queue& q):
queue(q)
{
}
bool operator()() const
{
return !queue.empty();
}
};
public:
void push(const Msg& msg)
{
boost::mutex::scoped_lock lock(m_mux);
m_queue.push( msg);
m_condvar.notify_one();
}
bool try_pop( Msg& msg, Kind kind)
{
boost::system_time const timeout=boost::get_system_time()+ boost::posix_time::milliseconds( 30000);
boost::mutex::scoped_lock lock( m_mux);
if ( m_condvar.timed_wait( lock, timeout, is_empty( m_queue)))
{
if( !m_queue.empty() && m_queue.front().kind == kind)
{
msg = m_queue.front();
m_queue.pop();
return true;
}
}
return false;
}
};
Это ж пипец, дорогие товарищи...
+130
List<KeyValuePair<string, string>> documentList = GetList();
использование списка пар ключ-значение вместо словаря (Dictionary<string, string>)
+80
new