- 1
$this->vars['cookie_domain'] = $this->vars['cookie_domain'] == "" ? "" : $this->vars['cookie_domain'];
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+159
$this->vars['cookie_domain'] = $this->vars['cookie_domain'] == "" ? "" : $this->vars['cookie_domain'];
Из IPB от 2007 года, по следам индусского неизвестного классика.
Если cookie_domain = "", то пусть будет "", а если нет, то и хуй с ним, пусть остается как есть.
+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;
}
}
+156
for ($i=1;$i<=10;$i++) {
if(isset(${"imagenum".$i})) {
....
}
}
И такое бывало
+120
http://www.businessinsider.com/the-russian-internet-thinks-putin-is-dead-2015-3
политота
−109
result['first'] = False if page != 1 else True
Неплохое такое выражение
+135
int overflow(const char *str)
{
char buf[9000];
int res = atoi(buf);
itoa(res, buf, 10);
return strcmp(buf, str);
}
По мотивам #17745.
+157
var DayOfWeekToday = (new Date(item.datapoint[0])).getDay();
var DayOfWeekTomorrow = new Date(((new Date(item.datapoint[0])).getDate()) + 1).getDay();
var DayOfWeekToday = (new Date(item.datapoint[0])).getDay();
var DayOfWeekTomorrow = (DayOfWeekToday + 1 ) % 7;
+51
while (w.pollEvent(event)) {
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Period)) {
ip += ".";
}
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Num0)) {
ip += "0";
}
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Num1)) {
ip += "1";
}
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Num2)) {
ip += "2";
}
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Num3)) {
ip += "3";
}
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Num4)) {
ip += "4";
}
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Num5)) {
ip += "5";
}
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Num6)) {
ip += "6";
}
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Num7)) {
ip += "7";
}
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Num8)) {
ip += "8";
}
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Num9)) {
ip += "9";
}
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::BackSpace) && ip.length() > 0) {
ip.erase(ip.end() - 1, ip.end());
}
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Return)) {
if (validateIp(ip)) {
Text c("Connection...", f);
c.setColor(Color::Black);
c.setPosition(100, 20);
w.draw(c);
w.display();
return ip;
} else {
ip.erase(ip.begin(), ip.end());
wrongAnswer = true;
}
}
if (event.type == Event::Closed) {
w.close();
return 0;
}
}
Ввод IP-адреса в интерфейсе игры
−109
def remove_duplicates(seq):
seen = set()
seen_add = seen.add
return [x for x in seq if x not in seen and not seen_add(x)]
замечательная функция, возвращающая уникальные элементы списка.
+158
function display_form($value){
switch($value){
case "page_title":
return "<input type='text' id='page_title' name='settings[page_title]' value='".$this->values[$value]."'/>";
break;
case "admin_email":
return "<input type='text' id='admin_email' name='settings[admin_email]' value='".$this->values[$value]."'/>";
break;
case "max_rental":
return "<input type='text' id='max_rental' name='settings[max_rental]' value='".$this->values[$value]."'/>";
break;
case "offset":
return "<input type='text' id='offset' name='settings[offset]' value='".$this->values[$value]."'/>";
break;
case "launch_limit":
return "<input type='text' id='offset' name='settings[launch_limit]' value='".$this->values[$value]."'/>";
break;
case "page_text":
return "<textarea id='page_text' class='ckeditor' name='settings[page_text]'>".$this->values[$value]."</textarea>";
break;
case "email_text":
return "<textarea id='page_text' class='ckeditor' name='settings[email_text]'>".$this->values[$value]."</textarea>";
break;
case "confirm_message":
return "<textarea id='page_text' class='ckeditor' name='settings[confirm_message]'>".$this->values[$value]."</textarea>";
break;
case "general_hours":
$hours = unserialize($this->values[$value]);
return "
<table id='hours'>
<tr><th></th>
<th>Sunday</th>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thursday</th>
<th>Friday</th>
<th>Saturday</th>
</tr>
<tr>
<th>Open</th>
<td>".$this->display_hour_options("Sunday","start",$hours['Sunday']['start'])."</td>
<td>".$this->display_hour_options("Monday","start",$hours['Monday']['start'])."</td>
<td>".$this->display_hour_options("Tuesday","start",$hours['Tuesday']['start'])."</td>
<td>".$this->display_hour_options("Wednesday","start",$hours['Wednesday']['start'])."</td>
<td>".$this->display_hour_options("Thursday","start",$hours['Thursday']['start'])."</td>
<td>".$this->display_hour_options("Friday","start",$hours['Friday']['start'])."</td>
<td>".$this->display_hour_options("Saturday","start",$hours['Sunday']['start'])."</td>
</tr>
<tr>
<th>Close</th>
<td>".$this->display_hour_options("Sunday","end",$hours['Sunday']['end'])."</td>
<td>".$this->display_hour_options("Monday","end",$hours['Monday']['end'])."</td>
<td>".$this->display_hour_options("Tuesday","end",$hours['Tuesday']['end'])."</td>
<td>".$this->display_hour_options("Wednesday","end",$hours['Wednesday']['end'])."</td>
<td>".$this->display_hour_options("Thursday","end",$hours['Thursday']['end'])."</td>
<td>".$this->display_hour_options("Friday","end",$hours['Friday']['end'])."</td>
<td>".$this->display_hour_options("Saturday","end",$hours['Saturday']['end'])."</td>
</tr>
</table>
";
break;
case "interests":
$interests = unserialize($this->values[$value]);
return "<strong>Display:</strong> <br /><input type='text' name='settings[interests][display]' value='".$interests['display']."'/><br />
<strong>Options: </strong><small>(Seperated by \"|\")</small> <br /><textarea id='page_title' name='settings[interests][choices]'>".implode("|",$interests['choices'])."</textarea>";
break;
case "occasions":
$occasions = unserialize($this->values[$value]);
return "<strong>Display:</strong> <br /><input type='text' name='settings[occasions][display]' value='".$occasions['display']."'/><br />
<strong>Options: </strong><small>(Seperated by \"|\")</small> <br /><textarea id='page_title' name='settings[occasions][choices]'>".implode("|",$occasions['choices'])."</textarea>";
break;
}
}
ActiveForm на все случаи жизни