- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
function(loaded) {
var sale=$("#markupz").val();
var markup=$("#salez").val();
...
});
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+156
function(loaded) {
var sale=$("#markupz").val();
var markup=$("#salez").val();
...
});
утонул в таком коде
+130
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
var alldir = Directory.GetDirectories(SearchIn.Text);
foreach (var s in alldir)
{
if(s.Split('\\').Last().IndexOf(SearchFor.Text) != -1)
{
string parent = Directory.GetParent(s).FullName;
string thisfolder = s.Split('\\').Last().Replace(SearchFor.Text, ReplaceTo.Text);
string fullpath = parent + "\\" + thisfolder;
Directory.Move(s, fullpath);
}
}
}
private void SearchIn_DoubleClick(object sender, EventArgs e)
{
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
SearchIn.Text = folderBrowserDialog1.SelectedPath;
}
}
}
Откопала свой хэллоу ворлд на шарпе.
Что забавно, больше всего здесь меня удручают названия переменных и компонентов.
+133
public static T ElementAtReverse<T>(this IEnumerable<T> source, int index)
{
while (true)
{
var array = source as T[] ?? source.ToArray();
var elementsCount = array.Count();
if (index < elementsCount || elementsCount == 0)
return array.ElementAt(elementsCount - 1 - index);
source = array;
index = index % elementsCount;
}
}
−124
Процедура Флажок1ПриИзменении(Элемент)
//выбираем контрагента
ТК = табК.найти(Контрагент, "контрагент");
Первый = 2+2;
для кк=0 по табК.Количество()-1 цикл
элементыформы.МаршрутныйЛистК.Область("C"+число(кк*3+1+Первый)).Видимость = (ОтобразитьВсеМеста и ТабК[кк]=ТК);
конеццикла;
КонецПроцедуры
Продукт "1С:Молокозавод. Международная поставка для пользователей "1С:Управление производственным предприятием "
Форма документа "МОЛ_ЗаказПоМаршруту".
Фирма "ЦНТУиК" (ЗАО "Центр научно-технических услуг и консультаций").
Не понятно что они курят.
+98
class CSVSave
{
char separator = ';';
public void SaveCSV(string pathfile, IEnumerable<Product> list )
{
using (var sw = new StreamWriter(pathfile, false, Encoding.GetEncoding(1251)))
{
foreach (var prod in list)
{
string line =
prod.Manufacturer + separator +
prod.Name + separator +
prod.Type + separator +
prod.Url + separator +
prod.Imgurl + separator +
prod.Sex + separator +
prod.Volume + separator +
prod.Box + separator +
prod.Price + separator +
prod.availability + separator +
prod.Desk;
if ((prod.Family != null) || (prod.QuantityPurchased != null) || (prod.Application != null) || (prod.Flavornotes != null) || (prod.Production != null)) line += separator;
if (prod.QuantityPurchased != null) line += prod.QuantityPurchased + separator;
if (prod.Family != null) line += prod.QuantityPurchased + separator;
if (prod.Production != null) line += prod.QuantityPurchased + separator;
if (prod.Application != null) line += prod.QuantityPurchased + separator;
if (prod.Flavornotes != null) line += prod.QuantityPurchased + separator;
line=line.Trim(separator);
sw.WriteLine(line);
}
sw.Close();
}
}
}
+133
BaseIndexerObjectType type;
<...>
var searchType = (SearchEntity)Enum.Parse(typeof(SearchEntity), type.ToString());
Наткнулся на просторах рабочего кода. Конвертируем один енум в другой.
+88
procedure sr(var q, w: string; j, k: integer);
begin
for j := 1 to 100 do
begin
if ord(q[j]) - ord(w[j]) > 0 then begin for k := 1 to pos(' ', q) do write(q[k]);exit; end
else if ord(q[j]) - ord(w[j]) < 0 then begin for k := 1 to pos(' ', w) do write(w[k]);exit; end;
end;
for k := 1 to pos(' ', w) do write(w[k]);
end;
procedure sr2(var q, w, e, r: string; j, k, p: integer);
begin
for j := 1 to 101 do
begin
if ord(q[j]) - ord(w[j]) > 0 then begin r := q;break; end
else if ord(q[j]) - ord(w[j]) < 0 then begin r := w;break;end;
inc(p);
end;
if p>100 then r:=w;
for j := 1 to 100 do
begin
IF E[J]=' ' Then break;
if ord(e[j]) - ord(r[j]) > 0 then begin for k := 1 to pos(' ', e) do write(e[k]);exit; end
else if ord(e[j]) - ord(r[j]) < 0 then begin for k := 1 to pos(' ', r) do write(r[k]);exit; end;
end;
for k := 1 to pos(' ', r) do write(r[k]);
end;
var
st, a, b, c, rd: string;
i, s: integer;
begin
assign(input, 'input.txt'); reset(input);
assign(output, 'output.txt'); rewrite(output);
read(st);
for i := 1 to 102
do
begin
a := a + ' ';
b := b + ' ';
c := c + ' ';
end;
for i := 1 to length(st) do
if st[i] = ' ' then inc(s)
else
case s of
0: a[i] := st[i];
1: b[i - pos(' ', a)] := st[i];
2: c[i - pos(' ', a) - pos(' ', b)] := st[i];
end;
if (a=b) and (b=c) then for i := 1 to pos(' ', a) do write(a[i])
else if (pos(' ', a) > pos(' ', b)) and (pos(' ', a) > pos(' ', c)) then for i := 1 to pos(' ', a) do write(a[i])
else if (pos(' ', b) > pos(' ', a)) and (pos(' ', b) > pos(' ', c)) then for i := 1 to pos(' ', b) do write(b[i])
else if (pos(' ', c) > pos(' ', b)) and (pos(' ', c) > pos(' ', a)) then for i := 1 to pos(' ', c) do write(c[i])
else if (pos(' ', a) = pos(' ', b)) and (pos(' ', b) = pos(' ', c)) then sr2(a, b, c, rd, 0, 0, 0)
else if pos(' ', a) = pos(' ', b) then sr(a, b, 0, 0)
else if pos(' ', c) = pos(' ', b) then sr(c, b, 0, 0)
else if pos(' ', a) = pos(' ', c) then sr(a, c, 0, 0);
end.
Выбор максимума из 3 целых длинных чисел
+210
/*
_31 - числа начинаются с _
_Math_sin - глобальные функции тоже
$abcd - строки начинаются с $
/\ - символ лямбда. Easter egg:можно писать и / для краткости
САХАР:
args = arguments
_ = args[0]
*/
log("========CALCULATOR EXAMPLE========");
//*
handler= makeHandler(chainer());
var calc = prox(
{ //imports
print:function(x){log(x); return x;}
,add:function(a,b){ return a+b;}
,set:function(x,y){ return y;}
,fma:function(a,b,c){
return a*b+c;
}
}
);
calc
.set[0]
.add[2]
.print //2
.fma[10][5]
.print //25
.add._3
.String
.add._1111
.print //281111
._Math_min._1
._Math_max._1000
.print //100
.String
._Math_log10
.add["$ pow 10"]
.print //3 pow 10
;
//*/
handler= makeHandler(chainer());
var linq = prox(
{ //imports
set :function(inner,y){ return y;}
,print :function(x){log(x); return x;}
,map :function(arr,y){ return arr.map(y)}
,filter :function(arr,y){ return arr.filter(y)}
,sort :function(arr,comparator){ return arr.sort(comparator)}
//Imperatii
,IF :function(context,condition,trueBranch,falseBranch){
return (condition(context)) ? trueBranch(context) : falseBranch(context);
}
}
);
linq
.set ["[5,2,1,3,4]"]
.print//[5, 2, 1, 3, 4]
.map ["/\ _ * 3"]
.print//[15, 6, 3, 9, 12]
.filter ["/\ log('filter='+args[0]),args[0]>5"] //несколько операторов в лямбде.
.print//[6, 9, 12, 15]
.sort ["/\ args[0]-args[1]"]
.map ["/\ _ - 6"]
.print//[0, 3, 6, 9]
.map ["/\ 2>_ ? 1 : _ * args.callee(_-1)"] //анонимная рекурсия и факториал
.print//[1, 6, 720, 362880]
//имперации
.filter ["/\ _>100"]
.IF ["/\ _.length===0"][
"/\ log('array is EMPTY!'), _"
][
"/\ log('Not empty:',_), []"
] //"Not empty:" [720, 362880]
.IF ["/\ _.length===0"][
"/\ log('EMPTY!'), ['empty','replacement']"
][
"/\ log(_), _"
].print//['empty','replacement']
;
Такой вот DSL на свойствах javascript.
Осторожно! Все трюки выполнены профессионалами. Не пытайтесь повторить это на работе.
http://jsfiddle.net/y5og4o9q/1/
+125
http://faculty.knox.edu/dbunde/teaching/chapel/
Тарасу должно понравится: Паскаль со скобочками, даже begin и then есть.
+161
if(upass==uname || upass=='1234' || upass=='12345' || upass=='123456' || upass=='654321' || upass=='pikabu' || upass=='password' || upass=='qwerty' || upass=='qazwsx') {
$('#'+upass2_id+'_err').html('Пароль не должен быть слишком простым или совпадать с логином');
errCnt++;
}
смотрел исходный код по правой кнопки - сайт pikabu.ru