- 1
- 2
- 3
- 4
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
kill_proc(1,SIGTERM,1);
#else
...
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+146
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
kill_proc(1,SIGTERM,1);
#else
...
Оригинальный способ проверить версию ядра линукса...
Где-то в сырцах реалтековского драйвера для GPIO...
+164
FrmCabinetFound *frm = new FrmCabinetFound(index.data(Qt::UserRole).toInt());
((QMdiArea*)this->parent()->parent()->parent())->addSubWindow(frm);
frm->show();
+100
case
0: FilterList.Add('RCHECK = '+''''+'+'+'''');
1: FilterList.Add('RCHECK = '+''''+'-'+'''');
...
Автор кода жжот. Код реально работает. Но прочитать такое даже автор по прошествии года не сможет.
Можно было проще
0:FilterList.Add('RCHECK = ''+''');
+147
var that = this;
просто и со вкусом
−104
def entities(model, params = {})
@entities ||= {}
@entities[model] ||= []
if @entities[model].blank? or parameters_changed?(model, params)
@entities[model] = []
include = params[:include] || nil
group = params[:group] || nil
order = params[:order] || nil
page = params[:page] || nil
entity_ids = []
model_role = nil
model_class = model.to_s.classify.constantize
if self.has_role_for?(model_class)
self.roles_for(model_class).uniq.each do |role|
if role.authorizable_id.blank?
raise "Authorization problem! Found more than one #{model_class} model permission!" unless model_role.blank?
model_role = role.name
next
end
if !role.authorizable_id.blank? && MerchantRole::MERCHANT_ROLES.include?(role.name)
entity_ids << role.authorizable.id
end
end
if entity_ids.blank? and MerchantRole::MERCHANT_ROLES.include?(model_role)
#WARNING! RECURSION! EVIL!
if MerchantRole.has_entity_parent?(model)
parent_model = MerchantRole.entity_parent(model)
parent_entities = self.entities(parent_model)
unless parent_entities.blank?
_params = {
:conditions => conditions_and_parameters(params, nil, ["`#{model.to_s}`.`#{parent_model.to_s.singularize}_id` IN (?)", parent_entities.map(&:id)]),
:include => include,
:order => order,
:group => group
}
_params.merge!(:page => page) if params.keys.include?(:page)
if block_given?
(self.is_reseller? ? self.reseller.send(model) : model_class).each(_params) do |o|
yield o
end
else
@entities[model] = (self.is_reseller? ? self.reseller.send(model) : model_class).send(params.keys.include?(:page) ? :paginate : :find, :all, _params)
end
end
else
_params = {
:conditions => conditions_and_parameters(params, nil),
:include => include,
:order => order,
:group => group
}
_params.merge!(:page => page) if params.keys.include?(:page)
if block_given? #Find only merchants associated with the reseller or all merchants if we are no reseller.
(self.is_reseller? ? self.reseller.send(model) : model_class).each(_params) do |o|
yield o
end
else
@entities[model] = (self.is_reseller? ? self.reseller.send(model) : model_class).send(params.keys.include?(:page) ? :paginate : :find, :all, _params)
end
end
else
_params = { :conditions => conditions_and_parameters(params, nil, ["`#{model.to_s}`.`id` IN (?)", entity_ids]),
:include => include,
:order => order,
:group => group }
_params.merge!(:page => page) if params.keys.include?(:page)
if block_given?
model_class.each(_params) do |o|
yield o
end
else
@entities[model] = model_class.send(params.keys.include?(:page) ? :paginate : :find, :all, _params)
end
end
end
end
entities[@model]
end
This method does the following (you guessed it, right?):
#Fetch entities for which we have a read permission.
#This is now it should work:
#1. : If we don't have any role on the model, we won't get anything.
#2a.: Check roles we have for whole model. If no role for whole model we can only fetch instances we have assigned.
#2b.: Check all instances we have a role for and store them.
#3a.: We have roles for instances -> Goto(#7)
#3b.: We have no instance roles but have a role for the whole model.
#4. : Check recusively if we have roles fro a parent model (channels -> merchants).
#5a.: If we have a parent role and got parent entities returned we only fetch instances belonging to the parent entities.
#6a.: If we have a parent role and got no entities back, then we won't get anything since we are not supposed to.
#7. : Get all instances based on our reseller or globally for the system.
+174
if ($_SESSION['free'] <= 0) {
if ($_SESSION['free'] > 0) {
$_SESSION['free'] --;
}
}
Нашел в один из онлине казино.
+76
if (s.contains("-"))
{
String[] sa = s.split("-", 2);
for (Long i = Long.parseLong(sa[0].trim()); i<=Long.parseLong(sa[1].trim()); i++)
{
departmentsQueue.add(i);
}
}
else
{
Long id = Long.parseLong(s.trim());
departmentsQueue.add(id);
}
Отличный цикл! Кстати, я бы тут ещё и s.contains() убрал
+167
char *sLoop = new char[4];
_itoa(i, sLoop, 10);
string strField = fp1 + sLoop + fp2;
char *str = new char[255];
for (int i=0; i<=sizeof(strField); i++)
str[i] = strField[i];
_bstr_t impFieldName(str);
// думаю, очевдно, что delete нигде не было. ;)
+144
class GameDevTroll:public Troll{};
GameDevTroll TarasB;
TarasB.throwIn( Url("Какие проблемы в данных отрывках кода? (5 стр)") );
http://www.gamedev.ru/flame/forum/?id=150336&page=5#m65
−97
i = 0
t = 12
r = 0
g = 0
while r!=1:
i = i + 1
if t%i==0:
g = g + 1
if i==5000:
print t, ' - ',g
i, g = 0, 0
t = t + 1
if t==203:
r = 1
Нахождение дилителей.
Вот так-вот, человек видимо на любит юзать цикл for=)