- 1
Mage::run();
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+123
Mage::run();
С этого места начинается боль и мучения.
+156
<?php
$dataProvider = new CActiveDataProvider('User', array(
'criteria'=>array(
'condition' => 'id = ' . $id,
),
));
$regdata = $dataProvider->getData();
if (is_array($regdata)) $regdata = current($regdata);
//....
$this->redirect(Yii::app()->createUrl('user/profile'));
Как не стоит писать на Yii
+130
DECLARE (A, B INIT ((5)0,(5)1)) DIM (0:9) FLOAT;
+143
<?php
function get_md5($filename){
return md5_file($filename)
}
echo "get_md5($_POST)";
?>
Только начал php, посоветуйте литературу Х)
+37
int hamming(int i, int j, vector<state>& net) //returns Hamming distance between i and j nodes
{
int res = 0;
if (net[i].nodes[0] != net[j].nodes[0])
{
res++;
}
if (net[i].nodes[1] != net[j].nodes[1])
{
res++;
}
if (net[i].nodes[2] != net[j].nodes[2])
{
res++;
}
if (net[i].nodes[3] != net[j].nodes[3])
{
res++;
}
if (net[i].nodes[4] != net[j].nodes[4])
{
res++;
}
if (net[i].nodes[5] != net[j].nodes[5])
{
res++;
}
if (net[i].nodes[6] != net[j].nodes[6])
{
res++;
}
if (net[i].nodes[7] != net[j].nodes[7])
{
res++;
}
if (net[i].nodes[8] != net[j].nodes[8])
{
res++;
}
if (net[i].nodes[9] != net[j].nodes[9])
{
res++;
}
if (net[i].nodes[10] != net[j].nodes[10])
{
res++;
}
if (net[i].nodes[11] != net[j].nodes[11])
{
res++;
}
if (net[i].nodes[12] != net[j].nodes[12])
{
res++;
}
return res;
}
Человеку срочно нужно узнать про существование циклов.
−122
find $WORK/LOG -name "*.log" | grep "^app_"
и писали же вроде это не в 2 утра...
−126
while [ 1 ]
do
# ....
done
Прикололо. Не уверен что автор даже знает почему/как именно это работает.
−124
out=`$SOME_PROPRIETARY_TOOL $LOTS_OF_PARAMETERS 2>&1`
out=`echo $out | awk '{print $23}'`
из официального скрипта. и мне вот ту $SOME_PROPRIETARY_TOOL надо править. пальцев до 23х считать не хватает.
+156
if($(".picture-column.gallery").size()) {
$(".minigal-nav .counter").text("1 из " + $(".picture-column.gallery").find("li").size());
if (window.isWindowsPhone){
$(".minigal-nav li.next").attr("onclick", 'var index = $(".picture-column.gallery li.current").index(); index++; if(index > $(".picture-column.gallery").find("li").size() - 1) {index = 0;};switchImage(index);');
$(".picture-column.gallery img").attr("onclick", '$(".minigal-nav li.next").trigger("click");');
$(".minigal-nav li.prev").attr("onclick", 'var index = $(".picture-column.gallery li.current").index();index--;if(index < 0) {index = $(".picture-column.gallery").find("li").size() - 1;};switchImage(index);');
} else {
$(".minigal-nav li.next").on("click", function() {
var index = $(".picture-column.gallery li.current").index();
index++;
if(index > $(".picture-column.gallery").find("li").size() - 1) {
index = 0;
}
switchImage(index);
});
$(".picture-column.gallery img").on("click", function() {
$(".minigal-nav li.next").trigger("click");
});
$(".minigal-nav li.prev").on("click", function() {
var index = $(".picture-column.gallery li.current").index();
index--;
if(index < 0) {
index = $(".picture-column.gallery").find("li").size() - 1;
}
switchImage(index);
});
}
var switchImage = function(index) {
$(".picture-column.gallery li.current").fadeOut(function() {
$(this).removeClass("current");
$(".picture-column.gallery").find("li").eq(index).fadeIn().addClass("current");
});
$(".minigal-texts li.current").fadeOut(function() {
$(this).removeClass("current");
$(".minigal-texts").find("li").eq(index).fadeIn().addClass("current");
});
$(".minigal-nav .counter").text(index + 1 + " из " + $(".picture-column.gallery").find("li").size());
}
}
Это что-то типа адаптивный слайдер))))
+27
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>
#include <utility>
#include <sstream>
#include <assert.h>
using namespace std;
struct PeriodDescription{
size_t length, repeat_amount, last_items_amount;
/*friend ostream& operator<<(ostream& os, const PeriodDescription& s){
os<<" (PeriodDescription){"<<s.length<<", "<<s.repeat_amount<<", "<<s.last_items_amount<<"} ";
return os;
}*/
};
/*template<class C>
string co(C&& c){
ostringstream r;
r<<" (C) {";
copy(c.begin(), c.end(), ostream_iterator<typename C::value_type>(r, ", "));
r<<"}; ";
return move(r.str());
}*/
vector<PeriodDescription> find_repeat_sequences_since_begin(const string& sequence){
vector<PeriodDescription> result;
if(sequence.empty())
return result;
auto position_at_last_period=sequence.begin();
const char first_item = *position_at_last_period;
const auto after_last=sequence.end();
auto position_at_current_period = position_at_last_period;
while(true){
position_at_last_period=sequence.begin();
position_at_current_period = find(next(position_at_current_period), after_last, first_item);
PeriodDescription new_period {size_t(distance(position_at_last_period, position_at_current_period)), 1, 0};
while(position_at_current_period!=after_last && *position_at_last_period==*position_at_current_period){
++position_at_last_period; ++position_at_current_period;
if(++new_period.last_items_amount>=new_period.length){
new_period.last_items_amount = 0;
++new_period.repeat_amount;
}
}
if(new_period.repeat_amount==1 && new_period.last_items_amount==0)
return result;
result.push_back(new_period);
if(position_at_current_period==after_last)
return result;
}
}
vector<size_t> generate_FSM_failJumpIndices(const vector<PeriodDescription>& periodDescriptions, const size_t stringLength){
vector<size_t> r(stringLength+1);
for(const auto& pd : periodDescriptions){
for(size_t periodIndex=1; periodIndex<pd.repeat_amount; ++periodIndex)
for(size_t indexAtPeriod=0; indexAtPeriod<pd.length; ++indexAtPeriod)
r[(periodIndex*pd.length)+indexAtPeriod]=(periodIndex-1)*pd.length + indexAtPeriod;
for(size_t indexAtAfterPeriods=0; indexAtAfterPeriods<pd.last_items_amount; ++indexAtAfterPeriods)
r[pd.length*pd.repeat_amount+indexAtAfterPeriods]=pd.length*(pd.repeat_amount-1)+indexAtAfterPeriods;
}
return r;
}
vector<size_t> make_FSM_failJumpIndices(const string& sequence){
return generate_FSM_failJumpIndices(find_repeat_sequences_since_begin(sequence), sequence.size());
}
class FSM_for_find_equal_ranges{
size_t state;
vector<size_t> failJumpIndices;
string sequence;
string::const_iterator find_next(string::const_iterator checkPosition, const string::const_iterator last){
struct atReturn{
size_t& state;
~atReturn(){state = 0;}
}nullify{state};
if(checkPosition==last)
return last;
if(sequence.empty())
return next(checkPosition);
if(size_t(distance(checkPosition, last))<sequence.size())
return last;
while(true){
if(checkPosition==last)
return last;
if(*checkPosition==sequence[state])
++state;
else
state=failJumpIndices[state];
++checkPosition;
if(state>=sequence.size())
return prev(checkPosition, sequence.size());
}
}
public:
template<class T>
FSM_for_find_equal_ranges(T&& sequence):
Очередное собеседование. Пригласили на должность дельфина. Но оп отказался проходить собеседование на дельфи.
http://ideone.com/zp5CRb