- 1
$data_move = date("d.m.Y", mktime(0, 0, 0, (int)date("m",time()), (int)date("d",time()), (int)date("Y",time())));
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+154
$data_move = date("d.m.Y", mktime(0, 0, 0, (int)date("m",time()), (int)date("d",time()), (int)date("Y",time())));
Вишенка даже не в том, что афтар - кармический индус, а в том, что теоретически возможна ситуация, при которой date("m",time()) выполняется в последнюю миллисекунду предыдущего месяца, а date("d",time()) - в первую следующего.
+156
$result['BIRTHDATE'] = (($date['day'] < 10) ? '0'.$date['day'] : $date['day']).'.'.(($date['month'] < 10) ? '0'.$date['month'] : $date['month.'] ).'.'.$date['year'];
Пых и даты.
+11
QString Factory::lifeEqual(WidgetEnum::SearchWidgetSet param) {
switch (param) {
case WidgetEnum::station:
return "Станция";
case WidgetEnum::water_area:
return "Акватория";
case WidgetEnum::station_coordinates:
return "Координаты станции";
case WidgetEnum::volume_of_filtered_water:
return "Объем отфильтрованной воды";
case WidgetEnum::chlorophyll_a_concentration:
return "Концентрация хлорофила а";
case WidgetEnum::chlorophyll_b_concentration:
return "Концентрация хлорофила b";
case WidgetEnum::chlorophyll_c_concentration:
return "Концентрация хлорофила c";
case WidgetEnum::A665k:
return "A(665k";
case WidgetEnum::pigment_index:
return "Индекс пигмента";
case WidgetEnum::pheopigments:
return "Феопигменты";
case WidgetEnum::upholding_sample_time:
return "Время выдержки образца";
case WidgetEnum::concetrated_sample_volume:
return "Объемная концентрация образца";
case WidgetEnum::cameras_viewed_number:
return "Качество камеры";
case WidgetEnum::total:
return "Общая численость";
case WidgetEnum::total_species:
return "Число видов в пробе";
case WidgetEnum::total_biomass:
return "Общая биомасса";
case WidgetEnum::total_percent:
return "Итоговый процент";
case WidgetEnum::biomass_percent:
return "Процент биомасс";
case WidgetEnum::percentage_of_total:
return "Процент от общего числа";
case WidgetEnum::percentage_of_the_total_biomass:
return "Процент от общего числа биомассы";
case WidgetEnum::number:
return "Номер";
case WidgetEnum::biomass:
return "Биомасса";
case WidgetEnum::total_species_in_group:
return "Всего видов в группе";
case WidgetEnum::name:
return "Название";
case WidgetEnum::name_alt:
return "Альтернативное название";
case WidgetEnum::name_rus:
return "Русское название";
case WidgetEnum::fishing_gear:
return "Рыболовный аппарат";
case WidgetEnum::assessment_of_zooplankton:
return "Оценка зоопланктона";
case WidgetEnum::date:
return "Дата";
case WidgetEnum::Station_water_area:
return "";
case WidgetEnum::groupsOfPh_name:
return "Название группы";
case WidgetEnum::groups:
return "Вид";
case WidgetEnum::error:
return "errorA";
case WidgetEnum::chlorinity:
return "chlorinity";
case WidgetEnum::density:
return "density";
case WidgetEnum::volume:
return "volume";
case WidgetEnum::o2_mg_l:
return "o2_mg_l";
case WidgetEnum::o2_ml_l:
return "o2_ml_l";
case WidgetEnum::bod5:
return "bod5";
case WidgetEnum::ph:
return "ph";
case WidgetEnum::alk:
return "alk";
case WidgetEnum::no2:
return "no2";
case WidgetEnum::no3:
return "no3";
case WidgetEnum::total_n:
return "total_n";
case WidgetEnum::po4:
return "po4";
case WidgetEnum::total_p:
return "total_p";
case WidgetEnum::si:
return "si";
And etc.....
В таком духе имеется строк 300, и если бы выход здравого смысла из спячки и наличие базы данных, 50 строчек которыми все это стало, с течением времени могло бы превратиться в 1000 строк, если не больше.
И хоть это банальный гавногод, жалко трудов и времени на него затраченных. А так хоть канет в бездне говногода, а не в бездне моего винта.
+78
public static String[] Filtr( String[] mas )
{
for(int i=0;i<mas.length;i++)
{
if ("А".equals(mas[i])){
mas[i] = "а";
}
if ("Б".equals(mas[i])){
mas[i] = "б";
}
if ("В".equals(mas[i])){
mas[i] = "в";
}
if ("Г".equals(mas[i])){
mas[i] = "г";
}
if ("Д".equals(mas[i])){
mas[i] = "д";
}
if ("Е".equals(mas[i])){
mas[i] = "е";
}
if ("Ё".equals(mas[i])){
.....//и т.д.
if ("Э".equals(mas[i])){
mas[i] = "э";
}
if ("Ю".equals(mas[i])){
mas[i] = "ю";
}
if ("Я".equals(mas[i])){
mas[i] = "я";
}
if ("Й".equals(mas[i])){
mas[i] = "й";
}
}
for(int i=0;i<mas.length;i++)
{
if(
(mas[i].equals("а") == false) &&
(mas[i].equals("б") == false) &&
(mas[i].equals("в") == false) &&
(mas[i].equals("г") == false) &&
(mas[i].equals("д") == false) &&
(mas[i].equals("е") == false) &&
(mas[i].equals("ё") == false) &&
(mas[i].equals("ж") == false) &&
(mas[i].equals("з") == false) &&
(mas[i].equals("и") == false) &&
(mas[i].equals("к") == false) &&
(mas[i].equals("л") == false) &&
(mas[i].equals("м") == false) &&
(mas[i].equals("н") == false) &&
(mas[i].equals("о") == false) &&
(mas[i].equals("п") == false) &&
(mas[i].equals("р") == false) &&
(mas[i].equals("с") == false) &&
(mas[i].equals("т") == false) &&
(mas[i].equals("у") == false) &&
(mas[i].equals("ф") == false) &&
(mas[i].equals("х") == false) &&
(mas[i].equals("ц") == false) &&
(mas[i].equals("ч") == false) &&
(mas[i].equals("ш") == false) &&
(mas[i].equals("щ") == false) &&
(mas[i].equals("э") == false) &&
(mas[i].equals("ю") == false) &&
(mas[i].equals("я") == false) &&
(mas[i].equals("ъ") == false) &&
(mas[i].equals("ь") == false) &&
(mas[i].equals("ы") == false) &&
(mas[i].equals("й") == false) &&
(mas[i].equals(" ") == false))
{
mas = Del(mas, i);
i--;
} ;
for(int k=0;(k+1)<mas.length;k++)
{
if(mas[k].equals(" ") && mas[k+1].equals(" "))
{
mas = Del(mas, k);
k--;
}
}
}
return mas;
}
+154
if($('.article-775-gallery')){
$('.article-775-gallery').each(function(){
get_images_by_building_gallery_id($(this).attr('id').replace(/gallery-/g,''));
});
}
/* ************************************************************************************************************** */
function get_building_details_by_property_id(id, size){
$.get(urlprefix + "/ajax/nanar/" + id, function(data){
var desc = jQuery.parseJSON(data);
console.log(desc);
if(desc.street && desc.zip && desc.town){
$('div[id="new-property-entry-id-' + id + '"] .house-item-head').html(desc.street + " <strong>" + desc.zip + " " + desc.town + " </strong>");
$('div[id="new-property-entry-id-' + id + '"] .house__item-descr').text(desc.description);
$('div[id="new-property-entry-id-' + id + '"] img').attr('src', desc.preview + size);
$('div[id="new-property-entry-id-' + id + '"] .verd').text(desc.verd);
$('div[id="new-property-entry-id-' + id + '"] .stard').text(desc.stard);
$('div[id="new-property-entry-id-' + id + '"] .tegund').text(desc.tegund);
$('div[id="new-property-entry-id-' + id + '"] .rooms').text(desc.rooms);
$('div[id="new-property-entry-id-' + id + '"]').slideDown();
}
});
}
if($('div[id^="new-property-entry-id-"]')){
setTimeout(function(){
$($('div[id^="new-property-entry-id-"]')).each(function(){
var size;
if($('div[id^="new-property-entry-id-"] div').hasClass('big-image')){
size = "180x140";
$('.new-property-entry-description').css('width','476px');
$('.time').css('display','block');
}else{size = "322x157";}
get_building_details_by_property_id($(this).attr('id').replace(/new-property-entry-id-/g,''), size);
});
},500);
}
код творит чудеса :), я его побоялся трогать.... знаю что функция на 9 строчке, это некое подобие шаблонизатора
+152
protected function CreateClass($className, $params) {
switch (count($params)) {
case 0:
return new $className();
break;
case 1:
return new $className($params[0]);
break;
case 2:
return new $className($params[0], $params[1]);
break;
case 3:
return new $className($params[0], $params[1], $params[2]);
break;
case 4:
return new $className($params[0], $params[1], $params[2], $params[3]);
break;
case 5:
return new $className($params[0], $params[1], $params[2], $params[3], $params[4]);
break;
case 6:
return new $className($params[0], $params[1], $params[2], $params[3], $params[4], $params[5]);
break;
case 7:
return new $className($params[0], $params[1], $params[2], $params[3], $params[4], $params[5], $params[6]);
break;
case 8:
return new $className($params[0], $params[1], $params[2], $params[3], $params[4], $params[5], $params[6], $params[7]);
break;
case 9:
return new $className($params[0], $params[1], $params[2], $params[3], $params[4], $params[5], $params[6], $params[7], $params[8]);
break;
case 10:
return new $className($params[0], $params[1], $params[2], $params[3], $params[4], $params[5], $params[6], $params[7], $params[8], $params[9]);
break;
default:
echo "Too many arguments";
return null;
break;
}
}
Плагин Jevents для джумлы
+71
config.x = Integer.parseInt(json.get("x").toString());
config.y = Integer.parseInt(json.get("y").toString());
Преобразование long в int.
+133
open System
let inline un激辛カレー<'a> (f:obj) (tuple:obj) =
match tuple with
| :? ('a * 'a * 'a) as tuple ->
let a , b , c = tuple
match f with
| :? ('a -> 'a -> 'a -> 'a) as f -> f a b c
| _ -> failwith "type did not matched! 3"
| :? ('a * 'a) as tuple ->
let a,b = tuple
match f with
| :? ('a -> 'a -> 'a) as f -> f a b
| _ -> failwith "type did not matched! 2"
| :? 'a as tuple ->
let a = tuple
match f with
| :? ('a -> 'a) as f -> f a
| _ -> failwith "type did not matched! 1"
| _ -> failwith "type did not matched! tuple"
printfn"%A"<| un激辛カレー<float> (fun x->x + 1.) 2.
printfn"%A"<| un激辛カレー<int> (+) (10,10)
printfn"%A"<| un激辛カレー<string> (fun (x:string) y z->x + y + z) ("How ","are ","you?")
+132
if(fileCounter < 1000){
subDir = "SUBDIREC.001";
//много кода
}else if (fileCounter < 2000 && fileCounter > 999){
subDir = "SUBDIREC.002";
//много кода, плюс еще 17 таких же веток
}else if (fileCounter < 20000 && fileCounter > 18999){
subDir = "SUBDIREC.020";
//много кода
}
+136
SqlConnection con = new SqlConnection(connectionString);
string sql = "SELECT idea.Id, idea.Small_text, idea.Full_text, idea.Example_text, ";
sql = sql + " ul.FullName as Avtor, ref.Name as Status, even.date_act, (select count (*) from events ev where ev.id_action=2 and ev.id_target=idea.Id and ev.type_target=1) as CountComm, (select count (*) from events ev where ev.id_action=57 and ev.id_target=idea.Id and ev.type_target=1) as Voit, (select max(ev.date_act) from events ev where ev.id_action in (1,2,4,5,7,8,9,10,58,60,61,62,63,64,65,66,67,68,69,70,71,72,74) and ev.id_target=idea.Id and ev.type_target=1) as Last_action";
sql = sql + " FROM Idea idea, UserLists ul, Refbook ref, Events even ";
sql = sql + " WHERE idea.Avtor=ul.Id and idea.Status_id = ref.Id and even.id_action=1 and even.type_target=1 and even.id_target=idea.id ";
if (id >= 0)
sql = sql + " and idea.Status_id=" + id;
if (id_avtor >= 0)
sql = sql + " and idea.Avtor=" + id_avtor;
sql = sql + " ORDER BY Last_action desc";
SqlCommand cmd = new SqlCommand(sql, con);
cmd.CommandType = CommandType.Text;
List<Idea> Ideas = new List<Idea>();
using (con)
{
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Idea idea = GetIdeaInfo(Int32.Parse(reader["Id"].ToString()));
Ideas.Add(idea);
}
reader.Close();
return Ideas;
}
Принял еще один проект. ASP.NET MVC4. Автор уехал в Новую Зеландию.