- 1
Бесконечный оффтоп имени Борманда #5
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
Бесконечный оффтоп имени Борманда #5
#1: https://govnokod.ru/25864 https://govnokod.xyz/_25864
#2: https://govnokod.ru/25921 https://govnokod.xyz/_25921
#3: https://govnokod.ru/26544 https://govnokod.xyz/_26544
#4: https://govnokod.ru/26838 https://govnokod.xyz/_26838
0
<!DOCTYPE html>
<html lang="ru">
<heaad><title>calculator Protestant of sins [beta]</title></head><body><script>
let m = ["сколько Вам лет [в годах]?","мало!","всего наилучшего тебе",0,16668,"сколько вы отдыхаете? [в часах]","у вас накопилось :"," грехов! "];
var x="Этот супер калькулятор поможет тебе подсчитать количество нажитых тобой - за твои годы Грехов!\n Не бойся, смелее вводи свои данные в последующие окошки, и получай результат!\nне переживай, если у тебя получится болше одного миллиона - то это в пределах нормы, если больше то надо делать обряд!";
try{function b(e) {let l=d(c(m[e]));e==0?x=l:0;return l};
function c(a) {return prompt(a)}
function d(d) {if(d<=2){alert(m[1]);d(c(m[0]))}else{return d;}}
if(confirm(x)){let s=0x1E32F50*b(0);let a=x*0x16D*0x18-b(5);alert(m[6]+`${s-a-m[4]-Math.PI}`+m[7])}else{alert(m[2])}}catch(x){alert("©by den")};
</script></body></html>
Hello народ))
Уверен вы ещё не встречали такого супер калькулятора!
Чую даже без запуска вы поймёте что это полное Г
0
function* foo() {
let i = 1;
yield ++i;
yield ++i;
}
function main() {
for (const o of foo()) {
print(o);
}
print("done.");
}
вот... решил самую крутую проблему в итераторах... а ты (С/C++) так можешь?
0
Электрика / электроника #4
#1: https://govnokod.ru/25437 https://govnokod.xyz/_25437
#2: https://govnokod.ru/25820 https://govnokod.xyz/_25820
#3: https://govnokod.ru/26570 https://govnokod.xyz/_26570
+4
struct Foo {
};
struct Bar {
int x[0];
};
https://ideone.com/upuoOg
Какая консистентность )))
+1
Питушня #19
#1: https://govnokod.ru/26692 https://govnokod.xyz/_26692
#2: https://govnokod.ru/26891 https://govnokod.xyz/_26891
#3: https://govnokod.ru/26893 https://govnokod.xyz/_26893
#4: https://govnokod.ru/26935 https://govnokod.xyz/_26935
#5: (vanished) https://govnokod.xyz/_26954
#6: (vanished) https://govnokod.xyz/_26956
#7: https://govnokod.ru/26964 https://govnokod.xyz/_26964
#8: https://govnokod.ru/26966 https://govnokod.xyz/_26966
#9: https://govnokod.ru/27017 https://govnokod.xyz/_27017
#10: https://govnokod.ru/27045 https://govnokod.xyz/_27045
#11: https://govnokod.ru/27058 https://govnokod.xyz/_27058
#12: https://govnokod.ru/27182 https://govnokod.xyz/_27182
#13: https://govnokod.ru/27260 https://govnokod.xyz/_27260
#14: https://govnokod.ru/27343 https://govnokod.xyz/_27343
#15: https://govnokod.ru/27353 https://govnokod.xyz/_27353
#16: https://govnokod.ru/27384 https://govnokod.xyz/_27384
#17: https://govnokod.ru/27482 https://govnokod.xyz/_27482
#18: https://govnokod.ru/27514 https://govnokod.xyz/_27514
0
const int sum(int a, int b){
return a+b;
}
int a(int x)
{
const std::function<int(int)> sum4 = std::bind(sum,_1, 4);
return sum4(123);
}
int b(int x)
{
puts("bagor");
const std::function<int(int)> sum4 = std::bind(sum,_1, 4);
return sum4(123);
}
int c(int x)
{
const std::function<int(int)> sum4 = std::bind(sum,_1, 4);
puts("bagor");
return sum4(123);
}
// Функции a и b нормально инлайнятся. Ассемблерный выхлоп:
sum(int, int): # @sum(int, int)
lea eax, [rdi + rsi]
ret
a(int): # @a(int)
mov eax, 127
ret
b(int): # @b(int)
push rax
mov edi, offset .L.str
call puts
mov eax, 127
pop rcx
ret
//А вот int c(int x)
c(int): # @c(int)
push rbx
sub rsp, 32
mov edi, 16
call operator new(unsigned long)
mov rbx, rax
mov qword ptr [rax], offset sum(int, int)
mov dword ptr [rax + 8], 4
mov qword ptr [rsp], rax
mov qword ptr [rsp + 24], offset std::_Function_handler<int (int), std::_Bind<int const (*(std::_Placeholder<1>, int))(int, int)> >::_M_invoke(std::_Any_data const&, int&&)
mov qword ptr [rsp + 16], offset std::_Function_handler<int (int), std::_Bind<int const (*(std::_Placeholder<1>, int))(int, int)> >::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation)
mov edi, offset .L.str
call puts
mov esi, dword ptr [rbx + 8]
mov edi, 123
call qword ptr [rbx]
mov ebx, eax
mov rax, qword ptr [rsp + 16]
test rax, rax
je .LBB3_3
mov rdi, rsp
mov rsi, rdi
mov edx, 3
call rax
.LBB3_3:
mov eax, ebx
add rsp, 32
pop rbx
ret
mov rdi, rax
call __clang_call_terminate
mov rbx, rax
mov rax, qword ptr [rsp + 16]
test rax, rax
je .LBB3_6
mov rdi, rsp
mov rsi, rdi
mov edx, 3
call rax
.LBB3_6:
mov rdi, rbx
call _Unwind_Resume@PLT
mov rdi, rax
call __clang_call_terminate
__clang_call_terminate: # @__clang_call_terminate
push rax
call __cxa_begin_catch
call std::terminate()
std::_Function_handler<int (int), std::_Bind<int const (*(std::_Placeholder<1>, int))(int, int)> >::_M_invoke(std::_Any_data const&, int&&): # @std::_Function_handler<int (int), std::_Bind<int const (*(std::_Placeholder<1>, int))(int, int)> >::_M_invoke(std::_Any_data const&, int&&)
mov rax, qword ptr [rdi]
mov rcx, qword ptr [rax]
mov edi, dword ptr [rsi]
mov esi, dword ptr [rax + 8]
jmp rcx # TAILCALL
std::_Function_handler<int (int), std::_Bind<int const (*(std::_Placeholder<1>, int))(int, int)> >::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation): # @std::_Function_handler<int (int), std::_Bind<int const (*(std::_Placeholder<1>, int))(int, int)> >::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation)
Решил попробовать std::bind.
https://godbolt.org/z/eW5eT5oj4
+3
Афганистан заебал.
−2
# Дамп базы хуза
# Постобработка export-а из MySQL
import pandas as pd
import numpy as np
import csv
comments = pd.read_csv('/wp_comments-2.csv', header=None)
comments.head()
##
comments_clean = pd.DataFrame({
'comment_id': comments[0],
'comment_post_id': comments[1],
'comment_parent': comments[13],
'name': comments[2],
'gravatar_hash': comments[3].str.split('@').str[0],
'gravatar_domain': comments[3].str.split('@').str[1],
'profile': comments[4],
'date': comments[6],
'content': comments[8],
})
##
comments_clean[(comments_clean.gravatar_domain != 'lo.ol') & ~comments_clean.gravatar_domain.isna()]
##
comments_clean = comments_clean[(comments_clean.gravatar_domain == 'lo.ol') | comments_clean.gravatar_domain.isna()]
comments_clean.drop(columns=['gravatar_domain'], inplace=True)
comments_clean.head()
##
posts = pd.read_csv('/wp_posts.csv', header=None)
posts = posts[(posts[20] == 'post') & (posts[7] == 'publish') & (posts[11].str.match('^_'))]
posts.head()
##
posts_clean = pd.DataFrame({
'post_id': posts[0],
'date': posts[2],
'content': posts[4],
'description': posts[6],
'original_id': posts[11].str[1:]
})
posts_clean.head()
##
comments_clean.to_csv('~/Downloads/gost/comments.csv', index=False)
posts_clean.to_csv('~/Downloads/gost/posts.csv', index=False)
https://govnokod.xyz/dump/wp_gk_legacy_users.csv
../comments.csv
../posts.csv
+2
Steps to reproduce:
var s = "a huge, huge, huge string...";
s = s.substring(0, 5);
Expected results: s takes five bytes of memory, plus some overhead.
Actual results: s takes a huge, huge, huge amount of memory.
Unfortunately, most String functions use substring() or no-ops internally: concatenating with empty string, trim(), slice(), match(), search(), replace() with no match, split(), substr(), substring(), toString(), trim(), valueOf().
My workaround is:
function unleakString(s) { return (' ' + s).substr(1); }
But it's not satisfying, because it breaks an abstraction and forces me to think about memory allocation.
https://bugs.chromium.org/p/v8/issues/detail?id=2869
Status: Assigned (Open)
Reported on: Sep 3, 2013