- 1
- 2
// optimization. Should only be used to read it. Never to write it.
extern CGFloat __ccContentScaleFactor;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−195
// optimization. Should only be used to read it. Never to write it.
extern CGFloat __ccContentScaleFactor;
Может быть, я бунтарь!
__ccContentScaleFactor = -666;
+92
type
TForm1 = class(TForm)
Button1: TButton;
Button3: TButton;
ListBox1: TListBox;
Button2: TButton;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TListThread = class(TThread)
protected
procedure Execute; override;
end;
TMyThread = class(TThread)
protected
procedure Execute; override;
end;
TYouThread = class(TThread)
protected
procedure Execute; override;
end;
var
Form1: TForm1;
threadList1: TThreadList;
mythreadRunning, youthreadRunning, listThreadRunning: Boolean;
globalCount: Integer;
listProcess: TListThread; { TListThread is a custom descendant of TThread. }
secondProcess: TMyThread; { TMyThread is a custom descendant of TThread. }
otherSecondProcess: TYouThread; { TMyThread is a custom descendant of TThread. }
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if (mythreadRunning = FALSE) then
begin
mythreadRunning:= TRUE;
secondProcess := TMyThread.Create(True); { Create suspended--secondProcess does not run yet. }
secondProcess.FreeOnTerminate := True; { You do not need to clean up after termination. }
secondProcess.Priority := tpLower; // Set the priority to lower than normal.
secondProcess.Resume; { Now run the thread. }
end
else
MessageDlg('This thread is still running. You are going to hurt yourself!',
mtInformation, [mbOk], 0);
end;
procedure TMyThread.Execute;
var
I: Integer;
myRadio: TRadioButton;
begin
for I := 0 to 20 do
begin
if (Terminated) then
begin
mythreadRunning:= FALSE;
exit;
end;
myRadio:= TRadioButton.Create(Form1);
globalCount:= globalCount + 1;
myRadio.Name:= 'RadioButton' + IntToStr(globalCount);
threadList1.Add(myRadio);
Sleep(1000);
end;
mythreadRunning:= FALSE;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if (listthreadRunning = FALSE) then
begin
listThreadRunning:= TRUE;
listProcess := TListThread.Create(True); { Create suspended--secondProcess does not run yet. }
listProcess.FreeOnTerminate := True; { You do not need to clean up after termination. }
listProcess.Priority := tpLower; // Set the priority to lower than normal.
listProcess.Resume; { Now run the thread. }
end;
end;
procedure TListThread.Execute;
var
I: Integer;
Temp: TControl;
myList: TList;
begin
while(True) do
begin
http://docwiki.embarcadero.com/CodeExamples/XE5/en/TThreadList_%28Delphi%29
Беда, когда примеры пишут психически неполноценные люди. Самое ужасное то, что этот "пример" висит на сайте embarcadero.
+174
/*Caused by: java.lang.StackOverflowError
at com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.characters(SimpleResultTreeImpl.java)
at com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.copy(SimpleResultTreeImpl.java:438)
at com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary.copy(BasisLibrary.java:1317)
at GregorSamsa.replace()
at GregorSamsa.replace()
at GregorSamsa.replace()
at GregorSamsa.replace()
at GregorSamsa.replace()
начали разбираться
*/
/**
* As Gregor Samsa awoke one morning from uneasy dreams he found himself
* transformed in his bed into a gigantic insect. He was lying on his hard,
* as it were armour plated, back, and if he lifted his head a little he
* could see his big, brown belly divided into stiff, arched segments, on
* top of which the bed quilt could hardly keep in position and was about
* to slide off completely. His numerous legs, which were pitifully thin
* compared to the rest of his bulk, waved helplessly before his eyes.
* "What has happened to me?", he thought. It was no dream....
*/
protected final static String DEFAULT_TRANSLET_NAME = "GregorSamsa";
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java
transofm, factory, bug - какие начитанные разработчки, а.
+150
<?php
$subjects = array (
0 =>
array (
'title' => 'ОС Unix',
'teacher' => 'Вася',
'mark' => '3'),
1 =>
array (
'title' => 'Компьютерные сети',
'teacher' => 'Петя',
'mark' =>'4'),
2 =>
array (
'title' => 'Алгоритмы',
'teacher' => 'Коля',
'mark' => '4'),
);?>
<table>
<? foreach ($subjects as $key=>$subject) :
$number = $key+1;
?>
<tr>
<td><?echo $number;?></td>
<td><?echo $subject['title'];?></td>
<td><?echo $subject['teacher'];?></td>
<td><?echo $subject['mark'];?></td>
</tr>
<? endforeach; ?>
</table>
<? var_dump($subject)?>
+3
#define BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(TRAITS_PREFIX, TYPEDEF_TO_FIND) \
template <class T>\
struct TRAITS_PREFIX##_bool\
{\
template<bool Add>\
struct two_or_three {one _[2 + Add];};\
template <class U> static one test(...);\
template <class U> static two_or_three<U::TYPEDEF_TO_FIND> test (int);\
static const std::size_t value = sizeof(test<T>(0));\
};\
\
template <class T>\
struct TRAITS_PREFIX##_bool_is_true\
{\
static const bool value = TRAITS_PREFIX##_bool<T>::value > sizeof(one)*2;\
};\
//
Ну тут как бы все просто и понятно. Но зачем заканчивают макрос кодом
\
//
?
+133
panel1.Visible = checkBoxCCF.Checked;
panel2.Visible = checkBoxReliabilty.Checked;
panel3.Visible = checkBoxRisk.Checked;
panel4.Visible = checkBoxSaftey.Checked;
panel5.Visible = checkBoxSensitivity.Checked;
panel6.Visible = checkBoxThroughput.Checked;
panel7.Visible = checkBoxUncertainity.Checked;
Почему половина переменных нормальные, половина нет? Логика некоторых погромистов зашкаливает...
−85
c1 = true
c2 = true
c3 = true
c4 = true
c5 = true
c6 = true
c7 = true
c8 = true
c9 = true
c10 = true
c11 = true
c12 = true
c13 = true
next = true
function goForward()
c1 = c2
c2 = c3
c3 = c4
c4 = c5
c5 = c6
c6 = c7
c7 = c8
c8 = c9
c9 = c10
c10 = c11
c11 = c12
c12 = c13
c13 = next
end
Немножко Lua-кода от геймдизайнера.
+68
class CircuitBreaker
{
boolean broken = false;
CircuitBreaker() {}
private void breakCircuit()
{
this.broken = true;
}
private boolean isBroken()
{
return this.broken;
}
}
private boolean writeAssetsToDisk()
{
CircuitBreaker breaker = new CircuitBreaker();
writeBase64EncodedAssetToDisk(breaker, "...", getPath(...));
writeBase64EncodedAssetToDisk(breaker, "...", getPath(...));
writeBase64EncodedAssetToDisk(breaker, "...", getPath(...));
writeBase64EncodedAssetToDisk(breaker, "...", getPath(...));
return !breaker.isBroken();
}
private void writeBase64EncodedAssetToDisk(CircuitBreaker breaker, String base64String, String filename)
{
if (breaker.isBroken()) {
return;
}
...
try
{
...
}
catch (IOException e)
{
breaker.breakCircuit(); return;
}
...
}
Используй исключения, Люк. Фрагмент из Amazon Mobile Ads SDK.
+154
function box_navigation($gc, $num, $id, $function, $act){
global $tpl, $page;
$gcount = $gc;
$cnt = $num;
$items_count = $cnt;
$items_per_page = $gcount;
$page_refers_per_page = 5;
$pages = '';
$pages_count = ( ( $items_count % $items_per_page != 0 ) ) ? floor( $items_count / $items_per_page ) + 1 : floor( $items_count / $items_per_page );
$start_page = ( $page - $page_refers_per_page <= 0 ) ? 1 : $page - $page_refers_per_page + 1;
$page_refers_per_page_count = ( ( $page - $page_refers_per_page < 0 ) ? $page : $page_refers_per_page ) + ( ( $page + $page_refers_per_page > $pages_count ) ? ( $pages_count - $page ) : $page_refers_per_page - 1 );
if(!$act)
$act = "''";
else
$act = "'{$act}'";
if($page > 1)
$pages .= '<a href="" onClick="'.$function.'('.$id.', '.($page-1).', '.$act.'); return false">«</a>';
else
$pages .= '';
if ( $start_page > 1 ) {
$pages .= '<a href="" onClick="'.$function.'('.$id.', 1, '.$act.'); return false">1</a>';
$pages .= '<a href="" onClick="'.$function.'('.$id.', '.($start_page-1).', '.$act.'); return false">...</a>';
}
for ( $index = -1; ++$index <= $page_refers_per_page_count-1; ) {
if ( $index + $start_page == $page )
$pages .= '<span>' . ( $start_page + $index ) . '</span>';
else
$pages .= '<a href="" onClick="'.$function.'('.$id.', '.($start_page+$index).', '.$act.'); return false">'.($start_page+$index).'</a>';
}
if ( $page + $page_refers_per_page <= $pages_count ) {
$pages .= '<a href="" onClick="'.$function.'('.$id.', '.($start_page + $page_refers_per_page_count).', '.$act.'); return false">...</a>';
$pages .= '<a href="" onClick="'.$function.'('.$id.', '.$pages_count.', '.$act.'); return false">'.$pages_count.'</a>';
}
$resif = $cnt/$gcount;
if(ceil($resif) == $page)
$pages .= '';
else
$pages .= '<a href="/" onClick="'.$function.'('.$id.', '.($page+1).', '.$act.'); return false">»</a>';
if ( $pages_count <= 1 )
$pages = '';
$tpl_2 = new mozg_template();
$tpl_2->dir = TEMPLATE_DIR;
$tpl_2->load_template('nav.tpl');
$tpl_2->set('{pages}', $pages);
$tpl_2->compile('content');
$tpl_2->clear();
$tpl->result['content'] .= $tpl_2->result['content'];
}
дали проект чтобы разобрался)
+11
int FCEUI_SetCheat(....)
{
...
if((t=(char *)realloc(next->name,strlen(name+1))))
...
}
А пасиму оно на 2 байта меньше выделяет, насяльника?
http://www.viva64.com/ru/examples/V518/