- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
class Massiv{
int *a;
public:
void Sozd(int k);
};
void Massiv::Sozd(int k)
{
a=(int *) malloc (sizeof(int) * (k+3));
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+162
class Massiv{
int *a;
public:
void Sozd(int k);
};
void Massiv::Sozd(int k)
{
a=(int *) malloc (sizeof(int) * (k+3));
}
У меня будет свой конструктор!
+165
<?php
define('URL', 'http://shop.megafonnw.ru/spb/?pageid=5&subpageid=5&rnd=18');
$fp = fopen('URL', 'r');
$fpt = fopen('script.txt', 'r+');
$fpn = fopen('new.txt', 'r+');
$cont = file_get_contents(URL);
$man = substr($cont, 14900, 7636);
$script = file_get_contents('script.txt');
$new = file_get_contents('new.txt');
if($script == "") {
fwrite($fpt, $man);
print "script zapisan!";
}else {
if($script == $new) {
$ret = fwrite($fpn, $man);
print $ret."<br/>";
$sost = "No changed!";
ftruncate($fpn, 0);
}else {
$ret = fwrite($fpn, $man);
print $ret."<br/>";
$sost = "Text has been changed!";
ftruncate($fpt, 0);
$ret2 = fwrite($fpt, $new);
print $ret2."<br/>";
print strlen($new);
ftruncate($fpn, 0);
}
print "script ne zapisan";
}
print "\n\t<br/>".$sost;
fclose($fpn);
fclose($fpt);
fclose($fp);
?>
особо порадовала строка substr($cont, 14900, 7636);
+80
private String nextUTF8Character() throws IOException, CharacterCodingException
{
int iCodePoint = 0;
int byte1, byte2, byte3, byte4;
byte1 = is.read();
if (byte1 == -1)
return null;
// проверяем является ли первый бит нулевым
if ((byte1 & 0x80) == 0)
{
// один байт
iCodePoint = byte1 & 0x7F;
return new String(Character.toChars(iCodePoint));
}
byte2 = is.read();
if (byte2 == -1)
return null;
if ((byte1 & 0xE0) == 0xC0 && (byte2 & 0xC0) == 0x80)
{
// два байта
iCodePoint = ((byte1 & 0x1F) << 6) | (byte2 & 0x3F);
if (iCodePoint > 0x7F)
return new String(Character.toChars(iCodePoint));
else
throw new CharacterCodingException();
}
byte3 = is.read();
if (byte3 == -1)
return null;
if ((byte1 & 0xF0) == 0xE0 && (byte2 & 0xC0) == 0x80 && (byte3 & 0xC0) == 0x80)
{
// три байта
iCodePoint = ((byte1 & 0x0F) << 12) | ((byte2 & 0x3F) << 6) | (byte3 & 0x3F);
if (iCodePoint > 0x7FF)
return new String(Character.toChars(iCodePoint));
else
throw new CharacterCodingException();
}
byte4 = is.read();
if (byte4 == -1)
return null;
if ((byte1 & 0xF8) == 0xF0 && (byte2 & 0xC0) == 0x80 &&
(byte3 & 0xC0) == 0x80 && (byte4 & 0xC0) == 0x80)
{
// четыре байта
iCodePoint = ((byte1 & 0x07) << 18) | ((byte2 & 0x3F) << 12) |
((byte3 & 0x3F) << 6) | (byte4 & 0x3F);
if (iCodePoint > 0x0FFFF)
return new String(Character.toChars(iCodePoint));
else
throw new CharacterCodingException();
}
throw new CharacterCodingException();
}
Мегаоптимизированный код для получения букафф в кодироффке UTFфф-8
По данным профилировщика именно этот фрагмент самый тормозной в моей сетевой проге
+162
/* Присваивание объекту свойств.
* o изменяемый объект.
* Max Pro.
*/
function Font11(o)
{
if(bNavigator==true&&iNavigator!=2)
{
o.style.fontFamily="sans-serif";
o.style.fontSize="11pt";
}
} //end Font11(o)
мощно, сурово, независимо
+77
int min = 10;
int max = 4095;
for (SomeClass cc : someList) {
if ( cc.getMinVlan( ) != null ) min = cc.getMinVlan( ) > min ? cc.getMinVlan( ) : min;
if ( cc.getMaxVlan( ) != null ) max = cc.getMaxVlan( ) < max ? cc.getMaxVlan( ) : max;
}
Таким образом суровые калифорнийские мужыки ищут большой диапазон, куда можно поместить кучку маленьких диапазончиков.
+75
private static NavigableSet<Integer> availableVlans = populate( );
private static NavigableSet<Integer> populate( ) {
NavigableSet<Integer> list = new ConcurrentSkipListSet<Integer>( );
for ( int i = 1; i < 4095; i++ )
list.add( i );
return list;
}
public static void trim( int min, int max ) {
NavigableSet<Integer> newVlanList = Sets.newTreeSet( );
for ( int i = min; i < max; i++ )
newVlanList.add( i );
newVlanList.removeAll( availableVlans );
availableVlans.removeAll( availableVlans.headSet( min ) );
availableVlans.removeAll( availableVlans.tailSet( max ) );
for ( int i = min; i < max; i++ ) {
if ( !newVlanList.contains( i ) ) {
availableVlans.add( i );
}
}
}
Очередной кусок калифорнийского кода.
+144
public function __toString( $defaultText = '' )
{
return $this->getHtmlMaterial( $defaultText );
}
Продолжение серии "ОО П..."
+161
public bool IsDeleted
{
get { return _isDeleted; }
set { _isDeleted = true; }
}
удалить то удалил, а вот IsDeleted = false удачи =)
+136
enum Bool
{
True,
False,
FileNotFound
};
Как оказывается Boolean может быть не только long, но и FileNotFound.
Нашел зде©ь http://thedailywtf.com/Articles/What_Is_Truth_0x3f_.aspx
+144
class Node{
private:
int _data;
Node * _next;
public:
Node(int data): _next(0), _data(data){};
int getData() const {return _data;}
void setData(int value) {_data = value;}
Node * getNextNode() const {return _next;}
void setNextNode(Node * nextNode) {_next = nextNode;}
};
Нашел на страницах пастбина.