- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
public class Test {
public static final int a;
static {
System.out.println(Main.a);
a = 42;
System.out.println(Main.a);
}
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+72
public class Test {
public static final int a;
static {
System.out.println(Main.a);
a = 42;
System.out.println(Main.a);
}
}
javac такой javac...
Так видит проблему: http://ideone.com/jhPN5X
А вот так - нет: http://ideone.com/qAMIvH
+24
template <typename IdType, class Tag>
class id {
public:
typedef IdType value_type;
explicit id(value_type val)
: value(val)
{}
bool operator==(id rhs)
{
return rhs.value == value;
}
bool operator!=(id rhs)
{
return rhs.value != value;
}
value_type value;
};
#define HASKELL_NEWTYPE(type_name, value_type) struct __##type_name##_tag__ {}; \
typedef ::id<value_type, __##type_name##_tag__> type_name
Когда newtype нет, но очень хочется.
http://ideone.com/VRu56j
Простите за синтетику
+138
$sql_ex = array();
if(isset($this->request->get["id"]) && $this->request->get["id"] == '5')
$sql_ex[] = " `ex`.`num` = 5 ";
else
$sql_ex[] = " `ex`.`num` != 5 ";
if(isset($this->request->get["id"]) && $this->request->get["id"] == '7')
$sql_ex[] = " `ex`.`num` = 7 ";
else
$sql_ex[] = " `ex`.`num` != 7 ";
if(isset($this->request->get["id"]) && $this->request->get["id"] == '4')
$sql_ex[] = " `ex`.`num` = 4 ";
else
$sql_ex[] = " `ex`.`num` != 4 ";
if(isset($this->request->get["id"]) && $this->request->get["id"] == '10')
$sql_ex[] = " `ex`.`num` = 10 ";
else
$sql_ex[] = " `ex`.`num` != 10 ";
if(isset($this->request->get["id"]) && $this->request->get["id"] == '11')
$sql_ex[] = " `ex`.`num` = 11 ";
else
$sql_ex[] = " `ex`.`num` != 11 ";
if(isset($this->request->get["id"]) && $this->request->get["id"] == '14')
$sql_ex[] = " `ex`.`num` = 14 ";
else
$sql_ex[] = " `ex`.`num` != 14 ";
if(isset($this->request->get["id"]) && $this->request->get["id"] == '19')
$sql_ex[] = " `ex`.`num` = 19 ";
else
$sql_ex[] = " `ex`.`num` != 19 ";
if(isset($this->request->get["id"]) && $this->request->get["id"] == '20')
$sql_ex[] = " `ex`.`num` = 20 ";
else
$sql_ex[] = " `ex`.`num` != 20 ";
if(isset($this->request->get["id"]) && $this->request->get["id"] == '21')
$sql_ex[] = " `ex`.`num` = 21 ";
else
$sql_ex[] = " `ex`.`num` != 21 ";
if(isset($this->request->get["id"]) && $this->request->get["id"] == '13')
$sql_ex[] = " `ex`.`num` = 13 ";
else
$sql_ex[] = " `ex`.`num` != 13 ";
if(isset($this->request->get["id"]) && $this->request->get["id"] == '12')
$sql_ex[] = " `ex`.`num` = 12 ";
else
$sql_ex[] = " `ex`.`num` != 12 ";
if(isset($this->request->get["id"]) && $this->request->get["id"] == '6')
$sql_ex[] = " `ex`.`num` = 6 ";
else
$sql_ex[] = " `ex`.`num` != 6 ";
if(isset($this->request->get["id"]) && $this->request->get["id"] == '17')
$sql_ex[] = " `ex`.`num` = 17 ";
else
$sql_ex[] = " `ex`.`num` != 17 ";
if(isset($this->request->get["id"]) && $this->request->get["id"] == '23')
$sql_ex[] = " `ex`.`num` = 23 ";
else
$sql_ex[] = " `ex`.`num` != 23 ";
if(isset($this->request->get["id"]) && $this->request->get["id"] == '16')
$sql_ex[] = " `ex`.`num` = 16 ";
else
$sql_ex[] = " `ex`.`num` != 16 ";
$sql_extra = '';
if (!empty($sql_ex)) $sql_extra = ' AND '.implode(" AND ", $sql_ex);
В начале нужно было одно условие, потом еще и еще и ...
+9
y=fopen(lex,"w+");
fclose(y);
FILE *r=fopen(result,"w+");
fclose(r);
FILE *k=fopen("pryklad.obj","w+");
fclose(k);
+116
<style type="text/css">
header
{
display: block;
}
header
{
clear: both;
height: 160px;
width: 100%;
background: url(/images/imges.jpg) no-repeat;
-moz-background-size: 100%;
-webkit-background-size: 100%;
-o-background-size: 100%;
background-size: 100% 100%;
background-position: center center;
}
.block1
{
height: 160px;
width: 20%;
}
.block2
{
height: 160px;
width: 15%;
}
.block3
{
height: 160px;
width: 30%;
}
.block4
{
height: 160px;
width: 15%;
}
.block5
{
height: 160px;
width: 20%;
}
table
{
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
</style>
<header>
<table>
<tr>
<td class="block1" onClick="document.location='/' " onmouseover ="this.style.cursor='pointer' " title= "Главная">
</td>
<td class="block2">
</td>
<td class="block3">
</td>
<td class="block4">
</td>
<td class="block5" onClick="document.location='/script/enter.php' " onmouseover ="this.style.cursor='pointer' " title= "Вход">
</td>
</tr>
</table>
</header>
Найдено на просторах интернета: обычная шапка сайта, ничего лишнего.
Код был нечитаемым - форматировал я. CSS, касаемо использованных тегов, вся.
+79
public class StringToObjectMap extends HashMap<String, Object> {
public StringToObjectMap(Map<? extends String, ? extends Object> map)
Нет слов выразить мою печаль.
−88
// поднимаем и опускаем панель голосования при входящем вызове
for (ASSlideView* slideView in self.view.subviews)
if ([slideView isKindOfClass:[ASSlideView class]])
for (UIScrollView* scroll in slideView.subviews)
if ([scroll isKindOfClass:[UIScrollView class]])
for (UIView* view in scroll.subviews)
if ([view isKindOfClass:[UIView class]])
for (KVRateView* rateView in view.subviews)
if ([rateView isKindOfClass:[KVRateView class]]){
[rateView setFrame:CGRectMake(rateView.frame.origin.x, [[UIScreen mainScreen] bounds].size.height - 140 - [[UIApplication sharedApplication]statusBarFrame].size.height, rateView.frame.size.width, rateView.frame.size.height)];
break;
}
No comments
+110
<img border="0" width="476" height="179" src="file:///C|/Users/jy88h0/AppData/Roaming/Macromedia/Dreamweaver /eCustomer/iq/images/AI289.jpg" alt="Image of a properly addressed mail piece">
http://faq.usps.com/eCustomer/iq/usps/request.do?create=kb%3AUSPSFAQ&view%28%2 9=c[c_usps0910]
+127
/* Групповые операции с обращениями */
public function issuegroupopsAction() {
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$operation = $this->_request->getPost('operation');
define('RTF_SYMBOL_PAGE_BREAK', '\page');
try {
// Валидация
if(!in_array($operation, array('print-letters', 'print-work-order'))) {
throw new Exception('Неверная операция');
}
$issue_numbers = explode(';', (string)$_POST['issues']);
if(!count($issue_numbers)) {
throw new Exception('Не выбрано ни одного обращения.');
}
// Вычитка указанных обращений
$filter = new Type_Issue_Filter(array('issue_number' => $issue_numbers));
$paginator = new Type_Paginator;
$paginator->items_per_page = 40;
$issues = services::Issue()->records($this->user->sessionId, $filter, array('executant', 'address'), 'number', $paginator);
if(!count($issues->items)) {
throw new Exception('Выбранные обращения не найдены.');
}
$templateMaker = new Prodom_Rtf_TemplateMaker;
$templatesDir = dirname(__FILE__).'/templates/';
$outputFiles = array();
// Вид операции с группой обращений
switch($operation) {
case 'print-letters': {
// Сформирвать письма
$templateMaker->readTemplatesFromRtfFile($templatesDir.'templates.rtf');
$outputFiles = array('executants_%u.rtf' => array('issue2', 'letter1'), 'declarant_%u.rtf' => array('letter2'));
break;
}
case 'print-work-order': {
// Печать заказ-нарядов
if(!is_null($this->user->organization->issue_form_template)) {
// Если для организации определен свой собственный шаблон
$templateMaker->readTemplatesFromRtfFile($templatesDir.$this->user->organization->issue_form_template);
} else {
// Если шаблон явно не определен
$templateMaker->readTemplatesFromRtfFile($templatesDir.'templates.rtf');
}
$outputFiles = array('issue_%u.rtf' => array('issue1'));
break;
}
}
$toworkIssueIds = array();
$outputs = array_fill_keys(array_keys($outputFiles), null);
// Перебор выбранных пользователем обращений
foreach($issues->items as $issue) {
// Переводим все новые обращения в статус "В работе"
$issue_new_statuses = array(ISSUE_STATUS_NEW, ISSUE_STATUS_CONFIRMED);
if(($operation == 'print-work-order') && in_array($issue->status_id, $issue_new_statuses) && ($issue->org_executor_id == $this->user->organization->id)) {
$toworkIssueIds[] = $issue->id;
}
// Подготовка полей обращения для печати на формах
$fields = $this->getIssuePrintFields($issue);
foreach($outputFiles as $fileName => $needTemplates) {
foreach($needTemplates as $template_code) {
$out = $templateMaker->getAppliedTemplate($template_code, $fields);
$outputs[$fileName] .= ($outputs[$fileName] ? RTF_SYMBOL_PAGE_BREAK : null) . $out;
}
}
}
if(count($toworkIssueIds)) {
$resp = services::Issue()->changeStatusMultiple($this->user->sessionId, $toworkIssueIds, ISSUE_STATUS_INWORK, null, null, null);
}
// Если на выходе только один файл, отправляем rtf
if(count($outputs) == 1) {
foreach($outputs as $fileName => $fileBody) {
// Генерация случайного имени файла
$fileName = str_replace('%u', substr(md5(implode('_', $issue_numbers)), 0, 7), $fileName);
// Вывод файла пользователю
header('Content-type: application/rtf');
header("Content-Disposition: attachment; filename={$fileName}");
echo $templateMaker->getHeader().$fileBody.$templateMaker->getFooter();
}
} else {
// Eсли на выходе больше одного файла, пакуем их архивом
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=issues.zip");
header("Content-Description: Files of an applicant");
// Создаем ZIP архив
$zip = new ZipFile();
foreach($outputs as $fileName => $fileBody) {
// Генерация случайного имени файла
$fileName = str_replace('%u', substr(md5(implode('_', $issue_numbers)), 0, 7), $fileName);
// Вывод файла пользователю в браузер
$fileBody = $templateMaker->getHeader().$fileBody.$templateMaker->getFooter();
$zip->addFile($fileBody, $fileName);
}
echo $zip->file();
}
}
catch(Exception $ex) {
die($ex->getMessage());
}
}
Функция распечатки документов с отчетами по выбранным обращениям
+68
@Override
public void execute() {
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
for (ClientListener listener : listeners) {
listener.disconnected(this);
}
}