- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
$pay_id = 0;
$produce_id = 0;
$user_id = 0;
$add_time = 0;
$pr=substr_count($produce_id, ',');
$pa=substr_count($pay_id, ',');
$pu=substr_count($user_id, ',');
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+161
$pay_id = 0;
$produce_id = 0;
$user_id = 0;
$add_time = 0;
$pr=substr_count($produce_id, ',');
$pa=substr_count($pay_id, ',');
$pu=substr_count($user_id, ',');
+76
long[] times = new long[9];
times[0] = System.currentTimeMillis();
initPsrList();
times[1] = System.currentTimeMillis();
initPsrHierarchy();
times[2] = System.currentTimeMillis();
initPsrCheckList()
times[3] = System.currentTimeMillis();
initTranslationTables();
times[4] = System.currentTimeMillis();
initTranslationInfo()
times[5] = System.currentTimeMillis();
initVoltage();
times[6] = System.currentTimeMillis();
initElectroMetterPrecision();
times[7] = System.currentTimeMillis();
initMeasTransformers();
times[8] = System.currentTimeMillis();
long diff;
System.out.println("\n\n\n\n******************************************************************");
diff = times[1] - times[0];
System.out.println("-- initPsrList() = " + diff + "ms");
diff = times[2] - times[1];
System.out.println("-- initPsrHierarchy() = " + diff + "ms");
diff = times[3] - times[2];
System.out.println("-- initPsrCheckList() = " + diff + "ms");
diff = times[4] - times[3];
System.out.println("-- initTranslationTables() = " + diff + "ms");
diff = times[5] - times[4];
System.out.println("-- initTranslationInfo() = " + diff + "ms");
diff = times[6] - times[5];
System.out.println("-- initVoltage() = " + diff + "ms");
diff = times[7] - times[6];
System.out.println("-- initElectroMettersPrecision() = " + diff + "ms");
diff = times[8] - times[7];
System.out.println("-- initMeasTransformers() = " + diff + "ms");
diff = times[8] - times[0];
System.out.println("total = " + diff + "ms");
System.out.println("\n******************************************************************\n\n\n\n ");
Код подготовки отображаемой страницы на сервере.
+130
//Сам скрипт
#!/bin/sh
cat /opt/chtag/truechars > /opt/chtag/tf
printf " $1@" >> /opt/chtag/tf
mp3info -p "%t" "$1">> /opt/chtag/tf
/opt/chtag/a.out < /opt/chtag/tf > /opt/chtag/t3
sh /opt/chtag/t3
//truechars
абвгдеёжзийклмнопрстуфхцчшщьыъэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЬЫЪЭЮЯ
//Исходники a.out
#include <iostream>
using namespace std;
int main()
{
int i,j;
string name,s,as="",truec;
cin >> truec;
cin >> s;
while(!cin.eof()) {as+=" "+s; cin >> s;}
name=as.substr(1,as.find("@",0)-1);
as=as.substr(as.find("'")+1);
for(i=0; i<truec.size(); i++)
{
if(as.find(truec[i],0)<truec.size())
{
cout << "printf \"" << name << " OK!\\n\"" << endl;
return 0;
}
}
cout << "printf \""<<name<<"\\'s tags will be changed...\\nBefore\\n\";\n"
"mp3info \""<< name << "\";\n"
"mid3iconv -e CP1251 -d --remove-v1 \""<< name << "\";\n"
"printf \"Now\\n\"\nmp3info \"" << name << "\""
<< endl;
return 0;
}
Вообще должен кодировку в русских тэгах в mp3 нормальной делать...
+169
<div class="filterPanel" style="width:250px;">
<div class="filterComboBoxCaption">Диапазон времени:</div>
с: <select name="timeBeginFl" id="timeBeginFlId" style="width:80px;" onChange="javascript:resetTimes();">
<option value="07:00:00" {if $object.timeBeginFl=="07:00:00"}selected{/if}>07:00</option>
<option value="07:30:00" {if $object.timeBeginFl=="07:30:00"}selected{/if}>07:30</option>
<option value="08:00:00" {if $object.timeBeginFl=="08:00:00"}selected{/if}>08:00</option>
<option value="08:30:00" {if $object.timeBeginFl=="08:30:00"}selected{/if}>08:30</option>
<!-- ещё N таких же строчек -->
<option value="05:00:00" {if $object.timeBeginFl=="05:00:00"}selected{/if}>05:00</option>
<option value="05:30:00" {if $object.timeBeginFl=="05:30:00"}selected{/if}>05:30</option>
<option value="06:00:00" {if $object.timeBeginFl=="06:00:00"}selected{/if}>06:00</option>
<option value="06:30:00" {if $object.timeBeginFl=="06:30:00"}selected{/if}>06:30</option>
</select>
по: <select name="timeEndFl" id="timeEndFlId" style="width:80px;">
<option value="07:30:00" {if $object.timeEndFl=="07:30:00"}selected{/if}>07:30</option>
<option value="08:00:00" {if $object.timeEndFl=="08:00:00"}selected{/if}>08:00</option>
<option value="08:30:00" {if $object.timeEndFl=="08:30:00"}selected{/if}>08:30</option>
<option value="09:00:00" {if $object.timeEndFl=="09:00:00"}selected{/if}>09:00</option>
<!-- ещё N таких же строчек -->
<option value="05:00:00" {if $object.timeEndFl=="05:00:00"}selected{/if}>05:00</option>
<option value="05:30:00" {if $object.timeEndFl=="05:30:00"}selected{/if}>05:30</option>
<option value="06:00:00" {if $object.timeEndFl=="06:00:00"}selected{/if}>06:00</option>
<option value="06:30:00" {if $object.timeEndFl=="06:30:00"}selected{/if}>06:30</option>
</select>
</div>
Из шаблонов под Smarty.
−88
frmt = ("ISSUE" == "ISSUE") ? "@m-@yy" : "@dd-@m";
frmt = ("ISSUE" == "ISSUE") ? "@m-@yy" : "@dd-@m";
И не дают мне уснуть эти 2 строки. Наверное 2, чтобы наверняка, но вот условие я даже не знаю как интерпретировать Х_х
+154.8
#include <avr/interrupt.h>
#include <avr/io.h>
#include <stdio.h>
static void avr_init(void);
void uart_putchar(char value);
unsigned char read_adc(unsigned char adc_input);
unsigned char adc_enable;
ISR(SIG_UART_RECV)
{
unsigned char tmp;
tmp=UDR;
if (tmp=='1') adc_enable=1;
else adc_enable=0;
}
int main(void)
{
avr_init();
sei();
uart_putchar('A');
for(;;)
{
if(adc_enable)
{
uart_putchar(read_adc(0x00));
adc_enable = 0;
}
}
return(0);
}
static void avr_init(void)
{
PORTB=0b00000000;
DDRB=0b00001111;
PORTD=0b00111100;
DDRD=0b11000011;
// Baud Rate: 57600
// Character Size: 8-bit
// Mode: Asynchronous
// Parity: Disabled
// Stop Bit: 1-bit
// Multi-processor Communication
UBRRL = 0x0c;
UBRRH = 0x00;
UCSRA = 0x01;
UCSRC = 0x86;
UCSRB = 0xd8;
ADMUX=0x60;
ADCSRA=0xA6;
SFIOR&=0x0F;
SFIOR|=0x10;
return;
}
void uart_putchar(char value)
{
loop_until_bit_is_set(UCSRA, UDRE);
UDR = value;
return;
}
unsigned char read_adc(unsigned char adc_input)
{
ADMUX=adc_input|0x60;
// Start the AD conversion
ADCSRA|=0x40;
// Wait for the AD conversion to complete
while ((ADCSRA & 0x10)==0);
ADCSRA|=0x10;
return ADCH;
}
+116.4
string text = MyReader[2].ToString();
tt = new TableRow();
string css_clss = (text == "ИТОГО") ? "gr1" : "gr2";
int lvl = Convert.ToInt32(MyReader[1].ToString());
tt.CssClass = css_clss;
ASP.NET
//Это просто в ТОП 1. Выхватывать уровень группировки SQL по слову ИТОГО, учитывая что слово Итого может изменится и процедура возвращает уровень. lvl = 5 это ИТОГОВЫЙ уровень
−869.4
select ST1,lower(naim||' ( '||nam||' )') from ST_REAL, (select nvl(d.k_dor, g.k_admi+200) kod, decode(:lng,'uk',n_strnus/*ua_country*/,'ru',N_Strnr/*ru*_country*/) nam from (select relsa.k_admi,N_Strnr,n_strnus from d_adm@psv_nsi relsa, d_strn@psv_nsi strana/*, arm_spr.gosdor@uzc1 doroga*/ where relsa.k_strn=strana.k_strn)
+144.8
bool PathProcessor::Process(PPProcess *pProcess)
{
std::vector<int> viRoute; int nRouteCount; bool bRetVal = false;
for (int i = 0; i < m_viExcludeStop.size(); i++){
if (m_viExcludeStop[i] == pProcess->nStartStopId) return false;
}
int bbb = 0;
if (pProcess->nRouteId < 0){
viRoute = GetRoutesID(pProcess->nStartStopId);
nRouteCount = viRoute.size();
if (nRouteCount <= 0) return false;
}
else{
viRoute = GetRoutesID(pProcess->nStartStopId, pProcess->nRouteId);
nRouteCount = viRoute.size();
if (nRouteCount <= 0) return false;
nRouteCount = 1;
}
for (int i = 0; i < nRouteCount; i++){
RouteDataInfo rdCur = GetRoute(viRoute[i]);
pProcess->nRoutePartId = rdCur.nId;
PPResult *pRes;
bool bCurRetVal = false;
if (pProcess->bIsFirstStop == true){
pRes = new PPResult();
pRes->bFinished = false;
pRes->nFirstStopId = pProcess->nFirstId;
pRes->nLastStopId = -1;
pRes->nRouteId = rdCur.nRouteId;
m_viResult.push_back(pRes);
}
else pRes = pProcess->pLastResult;
if (pRes != NULL){
PartInfo piTemp(rdCur.nId, rdCur.nLastStopId);
pRes->viPartsId.push_back(piTemp);
}
if (IsEndStop(rdCur.nLastStopId) == true){
if (pRes != NULL){
pRes->bFinished = true;
pRes->nLastStopId = rdCur.nLastStopId;
}
bRetVal = true; bCurRetVal = true;
}
if ((pProcess->IsStopExist(rdCur.nLastStopId) == false) && (bCurRetVal == false)){
if ((pProcess->nCurStep < m_nMaxStep) && (pProcess->nRouteId >= 0)){
PPProcess ppProc;
ppProc.nCurStep = pProcess->nCurStep;
ppProc.nRouteId = pProcess->nRouteId;
ppProc.nStartStopId = rdCur.nLastStopId;
ppProc.pPrevProc = pProcess;
ppProc.bIsFirstStop = false;
ppProc.nFirstId = pProcess->nFirstId;
if (pProcess->pLastResult == NULL) ppProc.pLastResult = pRes;
else ppProc.pLastResult = pProcess->pLastResult;
if (Process(&ppProc) == true) bRetVal = true;
}
else if (pProcess->nCurStep < m_nMaxStep){
PPProcess ppProc;
ppProc.nCurStep = pProcess->nCurStep;
ppProc.nRouteId = rdCur.nRouteId;
ppProc.nStartStopId = rdCur.nLastStopId;
ppProc.pPrevProc = pProcess;
ppProc.bIsFirstStop = false;
ppProc.nFirstId = pProcess->nFirstId;
if (pProcess->pLastResult == NULL) ppProc.pLastResult = pRes;
else ppProc.pLastResult = pProcess->pLastResult;
if (Process(&ppProc) == true) bRetVal = true;
}
if (pProcess->nCurStep+1 < m_nMaxStep){
PPProcess ppProc2;
ppProc2.nCurStep = pProcess->nCurStep+1;
ppProc2.nRouteId = -1;
ppProc2.nStartStopId = rdCur.nLastStopId;
ppProc2.pPrevProc = pProcess;
ppProc2.bIsFirstStop = true;
ppProc2.nFirstId = rdCur.nLastStopId;
ppProc2.pLastResult = NULL;
if (Process(&ppProc2) == true){
PPResult *pRes2;
pRes2 = new PPResult();
pRes2->bFinished = true;
pRes2->nFirstStopId = pRes->nFirstStopId;
pRes2->nLastStopId = rdCur.nLastStopId;
pRes2->nRouteId = pRes->nRouteId;
PPProcess *pProc = pProcess;
while (pProc != NULL){
PartInfo piTemp(pProc->nRoutePartId, pProc->nStartStopId);
pRes2->viPartsId.push_back(piTemp);
pProc = pProc->pPrevProc;
}
m_viResult.push_back(pRes2); bRetVal = true;
}
}
}
}
if ((bRetVal == false) && (pProcess->nRouteId < 0))
m_viExcludeStop.push_back(pProcess->nStartStopId);
return bRetVal;
}
Когда-то давно писал алгоритм поиска маршрутов, теперь удевляюсь как это все работает да еще и не виснет
+166.2
<?
$fileSelect = array();
$sql = 'SELECT * FROM bd_file';
$stmt = db_prepare($sql, $file); $res = db_query($stmt);
while($row = db_fetch_row(res))
{
if (!is_file(filefolder.'/'.$row[название_файла]))) {
$fileSelect[$file] = $file;
}
}
unset($fileSelect);
?>
В добавок к #2929.
Этим образом идет проверка существование документов в панели администратора