- 1
NSString *CellIdentifier = [NSString stringWithFormat:@"BFTumblrPostCell%i%i",indexPath.section,indexPath.row];
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−397
NSString *CellIdentifier = [NSString stringWithFormat:@"BFTumblrPostCell%i%i",indexPath.section,indexPath.row];
+12
// Decompress section data
if (ERR_SUCCESS != LzmaDecompress(data, dataSize, decompressed)) {
// Intel modified LZMA workaround
EFI_COMMON_SECTION_HEADER* shittySectionHeader;
UINT32 shittySectionSize;
// Shitty compressed section with a section header between COMPRESSED_SECTION_HEADER and LZMA_HEADER
// We must determine section header size by checking it's type before we can unpack that non-standard compressed section
shittySectionHeader = (EFI_COMMON_SECTION_HEADER*) data;
shittySectionSize = sizeOfSectionHeaderOfType(shittySectionHeader->Type);
// ...
Oh shit!
+153
<?php foreach ($category_1['children'] as $category_2) { ?>
<?php if ($category_2['category_id'] == $category_id) { ?>
<option value="<?php echo $category_2['category_id']; ?>" selected="selected"> <?php echo $category_2['name']; ?></option>
<?php } else { ?>
<option value="<?php echo $category_2['category_id']; ?>"> <?php echo $category_2['name']; ?></option>
<?php } ?>
<?php foreach ($category_2['children'] as $category_3) { ?>
<?php if ($category_3['category_id'] == $category_id) { ?>
<option value="<?php echo $category_3['category_id']; ?>" selected="selected"> <?php echo $category_3['name']; ?></option>
<?php } else { ?>
<option value="<?php echo $category_3['category_id']; ?>"> <?php echo $category_3['name']; ?></option>
<?php } ?>
Код вида поиска из известной модификации CMS Opencart - Maxystore.
+155
{php}
$this->_tpl_vars['image_set'] = array();
$this->_tpl_vars['json_string'] = "";
{/php}
{if $pcollection}
{foreach name=pcollection key=picture_id item=picture from=$pcollection}
{php}
array_push($this->_tpl_vars['image_set'], "{$this->_tpl_vars['urlprefix']}/thumb.php?file=" . str_replace("thumbs","original","media/pictures/{$this->_tpl_vars['album']->getPath()}/{$this->_tpl_vars['picture']->getPath()}")."&size=245x143");
{/php}
{/foreach}
{/if}
{php}
$this->_tpl_vars['json_string'] = json_encode($this->_tpl_vars['image_set']);
{/php}
{$json_string}
получение объекта в smarty, потом пара фокусов, и вуаля, выплевываем json строку
+69
package com.javarush.test.level06.lesson11.bonus02;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/* Нужно добавить в программу новую функциональность
Задача: У каждой кошки есть имя и кошка-мама. Создать класс, который бы описывал данную ситуацию. Создать два объекта: кошку-дочь и кошку-маму. Вывести их на экран.
Новая задача: У каждой кошки есть имя, кошка-папа и кошка-мама. Изменить класс Cat так, чтобы он мог описать данную ситуацию.
Создать 6 объектов: маму, папу, сына, дочь, бабушку(мамина мама) и дедушку(папин папа).
Вывести их всех на экран в порядке: дедушка, бабушка, папа, мама, сын, дочь.
Пример ввода:
дедушка Вася
бабушка Мурка
папа Котофей
мама Василиса
сын Мурчик
дочь Пушинка
Пример вывода:
Cat name is дедушка Вася, no mother, no father
Cat name is бабушка Мурка, no mother, no father
Cat name is папа Котофей, no mother, father is дедушка Вася
Cat name is мама Василиса, mother is бабушка Мурка, no father
Cat name is сын Мурчик, mother is мама Василиса, father is папа Котофей
Cat name is дочь Пушинка, mother is мама Василиса, father is папа Котофей
*/
public class Solution
{
public static void main(String[] args) throws IOException
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String grfatherName = reader.readLine();
Cat catGrfather = new Cat(grfatherName);
String grmotherName = reader.readLine();
Cat catGrmother = new Cat(grmotherName);
String fatherName = reader.readLine();
Cat catFather = new Cat(fatherName, catGrfather, null);
String motherName = reader.readLine();
Cat catMother = new Cat(motherName, null, catGrmother);
String sonName = reader.readLine();
Cat catSon = new Cat(sonName, catFather, catMother);
String daughterName = reader.readLine();
Cat catDaughter = new Cat(daughterName, catFather, catMother);
System.out.println(catGrfather);
System.out.println(catGrmother);
System.out.println(catFather);
System.out.println(catMother);
System.out.println(catSon);
System.out.println(catDaughter);
}
public static class Cat
{
private String name;
private Cat father;
private Cat mother;
Cat(String name)
{
this.name = name;
}
Cat (String name, Cat father, Cat mother){
this.name = name;
this.mother = mother;
this.father = father;
}
@Override
public String toString()
{
if ((mother == null) && (father == null))
return "Cat name is " + name + ", no mother, no father ";
else if (father == null)
return "Cat name is " + name + ", mother is " + mother.name + " , no father";
else if (mother == null)
return "Cat name is " + name + ", no mather " + ", father is " + father.name;
else
return "Cat name is " + name + ", mother is " + mother.name + ", father is " + father.name;
}
}
}
Да лаба, точнее задание. Но меня так умиляет решение задачи :) Просто немного хардкода :)
+156
if ($.browser.msie && $.browser.version < 8) {
$("div.banneritem:gt(0)").remove();
$("#viewnow").remove();
$("#morerealestates").css("margin-top", "-26px");
$("img[align=right]").css("float", "right");
}
else {
setTimeout(function(){
slider();
}, 0);
}
var got = $("div.banneritem:eq(0)").find("#preview").find("a").attr("href");;
var timer = 7500;
var anim = 750;
function slider()
{
setTimeout(function(){
do_slide(0);
setTimeout(function(){
do_slide(1);
setTimeout(function(){
do_slide(2);
setTimeout(function(){
do_slide(2, true);
setTimeout(function(){
do_slide(1, true);
setTimeout(function(){
do_slide(0, true);
slider();
}, timer);
}, timer);
}, timer);
}, timer);
}, timer);
}, timer);
}
function do_slide(v,rev)
{
x = "div.banneritem:eq(" + v + ")";
if(rev==null)
{
$(x).slideUp(anim);
foo = $("div.banneritem:eq(" + (v+1) + ")").find("#preview").find("a").attr("href");
}else
{
$(x).slideDown(anim);
foo = $("div.banneritem:eq(" + (v-1) + ")").find("#preview").find("a").attr("href");
}
if(foo!=null) got = foo;
}
$("#viewnow").click(function(){
window.location=got;
});
Классика, слайдер на 3 елемента, с возавтом ;)
+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 строчке, это некое подобие шаблонизатора
+154
$('.order-form-popup form').on('submit', function (e) {
e.preventDefault();
var data = $(this).serializeArray(),
mainProfilesList = '',
fillingsList = '';
$('.field-name-field-eo-main-profiles .field-item').each(function () {
mainProfilesList += ('<li>' + ($(this).text()) + '</li>');
});
$('.field-name-field-eo-fillings .field-item').each(function () {
fillingsList += ('<li>' + ($(this).text()) + '</li>');
});
data.push({
name: 'profiles',
value: '<ul>' + mainProfilesList + '</ul>'
});
data.push({
name: 'fillings',
value: '<ul>' + fillingsList + '</ul>'
});
data.push({
name: 'number',
value: $('.field-name-field-eo-product-number .field-item').text()
});
data.push({
name: 'qty',
value: $('#qty-input').val()
});
data.push({
name: 'area',
value: $('.field-name-field-eo-area .field-item').text()
});
data.push({
name: 'price',
value: $('.field-name-field-eo-price-without-discount .field-item').text()
});
$.ajax({
url: location.protocol + '//' + location.hostname + '/send-message.php',
type: 'POST',
data: data,
success: function (data, textStatus) {
var msg = '<h3 id="order-form-popup-msg" style="text-align: center; margin-top: 50%;">Заявка успешно отправлена.<br /> Спасибо!</h3>'
$('.order-form-popup form, .order-form-popup-title').hide();
$('.order-form-popup').append(msg);
window.setTimeout(function () {
$('.order-form-popup, .order-form-overlay').fadeOut(500);
$('#order-form-popup-msg').remove();
$('.order-form-popup form, .order-form-popup-title').show();
}, 3500);
},
error: function (jqXHR, textStatus, errorThrown) {
//for debugging
}
});
});
Сериализация данных из полей, находящихся вне формы.
+154
Ext.define('Block', {
config: {
title: 'default',
desc: 'default'
},
constructor: function (config) {
this.initConfig(config);
},
tpl: new Ext.Template( '<div class="block">\
<div class="close">×</div>\
<div class="wrapper">\
<h3 class="title">{0}</h3>\
<p class="desc">{1}</p>\
</div>\
</div>'),
create: function(){
var div = new Ext.dom.Element(document.createElement('div')),
html = this.tpl.apply([
this.title,
this.desc
]);
div.setHTML(html);
return div.first();
}
});
var form = Ext.get('form'),
blocks = Ext.get('blocks');
form.addListener('submit', function(e, me){
e.preventDefault();
var title = me.elements.title.value,
desc = me.elements.desc.value,
blockInstance = Ext.create('Block');
blockInstance.setTitle(title);
blockInstance.setDesc(desc);
var blockElement = blockInstance.create();
blocks.appendChild(blockElement);
blockElement.select('.close').addListener('click', function(){
blockElement.remove();
});
me.reset();
});
Реализация минимального todo app на ExtJS. Переписывалась с чистого js ради эксперимента.
+154
function c(){
//Внимание! Далее идёт индусский код! Слабонервных попрошу уда(л|в)иться...
require ('config.php');
$included = get_included_files();
if(!in_array('config.php',$included)){
Error(404);
return;
}
...
...
}
Стиль и коммент оставил оригинальные, видимо ЭТО кому-то из наших уже попадало до меня.
Далее код - в натуре полный "хадж".