- 1
Segmentation fault
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
Segmentation fault
Я против «неинформативных ошибок».
0
# Если вы желаете ограничить диапазон "снизу",
# то просто производите генерацию псевдослучайных чисел в цикле до тех пор,
# пока не получите число большее нижней границы.
FLOOR=200
number=0 # инициализация
while [ "$number" -le $FLOOR ]
do
number=$RANDOM
done
echo "Случайное число, большее $FLOOR --- $number"
https://www.opennet.ru/docs/RUS/bash_scripting_guide/x4812.html
0
foreach ($cart = LaraCart::getItems() as $product) {
$product->id;
$product->name;
$product->title_slug;
$product->price;
$product->qty;
$product->photo;
$product->item_type;
}
А не прогнать бы нам просто данные ммм?
+2
>>> from heapq import heappush, heappop
>>> heap = []
>>> data = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0]
>>> for item in data:
... heappush(heap, item)
...
>>> ordered = []
>>> while heap:
... ordered.append(heappop(heap))
...
>>> ordered
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> data.sort()
>>> data == ordered
True
В «Python» есть стандартный модуль «heapq» с процедурками, которые делают из обычного листа очередь с приоритетом: https://docs.python.org/3.8/library/heapq.html. Всё просто, понятно, удобно и без этих ваших «классов» с «наследованиями». Именно поэтому я за «Python».
0
https://upload.wikimedia.org/wikipedia/commons/b/b5/Hexadecimal-counting.jpg
Просто оставлю это здесь
0
https://stackoverflow.com/questions/33569457/pymysql-returning-old-snapshot-values-not-rerunning-query
> Thanks. This saved my day.
> You are a hero to me, my country and the world in general. This saved my whole week. Also I did not found any other way to prevent this bug.
> Thanks a lot, this saved my day
Столкнулся с ровно такой же хуетой, как у стековерфлововца, но я делаю commit, и вижу изменения.
Кто-то скажет, что не надо было ставить "MySQL".
+1
using System;
using System.Drawing;
using System.Windows.Forms;
class HTMLCheapRedactor
{
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Form a = new Form() { Text = "HTML Doc" },
b = new Form() { Text = "HTML Code" };
var web = new WebBrowser() { Dock = DockStyle.Fill };
var txt = new TextBox()
{
Multiline = true,
Dock = DockStyle.Fill,
ScrollBars = ScrollBars.Both,
Font = new Font("Consolas", 12f),
WordWrap = false,
AcceptsTab = true
};
web.DataBindings.Add(new Binding("DocumentText", txt, "Text"));
a.Controls.Add(web);
b.Controls.Add(txt);
b.Show();
b.AddOwnedForm(a);
txt.Text = @"<html>
<head>
<title>Hello World!</title>
</head>
<body>
Hello World!
</body>
</html>";
Application.Run(a);
}
}
+1
private Map<Iterable<ItemStack>, Predicate<ItemStack>> getSubInventories(Map<Iterable<ItemStack>, Predicate<ItemStack>> subInventories, EntityPlayer player) {
InventoryPlayer inv = player.inventory;
ItemStack heldItem = inv.getCurrentItem();
int wireless = tile.getNetwork().getSetting(NetworkSettings.NETWORK_WIRELESS);
if((wireless >> 1 & 1) == 1) {
subInventories.put(Lists.newArrayList(heldItem), NOT_EMPTY);
}
if((wireless >> 2 & 1) == 1) {
subInventories.put(inv.offHandInventory, NOT_EMPTY);
}
if((wireless >> 3 & 1) == 1) {
subInventories.put(inv.mainInventory.subList(0, 9), stack -> !stack.isEmpty() && (heldItem.isEmpty() || heldItem != stack));
}
if((wireless >> 4 & 1) == 1) {
subInventories.put(inv.armorInventory, NOT_EMPTY);
}
if((wireless >> 5 & 1) == 1) {
if(FluxNetworks.proxy.baublesLoaded) {
if(player.hasCapability(BaublesCapabilities.CAPABILITY_BAUBLES, null)){
IItemHandler handler = player.getCapability(BaublesCapabilities.CAPABILITY_BAUBLES, null);
subInventories.put(() -> new ItemHandlerIterator(handler), NOT_EMPTY);
}
}
}
return subInventories;
}
+2
case Type::Instruction:
{
if (o == "movzwl") return OpCode::movzwl;
if (o == "movzbl") return OpCode::movzbl;
if (o == "shrb") return OpCode::shrb;
if (o == "shrl") return OpCode::shrl;
if (o == "xorl") return OpCode::xorl;
if (o == "andl") return OpCode::andl;
if (o == "ret") return OpCode::ret;
if (o == "movb") return OpCode::movb;
if (o == "cmpb") return OpCode::cmpb;
if (o == "movl") return OpCode::movl;
if (o == "jmp") return OpCode::jmp;
if (o == "testb") return OpCode::testb;
if (o == "incl") return OpCode::incl;
if (o == "sarl") return OpCode::sarl;
if (o == "decl") return OpCode::decl;
if (o == "jne") return OpCode::jne;
if (o == "je") return OpCode::je;
if (o == "js") return OpCode::js;
if (o == "subl") return OpCode::subl;
if (o == "subb") return OpCode::subb;
if (o == "addl") return OpCode::addl;
if (o == "addb") return OpCode::addb;
if (o == "sall") return OpCode::sall;
if (o == "orl") return OpCode::orl;
if (o == "andb") return OpCode::andb;
if (o == "orb") return OpCode::orb;
if (o == "decb") return OpCode::decb;
if (o == "incb") return OpCode::incb;
if (o == "rep") return OpCode::rep;
if (o == "notb") return OpCode::notb;
if (o == "negb") return OpCode::negb;
if (o == "sbbb") return OpCode::sbbb;
if (o == "pushl") return OpCode::pushl;
if (o == "retl") return OpCode::retl;
}
Фрагмент транслятора из ассемблера в ассемблер.
https://github.com/lefticus/x86-to-6502
0
#include <iostream>
using namespace std;
struct Rooster {
int id = 0;
};
void asshole(const Rooster* roosters) {
Rooster* r = (Rooster*)roosters;
for (int i = 0; i < 3; i++) {
r[i].id = i + 1;
}
}
int main() {
Rooster roosters[3];
asshole(roosters);
for (int i = 0; i < 3; i++) {
printf("%d\n", roosters[i].id);
}
return 0;
}
https://ideone.com/Xk9Ukg
Нахуй так жить?