- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
// ...
// xcrement - (in|de)crement
// ...
bool parse( . . . , int xcrement, . . . )
{
...
while ( ... )
{
...
index += xcrement;
}
...
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+157
// ...
// xcrement - (in|de)crement
// ...
bool parse( . . . , int xcrement, . . . )
{
...
while ( ... )
{
...
index += xcrement;
}
...
}
+81
Network notwork = null;
Ну и естественно, что нихрена не работает...
+74
public void write(byte[] bytesToSend) {
// System.out.println("Write begin.");
try {
socket.setSoTimeout(10000);
packageID = 0;
// Add bytes to send
saveBytesToPackeges(bytesToSend);
// Begin new Thread to be sure it was delivered
mySendChecker = new SendChecker();
Thread myThread = new Thread(mySendChecker);
myThread.start();
byte[] buf2 = new byte[50];
// Sending number of packeges
byte[] buf = bytesFromInt(numberOfPackages);
for (int i = 0; i < 4; i++) {
buf2[i] = buf[i];
}
packageID = -2;
buf = packetFromBytes(buf2, sizeOfPackage - 4);
DatagramPacket myPacket = new DatagramPacket(buf, buf.length,
addressToSendTo, portToSendTo);
socket.send(myPacket);
mySendChecker.setPacket(-2, myPacket);
// recieve answer
socket.receive(myPacket);
buf = myPacket.getData();
mySendChecker.removePacket(-2);
// send delieverer
buf = packetFromBytes(buf2, sizeOfPackage - 4);
socket.send(myPacket);
// starting to send data
for (int i = 0; i < numberOfPackages; i++) {
myPacket = new DatagramPacket(bytesToSendSave[i],
bytesToSendSave[i].length, addressToSendTo,
portToSendTo);
socket.send(myPacket);
mySendChecker.setPacket(i, myPacket);
}
// start to recieve answers
int numberOfPackegeRecieved = 0;
while (true) {
buf = new byte[8];
if (mySendChecker.isEmpty()) {
break;
}
myPacket = new DatagramPacket(buf, buf.length);
socket.receive(myPacket);
buf = myPacket.getData();
numberOfPackegeRecieved = intFromBytes(buf, 4);
if (-3 != intFromBytes(buf, 4)) {
continue;
}
numberOfPackegeRecieved = intFromBytes(buf, 0);
mySendChecker.removePacket(numberOfPackegeRecieved);
myPacket = new DatagramPacket(buf, buf.length, addressToSendTo,
portToSendTo);
socket.send(myPacket);
}
buf = bytesFromInt(-5);
myPacket = new DatagramPacket(buf, buf.length, addressToSendTo,
portToSendTo);
socket.send(myPacket);
mySendChecker.setPacket(-5, myPacket);
// System.out.println("WRITE Sending -5");
while (true) {
buf = new byte[4];
myPacket = new DatagramPacket(buf, buf.length);
socket.receive(myPacket);
buf = myPacket.getData();
if (-5 == intFromBytes(buf, 0)) {
// System.out.println("WRITE recieved -5");
break;
}
}
mySendChecker.end();
socket.setSoTimeout(100);
while (true) {
try {
socket.receive(myPacket);
} catch (SocketTimeoutException e) {
break;
}
}
socket.setSoTimeout(0);
// System.out.println("Write end.");
... TO BE CONTINUED ...
Лучшая реализация потокового протокола поверх UDP среди студентов. Остальное в таком же стиле.
+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 это ИТОГОВЫЙ уровень