- 1
chunksLst.erase(++it1);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
chunksLst.erase(++it1);
+142
List<EntryChange> changes = new List<EntryChange>();
for (int index = 0;
index < partsContainer.transform.childCount;
++index)
{
if (partsContainer
.transform
.GetChild(index)
.GetComponent<castle_parts_container>()
.inSave()
==
true)
{
// id of current part on scene
int partId =
partsContainer.transform
.GetChild(index).gameObject
.GetComponent<castle_parts_container>()
.partIdentificator;
int partColor =
partsContainer.transform
.GetChild(index).gameObject
.GetComponent<castle_parts_container>()
.savedColor();
int partNumber =
partsContainer.transform
.GetChild(index).gameObject
.GetComponent<castle_parts_container>()
.savedNumber();
EntryChange change = new EntryChange();
change.original =
partsContainer.transform
.GetChild(index).gameObject;
change.target =
partPrefabs.Where(
x => x.GetComponent<castle_parts_container>().partIdentificator
==
partId
&&
x.GetComponent<castle_parts_container>().partColor
==
partColor
&&
x.GetComponent<castle_parts_container>().partNumber
==
partNumber
).First();
changes.Add(change);
Избыточный код с форматированием в стиле Маяковского
+81
procedure tmythread.execute;
procedure fillmemo;
begin
form1.memo1.lines.add('Some string');
end;
begin
synchronize(fillmemo); //[Error] Unit1.pas(54): There is no overloaded version of 'Synchronize' that can be called with these arguments
end;
Почему нельзя сделать вещи, сделанные "через анус", еще более "через анус"?
+168
// ==UserScript==
// @name no horses
// @match *://govnokod.ru/*
// @grant none
// @run-at document-start
// ==/UserScript==
var CONFIG = {
horses: [
"Horse2",
"PragramistOtBoga",
"anonimb84a2f6fd141",
],
autoDownVote: true,
};
var observer = new MutationObserver(observeCallback);
var config = {
childList: true,
subtree: true,
};
observer.observe(document, config);
function observeCallback(mutations) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes) {
Array.prototype.forEach.call(mutation.addedNodes, function(node) {
try {
if (node.nodeType === 1 && /^comments_\d+$/.test(node.id)) {
handleComments(node);
}
} catch (e) {
console && console.warn && console.warn(e);
}
});
}
});
}
function downVote(node, type) {
var sel;
switch (type) {
case "post": sel = ".vote-against"; break;
case "comment": sel = ".comment-vote-against"; break;
default: throw 42; break;
}
var el = node.querySelector(sel);
if (el) {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, unsafeWindow,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
el.dispatchEvent(evt);
}
}
function handleComments(node) {
var comments = node.querySelectorAll(".entry-comment-wrapper");
Array.prototype.forEach.call(comments, function(comment) {
try {
handleComment(comment);
} catch (e) {
console && console.warn && console.warn(e);
}
});
}
function handleComment(node) {
var author = node.querySelector(".entry-author").textContent.trim();
if (CONFIG.horses.indexOf(author) != -1) {
node.style.opacity = 0.3;
node.style.maxHeight = "4em";
node.style.overflow = "scroll";
if (CONFIG.autoDownVote) {
downVote(node, "comment");
}
}
}
function handlePosts(node) {
var posts = node.querySelectorAll(".hentry");
var i;
for (i = 0; i < posts.length; i++) {
try {
handlePost(posts[i]);
} catch (e) {
console && console.warn && console.warn(e);
}
}
}
function handlePost(node) {
var author = node.querySelector(".author a:nth-child(2)").textContent.trim();
if (CONFIG.horses.indexOf(author) != -1) {
if (!/^\/\d+$/.test(document.location.pathname)) {
node.style.opacity = 0.3;
node.style.maxHeight = "4em";
node.style.overflow = "scroll";
}
if (CONFIG.autoDownVote) {
downVote(node, "post");
}
}
}
document.addEventListener("DOMContentLoaded", function() {
handleComments(document.body);
handlePosts(document.body);
});
Я так и не смог заставить MutationObserver срабатывать на новые элементы, появляющиеся во время загрузки страницы. Отсюда и костыль в последних строчках.
+64
import java.util.ArrayList;
public class Chapter19 {
/* find repeat chars in text (in all words of text)
* print repeat chars
*
*/
private String stringArray[] = { "Allocates ae neaw Setringa tehat",
"represeants tahe same saequence " };
final private String alfabetArray = "abcdefghijklmnopqrstuvwxyz";
private ArrayList <Character> repeatChars;
public void run() {
printStringArray();
repeatChars = new ArrayList<Character>();
extractRepeatChars();
if (!repeatChars.isEmpty()) {
printRepeatChars();
} else {
System.out.println("not repeat ");
}
}
private void printRepeatChars(){
System.out.println("");
for (char c : repeatChars) {
System.out.println(c);
}
}
private void printStringArray(){
System.out.println(" ");
for (String s : stringArray) {
System.out.println(s);
}
}
public String [][] parseStringArray() {
String wordsArray[][] = new String[stringArray.length][];
for (int i = 0; i < wordsArray.length; i++) {
wordsArray[i] = stringArray[i].split("\n|\t| ");
}
return wordsArray;
}
public int findRepeatCharInWordsArray(String [][]wordsArray, char c) {
for (int i = 0; i < wordsArray.length; i++) {
for (int j = 0; j < wordsArray[i].length; j++) {
if (wordsArray[i][j].indexOf(c) < 0) {
return 0; // zodyje c nerastas
}
}
}
return 1;
}
public void extractRepeatChars() {
String wordsArray[][] = parseStringArray();
for (char c : alfabetArray.toCharArray()) {
if (findRepeatCharInWordsArray(wordsArray, c) > 0) {
repeatChars.add(c);
}
}
}
} // end
chapter 19
0
https://mangalib.me/fisheye-placebo/v1/c1?page=3
именно поэтому я за «SSH-соединение»
−1
#include <boost/hana.hpp>
#include <boost/hana/ext/std/tuple.hpp>
#include <cstdint>
namespace hana = boost::hana;
using namespace hana::literals;
using hana::transform, hana::decltype_, hana::to_set, hana::type_c;
auto copy = [](uint8_t * in, uint8_t * out, auto n, auto s) {
n.times.with_index([&](auto x) {
if constexpr(x == s) {
++in;
} else {
*(uint16_t *)out = *(uint16_t *)in;
out +=2; in += 2;
}
});
return in;
};
auto f(uint8_t * in, uint8_t * out) {
return copy(in, out, 33_c, 15_c);
}
https://habr.com/ru/post/482834/#comment_21094618
> Простая задача, самый базовый вариант https://godbolt.org/z/5F5mt9 — повторите.
Очередные набросы крестоговна на хабр от царя.
Найдите UB.
0
Узнали? Согласны?
https://www.youtube.com/watch?v=0GIcP6xvW5Q
0
std::string makeFormContent(const std::string & album,
const std::wstring & filename,
const std::string & boundary)
{
static const std::string DELIM = "\r\n";
std::ostringstream ss;
std::ifstream file(filename, std::ios::binary);
ss << boundary << DELIM;
ss << "Content-Disposition: form-data; name=\"album\"" << DELIM << DELIM;
ss << album << DELIM;
ss << boundary << DELIM;
ss << "Content-Disposition: form-data; name=\"image\"; filename=\"image\"" << DELIM << DELIM;
ss << file.rdbuf() << DELIM;
ss << boundary << DELIM << "--";
return ss.str();
}
Заебали. Куча HTTP-либ под кресты, а банально сделать POST-запрос с multipart/form-data без кучи ебли нельзя. Приходится самому составлять, лол.
Именно поэтому я за «requests.post(url, data=data, files=files)».
−3
void print_line(char *s){
for(int i = 0; i < strlen(s); i++) putchar(s[i]);
putchar('\n');
}
Почему C работает медленнее чем JavaScript ?