- 1
IT Оффтоп #30
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
IT Оффтоп #30
#1: https://govnokod.ru/18142 https://govnokod.xyz/_18142
#2: https://govnokod.ru/18378 https://govnokod.xyz/_18378
#3: https://govnokod.ru/19667 https://govnokod.xyz/_19667
#4: https://govnokod.ru/21160 https://govnokod.xyz/_21160
#5: https://govnokod.ru/21772 https://govnokod.xyz/_21772
#6: https://govnokod.ru/24063 (потёр пидор сракер) https://govnokod.xyz/_24063
#7: https://govnokod.ru/24538 https://govnokod.xyz/_24538
#8: https://govnokod.ru/24815 (потёр пидор сракер) https://govnokod.xyz/_24815
#9: https://govnokod.ru/24867 https://govnokod.xyz/_24867
#10: https://govnokod.ru/25328 https://govnokod.xyz/_25328
#11: https://govnokod.xyz/_25436 https://govnokod.ru/25436 (потёр пидор сракер)
#12: https://govnokod.xyz/_25471
#13: https://govnokod.xyz/_25590 (потёр пидор сракер)
#14: https://govnokod.xyz/_25684
#15: https://govnokod.xyz/_25694
#16: https://govnokod.xyz/_25725
#17: https://govnokod.xyz/_25731
#18: https://govnokod.xyz/_25762
#19: https://govnokod.xyz/_25767
#20: https://govnokod.xyz/_25776
#21: https://govnokod.xyz/_25798
#22: https://govnokod.xyz/_25811
#23: https://govnokod.xyz/_25863
#24: https://govnokod.xyz/_25941
#25: https://govnokod.xyz/_26026
#26: https://govnokod.xyz/_26050
#27: https://govnokod.xyz/_26340
#28: https://govnokod.xyz/_26372
#29: https://govnokod.xyz/_26385
+6
# coding: inlinec
from inlinec import inlinec
@inlinec
def test():
#include<stdio.h>
void test() {
printf("Hello, world");
}
https://www.opennet.ru/opennews/art.shtml?num=52306 - Inlinec - новый способ использования Си-кода в Python-скриптах
Сишные вставки в питоне
+1
define method display (i :: <integer>)
do-display-integer(i);
end;
define method display (s :: <string>)
do-display-string(s);
end;
define method display (f :: <float>)
do-display-float(f);
end;
define method display (c :: <collection>)
for (item in c)
display(item); // runtime dispatch
end;
end;
В закромах истории нашёлся язык с runtime dispatch/multimethods.
0
for (var i = 0; i < self.Collection().length; i++) {
///НЕ УДАЛЯЙТЕ ОТОРВУ РУКИ!!!!!
if (self.Collection()[i].IsSecuringApplications() == true) {
continue;
}
TotalContractSumm = Math.round((TotalContractSumm + parseFloat(self.Collection()[i].ContractGuarantee)) * 100) / 100;
TotalApplicationSumm = Math.round((TotalApplicationSumm + parseFloat(self.Collection()[i].ApplicationGuarantee)) * 100) / 100;
}
Вот что бывает, когда нет code review.
0
data class User(
@Expose
@SerializedName("email")
val email: String? = null,
@Expose
@SerializedName("username")
val username: String? = null,
@Expose
@SerializedName("image")
val image: String? = null
) {
override fun toString(): String {
return "User(email=$email, username=$username, image=$image)"
}
}
JetBrains сделали прекрасный стандартный toString у дата классов, а они всё равно пишут свой туСтринг, который выдаёт результат в точности повторяющий стандартный.
https://github.com/mitchtabian/MVIExample/blob/master/app/src/main/java/com/codingwithmitch/mviexample/model/User.kt
0
$the_cow = <<EOC;
$thoughts
$thoughts @@@###==#######@#@@@@@@@@@@@@
@@@###====***====##########@@@@#
@@@###===***++********===###@@@#
#@@###==*****+++++++++**===##@@@#
=@@#####==****++++++++***==###@@@
#@@=##======*++*+++++***===###@@#
#@#===###===#**+++++*+***==###@#
@###**#=*++==#=****==#===####@@#
##====**==***+==++==##@###=###@@#
###=====***=######====*******==*+*=*+***=##=###
###====******+++*=#####===******===**==*****====##
#===*******++++++++=######==******#=***==******==##
#===******+++++++++++*=#####==**+++=#=*+*==****==####
#===****++++++++++++++++*=####=**++++**=====*+***==###=###
##==****++++++++++++++++++*=####===***===*=*=**+***==##**===###
##==***++++++++++++++++++++*#######=======*====****==##=***====###
##==***+++++++++++++++:+++++*######===#@@@@@@##=====##===****=====##
#===***++++++++++++++++++++*=########===@@@@@@@######=====**++*=====##@@
##===*****++*++++++++++++++**=####@@@@@##=====####@##=======******====###
###===***********+++++++++++***=####@#@######=##@@###===#===*********====#
##====*************+*****+******=###@@#@##@##@@@####======*****+******====
###===***************************=##@@@@@@@@######=======****++++*+****===
@##=====**************************===#########=#========*****++++++++**===
###======*********************========######================**********====
####=======****=**********==================================**=*==***=====
####============***====*=======================================*=**======#
Пахом для cowsay
+1
function send_message_with_photo($token, $peer_id, $message, $image_file_path) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
/* Получаем ссылку для загрузки фотографии */
curl_setopt($ch, CURLOPT_URL, 'https://api.vk.com/method/photos.getMessagesUploadServer');
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
"access_token" => $token,
"v" => "5.103"
));
$result = json_decode(curl_exec($ch), true);
$upload_url = $result['response']['upload_url'];
/* Отправляем фотографию */
curl_setopt($ch, CURLOPT_URL, $upload_url);
$file = curl_file_create($image_file_path);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
"photo" => $file,
));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: multipart/form-data'));
$result = json_decode(curl_exec($ch), true);
$server = $result['server'];
$photo = $result['photo'];
$hash = $result['hash'];
/* Сохраняем фотографию */
curl_setopt($ch, CURLOPT_URL, 'https://api.vk.com/method/photos.saveMessagesPhoto');
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
"access_token" => $token,
"v" => "5.103",
"server" => $server,
"photo" => $photo,
"hash" => $hash
));
$result = json_decode(curl_exec($ch), true);
$photo_id = strval($result['response'][0]['id']);
$owner_id = strval($result['response'][0]['owner_id']);
$attachment = "photo" . $owner_id . "_" . $photo_id;
/* Отправляем сообщение */
curl_setopt($ch, CURLOPT_URL, 'https://api.vk.com/method/messages.send');
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
"access_token" => $token,
"v" => "5.103",
"random_id" => rand(),
"peer_id" => $peer_id,
"message" => $message,
"attachment" => $attachment
));
$result = json_decode(curl_exec($ch), true);
curl_close($ch);
}
Говнокод для загрузки фото в ВК)
−1
g = {'А', 'Е', 'Ё', 'И', 'У', 'О', 'Я', 'Ы', 'Э', 'Ю'}
s = input().split()
last = -1
start = -1
first = 0
f = 0
GL = 0
gl = 0
cnt = 0
el = s[0]
if len(s) == 1:
el = s[0]
for i in range(len(el)):
if el[i].isupper() and el[i] not in g:
print('ошибка')
exit()
if el[i].isupper() and f:
print('ошибка')
exit()
if el[i].upper() in g:
gl += 1
GL += 1
if el[i].isupper():
start = gl
f = 1
if gl and not f:
print('ошибка')
exit()
if start == -1:
print('не стихи')
exit()
if (start == 2 and gl == 3) \
or (start == 1 and gl == 2) \
or (start == 2 and gl == 2):
print('недостаточно информации')
exit()
last = -1
start = -1
first = 0
GL = 0
f = 0
gl = 0
cnt = 0
el = s[0]
while start == -1 and first < len(s):
el = s[first]
first += 1
for i in range(len(el)):
if el[i].isupper() and el[i] not in g:
print('ошибка')
exit()
if el[i].isupper() and f:
print('ошибка')
exit()
if el[i].upper() in g:
gl += 1
GL += 1
if el[i].isupper():
start = gl
gl = 0
f = 1
if gl and not f:
print('ошибка')
exit()
if start == -1:
print('не стихи')
exit()
cnt = gl
for k in range(first, len(s)):
el = s[k]
f = 0
gl = 0
cnt = cnt
for i in range(len(el)):
if el[i].upper() in g:
cnt += 1
gl += 1
GL += 1
if el[i].isupper() and el[i] not in g:
print('ошибка')
exit()
if el[i].isupper() and f:
print('ошибка')
exit()
if el[i].isupper():
if last == -1:
last = cnt
cnt = 0
elif cnt != last:
print('не стихи')
exit()
else:
cnt = 0
f = 1
if gl and not f:
print('ошибка')
exit()
if GL == 1:
print('не стихи')
exit()
if start > 3 or last > 3 or cnt > 2:
print('не стихи')
exit()
if start == 1:
if last == 2 and cnt < last:
print('хорей')
elif (last == 3 or last == -1) \
and cnt < 3:
print('дактиль')
else:
print('не стихи')
elif start == 2:
if (last == 2 and cnt < last) \
or last == -1:
print('ямб')
elif last == 3:
print('амфибрахий')
else:
print('не стихи')
elif start == 3 \
and (last == 3 or last == -1):
print('анапест')
else:
print('не стихи')
0
$('#calculator').on('change', clr);
$('#calculator').on('change', total_sum);
$('#calculator').on('click', '.title', add_block);
$('#calculator').on('change', total_kg);
$("input[name='group1']").on('click', total_sum);
$("input[name='pack']").on('click', total_sum);
$('#calculator').on('click', '.title', total_sum);
$('#dop_block_0').html(
'<select size="1" name="paper" class="paper" id="paper_0">' +
'<option selected="" disabled="">Вид макулатуры</option>' +
'<option value="Картон">Картон</option>' +
'<option value="Книги, журналы">Книги, журналы</option>' +
'<option value="Архив">Архив</option>' +
'<option value="Полиэтилен">Полиэтилен</option>' +
'<option value="Газеты">Газеты</option>' +
'</select>' +
'<input type="text" placeholder="Вес в килограммах" name="weight" class="masa" id="masa_0" min="0">' +
'<p>' +
'Цена (руб/кг): <input type="text" class="price" value="0" disabled=""><input type="hidden" class="cur" id="cur_0" value="0" disabled="">' +
'</p>'
);
function total_kg() {
var i = 0;
var kg_ol = 0;
while (i < 6) {
var t = +$("#masa_" + i).val();
if (t !== t) { t = 0 };
kg_ol += t;
i++;
}
if (kg_ol >= 300) {
$('#test').attr('disabled', false);
}
else {
$('#test').attr('disabled', true);
$('#test').attr('checked', false);
$('#test').attr('checked', true);
}
};
function total_sum() {
var i = 0;
var pri0 = $("#test_block_" + i).find('.cur').val();
var price_ol = 0;
if (pri0 !== pri0) { pri0 = 0 };
while (i < 6) {
var t = +$("#test_block_" + i).find('.cur').val();
if (t !== t) { t = 0 };
price_ol += t;
i++;
}
$('.cur_ol').text(price_ol);
};
function add_block() {
var parent_id = $(this).parent().attr('id');
if ($('#' + parent_id + ' .block_dop').text() == "") {
$('#' + parent_id + ' .block_dop').html('<select size="1" name="paper" class="paper">' +
'<option selected disabled>Вид макулатуры</option>' +
'<option value="Картон">Картон</option>' +
'<option value="Книги, журналы">Книги, журналы</option>' +
'<option value="Архив">Архив</option>' +
'<option value="Полиэтилен">Полиэтилен</option>' +
'<option value="Газеты">Газеты</option>' +
'</select>' +
'<input type="text" placeholder="Вес в килограммах" name="weight" class="masa" id="masa_' + colum + '" min="0">' +
'<p>Цена (руб/кг): <input type="text" class="price" value="0" disabled><input type="hidden" class="cur" value="0" disabled></p>' +
'<script>jQuery(function($){$("#masa_' + colum + '").mask("999999",{placeholder:"",autoclear: false});});</script>');
$('#' + parent_id + ' .block_dop').slideDown();
$(this).html('Убрать вид макулатуры');
if (colum < 5) {
console.log("1=2");
var st = colum + 1;
$('#calculator .param').append('<div id="dop_block_' + st + '" class="dop">' +
'<p class="title">Добавить вид макулатуры</p>' +
' <div class="block_dop"></div>' +
'</div>');
colum++;
};
}
else {
if (colum == 1) {
console.log("2=1");
$('#' + parent_id + ' .block_dop').slideUp();
$('#' + parent_id + ' .block_dop').html("");
$(this).html('Добавить вид макулатуры');
console.log("сolum=" + colum);
}
else {
console.log("2=2");
$('#' + parent_id).slideUp();
$('#' + parent_id).remove();
colum--;
};
function clr() {
var i = 0;
while (i < 6) {
var price = 0;
var x = $("#dop_block_" + i).find('.paper').val();
if ($('input[name=group1]:checked').val() == 2 && $('input[name=pack]:checked').val() == 1){
switch (x) {
case '1'://Картон
Кокой "Java Script"
−3
Что это за бесячая стрелка на говнокоде, которая появляется при горизонтальном скроле?
https://i.imgur.com/uRcKSDO.png
Браузер - Opera. В FF, IE, Google Chrome - не воспроизводится.
Это заговр против Норвежских разработчиков?