- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
$version = (int)$_GET['version'];
if (!empty($version))
{
$version = '1.4.6.2';
}
else
{
$version = '1.4.6.2';
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+158
$version = (int)$_GET['version'];
if (!empty($version))
{
$version = '1.4.6.2';
}
else
{
$version = '1.4.6.2';
}
Ну и на кой?
−122
var daytoday:String;
var today = new Date();
var monthtoday;
var year = today.getFullYear();
var timer:Timer = new Timer(1000);
timer.addEventListener(TimerEvent.TIMER, clock);
timer.start();
function clock(e:TimerEvent):void {
var datetoday:Date=new Date();
switch (datetoday.day) {
case 0:
daytoday="ВОСКРЕСЕНЬЕ";
break;
case 1:
daytoday="ПОНЕДЕЛЬНИК";
break;
case 2:
daytoday="ВТОРНИК";
break;
case 3:
daytoday="СРЕДА";
break;
case 4:
daytoday="ЧЕТВЕРГ";
break;
case 5:
daytoday="ПЯТНИЦА";
break;
case 6:
daytoday="СУББОТА";
break;
}
дэй_оф_вик.text=String(daytoday);
switch (datetoday.month) {
case 0:
monthtoday="Января";
break;
case 1:
monthtoday="Февраля";
break;
case 2:
monthtoday="Марта";
break;
case 3:
monthtoday="Апреля";
break;
case 4:
monthtoday="Мая";
break;
case 5:
monthtoday="Июня";
break;
case 6:
monthtoday="Июля";
break;
case 7:
monthtoday="Августа";
break;
case 8:
monthtoday="Сентября";
break;
case 9:
monthtoday="Октября";
break;
case 10:
monthtoday="Ноября";
break;
case 11:
monthtoday="Декабря";
break;
}
month.text=String(monthtoday);
day.text=String(datetoday.date);
data_txt.text = year;
}
Мне больше всего нравится 33 строка...
+994
int main()
{
//выводит на экран среднее арифметическое чисел 1, 3, 5
std::cout << Mean + 1 + 3 + 5 << std::endl;
//выводит на экран среднее геометрическое чисел 2, 4, 8
std::cout << Mean * 2 * 4 * 8 << std::endl;
}
//реализация
class CMean
{
mutable double out;
mutable size_t cnt;
mutable size_t type;
public:
CMean(): out(0), cnt(0), type(-1) {}
CMean& operator + (double n)
{
return type = 0, out+= n, ++cnt, *this;
}
CMean& operator * (double n)
{
return (type == (size_t)-1 ? type = 1, out = 1 : 0), out*= n, ++cnt, *this;
}
size_t reset() const {return type = -1, out = cnt = 0;};
friend std::ostream& operator << (std::ostream&, const CMean&);
} Mean;
std::ostream& operator << (std::ostream& _os, const CMean& _arith)
{
return _os << (!_arith.type ? _arith.out / _arith.cnt : std::pow(_arith.out, 1.0 / _arith.cnt)) + _arith.reset();
}
Вывод на экран арифметической и геометрической прогрессии.
+78
Drawable d = getResources().getDrawable(R.drawable.screen_width);
int width = d.getMinimumWidth();
switch (width) {
case 1024:
CAMERA_WIDTH = 1024;
CAMERA_HEIGHT = 600;
break;
case 800:
CAMERA_WIDTH = 800;
CAMERA_HEIGHT = 480;
break;
case 480:
CAMERA_WIDTH = 480;
CAMERA_HEIGHT = 320;
break;
case 320:
CAMERA_WIDTH = 320;
CAMERA_HEIGHT = 240;
break;
default:
CAMERA_WIDTH = 800;
CAMERA_HEIGHT = 480;
break;
}
Вот так автор определял размер экрана в Android...по размеру загруженной картинки в ресурсах
Про getResources().getConfiguration().screen Layout наверное он не знал...
+997
static std::string printFloatNumber(float num,bool friendly=false)
{
std::ostringstream out ;
if(friendly)
{
char tmp[100] ;
std::string units[4] = { "B/s","KB/s","MB/s","GB/s" } ;
int k=0 ;
while(num >= 800.0f && k<5)
num /= 1024.0f,++k;
sprintf(tmp,"%3.2f %s",num,units[k].c_str()) ;
return std::string(tmp) ;
}
else
{
out << num ;
return out.str() ;
}
}
Исходники RetroShare - это просто шедевр!
+121
case 64:
{
this.RA.Value = this.memory.getValue(this.CCR.Value);
HideRegister expr_555 = this.CCR;
expr_555.Value += 1;
break;
}
case 65:
{
this.RB.Value = this.memory.getValue(this.CCR.Value);
HideRegister expr_58F = this.CCR;
expr_58F.Value += 1;
break;
}
case 66:
{
this.RC.Value = this.memory.getValue(this.CCR.Value);
HideRegister expr_5C9 = this.CCR;
expr_5C9.Value += 1;
break;
}
case 67:
{
this.RD.Value = this.memory.getValue(this.CCR.Value);
HideRegister expr_603 = this.CCR;
expr_603.Value += 1;
break;
}
default:
if (command != 129)
{
switch (command)
{
case 192:
if (this.getBit(this.FR.Value, 0))
{
this.CCR.Value = this.memory.getValue(this.CCR.Value);
}
else
{
HideRegister expr_67C = this.CCR;
expr_67C.Value += 1;
}
break;
case 193:
if (!this.getBit(this.FR.Value, 0))
{
this.CCR.Value = this.memory.getValue(this.CCR.Value);
}
else
{
HideRegister expr_6CF = this.CCR;
expr_6CF.Value += 1;
}
break;
case 194:
if (this.getBit(this.FR.Value, 1))
{
this.CCR.Value = this.memory.getValue(this.CCR.Value);
}
else
{
HideRegister expr_71F = this.CCR;
expr_71F.Value += 1;
}
break;
case 195:
if (!this.getBit(this.FR.Value, 1))
{
this.CCR.Value = this.memory.getValue(this.CCR.Value);
}
else
{
HideRegister expr_76C = this.CCR;
expr_76C.Value += 1;
}
break;
}
}
else
{
this.CCR.Value = this.memory.getValue(this.CCR.Value);
}
break;
}
}
}
this.FR.Value = value;
}
Элсы,свечи,ифы и просто хороший код №3
(продолжение следует)
годная реализация того что можно было написать в 10 строчек
+162
function include_wp_head($src)
{
$paths = array(
".",
"..",
"../..",
"../../..",
"../../../..",
"../../../../..",
"../../../../../..",
"../../../../../../.."
);
foreach ($paths as $path) {
if(file_exists($path . '/' . $src)) {
return $path . '/' . $src;
}
}
}
WordPress Form Manager
+159
<?
$a = array("second","third","first");
usort($a,"tes");
function tes($c, $d, $data){
if ($c == "third" && $d == "second") return -1;
if ($c == "third" && $d == "first") return -1;
if ($c == "first" && $d == "second") return 1;
if ($c == "second" && $d == "third") return 1;
if ($c == "first" && $d == "third") return 1;
if ($c==$d==$data) return 0;
}
print_r($a);
?>
В тестах задание, сортировать $a до вида ([1]=>"third",[2]=>"second",[3]=>"first").
Один из вариантов ответа(остальные ответы аналогичны, отличаются синтаксисом).
+86
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Sdbankpd sdbankpd = (Sdbankpd) o;
if (bjbank != null ? !bjbank.equals(sdbankpd.bjbank) : sdbankpd.bjbank != null) return false;
if (bjbvpd != null ? !bjbvpd.equals(sdbankpd.bjbvpd) : sdbankpd.bjbvpd != null) return false;
if (bjcncd != null ? !bjcncd.equals(sdbankpd.bjcncd) : sdbankpd.bjcncd != null) return false;
if (bjcust != null ? !bjcust.equals(sdbankpd.bjcust) : sdbankpd.bjcust != null) return false;
if (bjcycd != null ? !bjcycd.equals(sdbankpd.bjcycd) : sdbankpd.bjcycd != null) return false;
if (bjdfin != null ? !bjdfin.equals(sdbankpd.bjdfin) : sdbankpd.bjdfin != null) return false;
if (bjdnwd != null ? !bjdnwd.equals(sdbankpd.bjdnwd) : sdbankpd.bjdnwd != null) return false;
if (bjefmt != null ? !bjefmt.equals(sdbankpd.bjefmt) : sdbankpd.bjefmt != null) return false;
if (bjeyd != null ? !bjeyd.equals(sdbankpd.bjeyd) : sdbankpd.bjeyd != null) return false;
if (bjhocy != null ? !bjhocy.equals(sdbankpd.bjhocy) : sdbankpd.bjhocy != null) return false;
if (bjlccy != null ? !bjlccy.equals(sdbankpd.bjlccy) : sdbankpd.bjlccy != null) return false;
if (bjlcd != null ? !bjlcd.equals(sdbankpd.bjlcd) : sdbankpd.bjlcd != null) return false;
if (bjmdel != null ? !bjmdel.equals(sdbankpd.bjmdel) : sdbankpd.bjmdel != null) return false;
if (bjmodt != null ? !bjmodt.equals(sdbankpd.bjmodt) : sdbankpd.bjmodt != null) return false;
if (bjmrdt != null ? !bjmrdt.equals(sdbankpd.bjmrdt) : sdbankpd.bjmrdt != null) return false;
if (bjpcfq != null ? !bjpcfq.equals(sdbankpd.bjpcfq) : sdbankpd.bjpcfq != null) return false;
if (bjpcfu != null ? !bjpcfu.equals(sdbankpd.bjpcfu) : sdbankpd.bjpcfu != null) return false;
if (bjpeyd != null ? !bjpeyd.equals(sdbankpd.bjpeyd) : sdbankpd.bjpeyd != null) return false;
if (bjrdnb != null ? !bjrdnb.equals(sdbankpd.bjrdnb) : sdbankpd.bjrdnb != null) return false;
if (bjsbrc != null ? !bjsbrc.equals(sdbankpd.bjsbrc) : sdbankpd.bjsbrc != null) return false;
if (bjslcd != null ? !bjslcd.equals(sdbankpd.bjslcd) : sdbankpd.bjslcd != null) return false;
if (bjsuc != null ? !bjsuc.equals(sdbankpd.bjsuc) : sdbankpd.bjsuc != null) return false;
if (bjtylc != null ? !bjtylc.equals(sdbankpd.bjtylc) : sdbankpd.bjtylc != null) return false;
if (bjurpt != null ? !bjurpt.equals(sdbankpd.bjurpt) : sdbankpd.bjurpt != null) return false;
if (bjzone != null ? !bjzone.equals(sdbankpd.bjzone) : sdbankpd.bjzone != null) return false;
return true;
}
Обработка резальтов селекта
+163
var img = new Array(6);
img[0]="for_index.jpg";
img[1]="img1.jpg";
img[2]="img2.jpg";
img[3]="img3.jpg";
img[4]="img4.jpg";
img[5]="img5.jpg";
img[6]="img6.jpg";
img[7]="img7.jpg";
img[8]="img7.1.jpg";
img[9]="img7.2.jpg";
img[10]="img7_.jpg";
img[11]="img8.jpg";
img[12]="img9.jpg";
img[13]="img9.1.jpg";
img[14]="img9.2.jpg";
img[15]="img9.3.jpg";
img[16]="img9.4.jpg";
img[17]="img9.5.jpg";
img[18]="img9.6.jpg";
img[19]="img9.7.jpg";
img[20]="img9.8.jpg";
img[21]="img9.9.jpg";
img[22]="img9.10.jpg";
img[23]="img9.11.jpg";
img[24]="img9.12.jpg";
img[25]="img10.jpg";
img[26]="img10.1.jpg";
img[27]="img11.jpg";
img[28]="img11.3.jpg";
img[29]="img11.4.jpg";
img[30]="img11.5.jpg";
img[31]="img11.6.jpg";
img[32]="img12.jpg";
img[33]="img12.5.jpg";
img[34]="img12.6.jpg";
img[35]="img12.7.jpg";
img[36]="img12.8.jpg";
img[37]="img12.9.jpg";
img[38]="img12.10.jpg";
img[39]="img12.11.jpg";
img[40]="img12.12.jpg";
img[41]="img13.jpg";
img[42]="img14.jpg";
img[43]="img14.1.jpg";
img[44]="img14.2.jpg";
img[45]="img14.3.jpg";
img[46]="img14.4.jpg";
img[47]="img14.5.jpg";
img[48]="img14.6.jpg";
img[49]="img15.jpg";
img[50]="img15.1.jpg";
img[51]="img15.2.jpg";
img[52]="img15.3.jpg";
img[53]="img15.5.jpg";
img[54]="img16.jpg";
img[55]="img16.1.jpg";
img[56]="img16.3.jpg";
img[57]="img16.4.jpg";
img[58]="img16.5.jpg";
var currentImage=0;
function next() {
currentImage++;
if (currentImage == img.length){
currentImage=0;
};
document.getElementById("pic").src="images/photos/elka2009/big/"+img[currentImage];
}
function prev() {
currentImage--;
if (currentImage == -1){
currentImage=img.length-1;
};
document.getElementById("pic").src="images/photos/elka2009/big/"+img[currentImage];
}