- 1
Афганистан заебал.
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+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
+1
function *foo()
{
yield 1;
yield 2;
yield 3;
}
function main()
{
for (const o of foo())
{
console.log (o);
}
}
main();
давайте посмотрим, как TS/JS имплементирует "елды". изначально код выглядит красиво. но заглянем под капот что генерит tsc для выполнение такого кода. мне придется разбить этот ужос
+1
struct file_id
{
uint64_t persistent;
uint64_t volatile_;
static const size_t RAW_LENGTH = 16;
operator std::string() const
{ return std::string(reinterpret_cast<const char*>(&persistent), RAW_LENGTH); }
// Операторы для использования file_id в качестве ключа map и
// unordered_map
struct hash
{
std::size_t operator()(const ntdec_smb2_file_id& file_id) const
{
std::string s_file_id = file_id;
std::hash<std::string> hasher;
return hasher(s_file_id);
}
};
bool operator == (const ntdec_smb2_file_id& other)
{
return std::string(*this) == std::string(other);
}
bool operator < (const ntdec_smb2_file_id& other)
{
return std::string(*this) < std::string(other);
}
bool operator > (const ntdec_smb2_file_id& other)
{
return std::string(*this) > std::string(other);
}
};
operator std::string тоже UB?
+2
class IntIter {
constructor(private i = 0) {}
next() {
type retType = [value: typeof this.i, done: boolean];
if (this.i < 10) {
return <retType>[this.i++, false];
}
return <retType>[this.i, true];
}
}
function main() {
let it = new IntIter();
for (const o of it)
{
print(o);
}
for (const o of "Hello")
{
print(o);
}
}
добавил поддержку ForOf для ES2015 и ES3; причем компилятор сам определяет какой вариант лучше юзать
+1
type a = 1;
type i = a & a;
type j = a | a;
function main() {
let v1: i;
let v2: j;
assert(sizeof(i) != sizeof(j));
print("done.");
}
ну все я понял вам скучно... как насчет такого примера?
+6
Раскрытие покровов. Настя, облачные технологии и Настенька.
−1
type int = 1;
type int64 = 4294967296;
declare function GC_get_heap_size(): int64;
function main() {
let i = 0;
for (i = 0; i < 10000000; ++i) {
const p = new int[1];
if (i % 100000 == 0) print("Heap size = ", GC_get_heap_size());
}
}
вот такая лабуда подкатили.. называется GC.. для тех кто не любит GC я добавил опцию -nogc :)
вот так можно JIT запускать без компиляции
tsc.exe --emit=jit --shared-libs=TypeScriptGCWrapper.dll 1.ts
tsc.exe --emit=jit -nogc 1.ts
+1
fn main() {
println!("Hello World!");
}
rustc --version --verbose:
rustc 1.52.1 (9bc8c42bb 2021-05-09)
binary: rustc
commit-hash: 9bc8c42bb2f19e745a63f3445f1ac248fb015e53
commit-date: 2021-05-09
host: powerpc-unknown-linux-gnu
release: 1.52.1
LLVM version: 12.0.0
Error output
rustc ./hello.rs
Illegal instruction (core dumped)
https://github.com/rust-lang/rust/issues/85238
Open: clienthax opened this issue on May 12 · 6 comments