- 1
- 2
- 3
- 4
- 5
- 6
$('#Leasing_payment_sum').keyup(function(){
if($(this).val()/$(this).val()){
var result = $(this).val()*1+$(this).val()*0.18;
$('#Leasing_payment_sum_with_nds').val(result.toFixed(2));
}
});
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+158
$('#Leasing_payment_sum').keyup(function(){
if($(this).val()/$(this).val()){
var result = $(this).val()*1+$(this).val()*0.18;
$('#Leasing_payment_sum_with_nds').val(result.toFixed(2));
}
});
Удивляет проверка...
+156
<?php
// Код курильщика
for ($i=1;$i<8;$i+=2){
if($i==$row->ShipingTime) $result .="<option selected value='".$i."'>".$i."</option>";
else $result .="<option value='".$i."'>".$i."</option>";
if($i==7) {$i+=3;
if($i==$row->ShipingTime) $result .="<option selected value='".$i."'>".$i."</option>";
else $result .="<option value='".$i."'>".$i."</option>";
}
else {
if($i==10) {
$i+=4;
if($i==$row->ShipingTime) $result .="<option selected value='".$i."'>".$i."</option>";
else $result .="<option value='".$i."'>".$i."</option>";
}
else {
for ($i=20;$i<45;$i+=10){
if($i==$row->ShipingTime) $result .="<option selected value='".$i."'>".$i."</option>";
else $result .="<option value='".$i."'>".$i."</option>";
if($i==40){$i+=20;
if($i==$row->ShipingTime) $result .="<option selected value='".$i."'>".$i."</option>";
else $result .="<option value='".$i."'>".$i."</option>";
$i+=30;
if($i==$row->ShipingTime) $result .="<option selected value='".$i."'>".$i."</option>";
else $result .="<option value='".$i."'>".$i."</option>";
}
}
}
}
// Код здорового человека (провели рефакторинг)
$ST_variants = array('1', '3', '5', '7', '10', '14', '20', '30' , '40', '60', '90');
foreach ($ST_variants as $value) {
print "<option ". ($value==$row->ShipingTime) ? 'selected' : '' ; ." value='".$value."'>".$value."</option>";
}
Заказчик хотел получить <select> со списком значений: '1', '3', '5', '7', '10', '14', '20', '30' , '40', '60', '90'...
+58
unsigned long long int getSumUtil(unsigned long long int *st, unsigned long long int ss, unsigned long long int se, unsigned long long int qs, unsigned long long int qe, unsigned long long int index)
//cout<<"here";
//prunsigned long long intf("here");
//printf("%llu\n%llu\n%c",i,j,type);
По следам prunsigned intf из http://govnokod.ru/17791.
http://www.codechef.com/viewplaintext/3039072
Ctrl+H - наш ответ typedef!
−397
[array_static removeAllObjects];
[array_static addObject:@"Files"];
[array addObjectsFromArray:[filemanager contentsOfDirectoryAtPath:DOCUMENTS error:nil]];
for (int l=0; l<array.count; l++) {
for (int j=0; j<array.count; j++) {
for (int i=0; i<array.count; i++) {
if ([[array objectAtIndex:i] rangeOfString:@"."].location != NSNotFound) {
[array removeObjectAtIndex:i];
}
}
}
}
for (int i = 0; i<array.count; i++) {
if (![array_static containsObject:[array objectAtIndex:i]]) {
[array_static addObject:[array objectAtIndex:i]];
}
}
Дали задание добавить фичу в один старый проект. Открыл проект, сижу и наслаждаюсь видом 8)
+158
eps=0.001;
s1=new Source(1000,0.17);
mx=new Mixer(1000);
mb=new Mem(0.15,0.95);
sp=new Splitter(0.80);
s2=new Sink();
s3=new Sink();
mx.in1=s1.out1;
mx.in2=sp.out2;
mb.in1=mx.out1;
sp.in1=mb.out2;
s3.in1=sp.out1;
s2.in1=mb.out1;
for (i=0;i<50;i++){
mx.calc();
mb.calc();
sp.calc();
}
function Stream(v,c){
this.v=v||null;
this.c=c||null;
this.selfCheck=false;
this.Show=function(){//how to add default values?
return "volume="+this.v+",conc="+this.c+",selfCheck:"+this.selfCheck+"; ";
}
}
function Source(v,c){
this.out1=new Stream(v,c);
this.calc=function(){};
}
function Sink(){
this.in1=null;
this.calc=function(){};
}
function Mixer(fixedV){
this.fv=fixedV;
this.in1=null;
this.in2=null;
this.out1=new Stream();
this.calc=function(){
this.out1.v=this.fv;//||this.in1.v+this.in2.v;
this.in2.v=this.in2.v||0;
this.in2.c=this.in2.c||0;
this.in1.v=this.out1.v-this.in2.v;
this.out1.c =(this.in1.v*this.in1.c+this.in2.v*this.in2.c)/this.out1.v;
this.out1.selfCheck=Math.abs
((this.in1.v*this.in1.c+this.in2.v*this.in2.c)-(this.out1.v*this.out1.c))<eps;
}
}
function Splitter(kS){
this.in1=null;
this.ks=kS||0.05;
this.out1=new Stream();
this.out2=new Stream();
this.calc=function(){
this.out1.v=this.in1.v*(1-this.ks);
this.out2.v=this.in1.v*(this.ks);
this.out1.c=this.in1.c;
this.out2.c=this.in1.c;
}
}
function Mem(kV,kC) {
this.kv = kV||0.15;
this.kc = kC||0.95;
this.in1 = null;
this.out1 = new Stream();
this.out2 = new Stream();
this.calc = function () {
this.out1.v = this.in1.v * this.kv;
this.out1.c = this.in1.c * (1 - this.kc);
this.out2.v = this.in1.v * (1 - this.kv);
this.out2.c = (this.in1.v * this.in1.c - this.out1.v * this.out1.c) / this.out2.v;
this.out1.selfCheck = this.out2.selfCheck = Math.abs
(this.in1.v * this.in1.c - (this.out1.v * this.out1.c + this.out2.v * this.out2.c)) < eps;
}
}
−115
def _message_handler_thread(self):
self._nick_change_failed = []
while self.running:
msg = self._message_queue.get(True)
text = msg.get_data()
conn = msg.get_connection()
args = text.replace("\r", "").replace("\n", "").split(" ")
command = args[0].upper()
command_args = args[1:]
if command == "NICK":
if len(command_args) < 1:
self._send_not_enough_parameters(conn, command)
else:
ident = self._clients[conn].identifier if self._clients[conn].identifier else None
if not self._set_nick(conn, command_args[0], ident):
self._nick_change_failed.append(conn)
elif command == "USER":
if conn in self._clients:
if len(command_args) < 2:
self._send_not_enough_parameters(conn, command)
else:
''''
self._send_lusers(conn)
self._clients[conn].real_name = command_args[:]
self._clients[conn].identifier = self._clients[conn].get_nick() + "!" + \
command_args[0] + "@" + self.name
'''
self._set_nick(conn, command_args[0], command_args[1])
self._send_motd(conn)
else: # Another way to identify is USER command.
if len(command_args) < 2:
self._send_not_enough_parameters(conn, command)
elif conn in self._nick_change_failed:
self._nick_change_failed.remove(conn)
else:
if self._set_nick(conn, command_args[0], command_args[1]):
self._clients[conn].identifier = self._clients[conn].get_nick() + "!" + \
command_args[0] + "@" + self.name
self._send_motd(conn)
elif command == "PRIVMSG" or command == "NOTICE":
if len(command_args) < 2:
self._send_not_enough_parameters(conn, command)
else:
message_text = command_args[1] if not command_args[1][0] == ":" else \
text.replace("\r\n", "")[text.index(":")+1:]
src = self._clients[conn].get_identifier()
dest = command_args[0]
if not dest.startswith("#"):
for clnt in self._clients.values():
if clnt.nick == dest:
clnt.connection.send(
":%s %s %s :%s" % (src, command, dest, message_text)
)
break
else:
self._send_no_user(conn, dest)
else:
for chan in self._channels:
if chan.name == dest:
self._channel_broadcast(conn, chan, ":%s %s %s :%s" %
(src, command, dest, message_text))
break
else:
self._send_no_user(conn, dest)
elif command == "JOIN":
if len(command_args) < 1:
self._send_not_enough_parameters(conn, command)
elif not all(c in ALLOWED_CHANNEL for c in command_args[0]) and len(command_args[0]):
self._send_no_channel(conn, command_args[0])
else:
for chan in self._channels:
if chan.name == command_args[0]:
chan.users += 1
self._clients[conn].channels.append(chan)
self._send_to_related(conn, ":%s JOIN %s" % (self._clients[conn].get_identifier(),
chan.name), True)
self._send_topic(conn, chan)
self._send_names(conn, chan)
else:
chan = Channel(command_args[0], 1)
chan.users = 1 # We have a user, because we have created it!
self._channels.append(chan)
self._clients[conn].channels.append(chan)
self._clients[conn].send(":%s JOIN %s" % (self._clients[conn].get_identifier(),
command_args[0]))
elif command == "PART":
if len(command_args) < 1:
self._send_not_enough_parameters(conn, command)
else:
for chan in self._channels:
if chan.name == command_args[0]:
self._send_to_related(conn, ":%s PART %s" % (self._clients[conn].get_identifier(),
command_args[0]))
self._clients[conn].channels.remove(chan)
chan.users -= 1
break
...
Я писал сервер для IRC...
Больше говнокода: https://github.com/SopaXorzTaker/irc-server/
+57
#include <cstdio>
#include <cstring>
int main() {
unsigned long long int a[100000];
unsigned long long int N;
unsigned long long int max,max1;
unsigned long long int maxC,maxC1;
unsigned long long int maxN[100000];
unsigned long long int ans = 0;
unsigned long long int ans1 = 0;
max = max1 = maxC = maxC1 = 0;
scanf("%llu",&N);
for (unsigned long long int i = 0; i < N; ++i) {
scanf("%llu",a + i);
if (a[i] > a[max]) {
max1 = max;
maxC1 = maxC;
// memcpy(maxN,maxN1,maxC*sizeof(unsigned long long int));
max = i;
maxC = 1;
maxN[0] = max;
} else if (a[i] == a[max]) {
maxN[maxC++] = i;
} else if (a[i] > a[max1]) {
max1 = i;
maxC1 = 1;
} else if (a[i] == a[max1]) {
maxC1++;
}
}
if (maxC == 1) {
ans = a[max];
if (a[max] == a[max1] + 1) {
if (a[max] < (maxC1 + 1) * a[max1]) {
printf("%llu\n",a[max]);
return 0;
}
}
if (max > 0) {
if (a[max - 1] + 1 < ans - 1) {
if (a[max - 1] + 1 == a[max1]) {
if (a[max1] * (maxC1 + 1 + (a[max] - 1 == a[max1]?1:0)) < ans) {
ans1 = a[max1] * (maxC1 + 1 + (a[max] - 1 == a[max1]?1:0));
if (ans > ans1) ans = ans1;
// prunsigned long long intf ("1 : %d\n",ans);
}
}
else {
ans1 = a[max] - 1 + (a[max] - 1 == a[max1]?a[max1] * maxC1:0);
if (ans > ans1) ans = ans1;
// prunsigned long long intf ("2 : %d\n",ans);
}
}
}
if (max < N - 2) {
if (a[max + 1] + 1 < ans - 1) {
if (a[max + 1] + 1 == a[max1]) {
if (a[max1] * (maxC1 + 1 + (a[max] - 1 == a[max1]?1:0)) < ans) {
ans1 = a[max1] * (maxC1 + 1 + (a[max] - 1 == a[max1]?1:0));
if (ans > ans1) ans = ans1;
// prunsigned long long intf ("3 : %d\n",ans);
}
}
else {
ans1 = a[max] - 1 + (a[max] - 1 == a[max1]?a[max1] * maxC1:0);
if (ans > ans1) ans = ans1;
// prunsigned long long intf ("4 : %d\n",ans);
}
}
}
printf("%llu\n",ans);
return 0;
} // one max line
bool f = true;
bool f1 = true;
if (a[max] * maxC > a[max] + 1) {
// prunsigned long long intf("here %d\n",maxC);
for (unsigned long long int i = 0; i < maxC; ++i) {
if (f1 && ((maxN[i] && a[maxN[i] - 1]) || (maxN[i] < N - 1 && a[maxN[i] + 1]))) f1 = false; // get from near line
if (f && ((maxN[i] && a[maxN[i] - 1] < a[max] - 1) || (maxN[i] < N - 1 && a[maxN[i] + 1] < a[max] - 1))) f = false;
}
}
ans1 = ans = maxC * a[max];
if (!f && a[max] > 1) ans = (maxC - 1) * a[max];
if (!f1) ans1 = a[max] + 1;
printf("%llu\n",ans>ans1?ans1:ans);
return 0;
}
Серега говнокодит задачу с OpenCup'a от 15.03.2015 (задача L - Бассейн счастья)
+137
http://download.hdd.tomsk.ru/preview/wxjuxudv.jpg
Защита от ботов 100500ого левела
И что не так с этими вебпрограммистами?
С сайта
http://friends-online.co/eng/1-season/1-seria-1-season.html
−95
if (avoidFlickeringTimer.running);
avoidFlickeringTimer.reset();
чинили-чинили...
+156
for ($i=1;$i<=10;$i++) {
if(isset(${"imagenum".$i})) {
....
}
}
И такое бывало