- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
set -e
myfunc() {
echo "START"
v=$(asdasdsd 1 2 3)
echo "FINISH"
}
myfunc && echo "OK"
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
set -e
myfunc() {
echo "START"
v=$(asdasdsd 1 2 3)
echo "FINISH"
}
myfunc && echo "OK"
Выводит:
START
./b.sh: line 5: asdasdsd: command not found
FINISH
OKset -e
myfunc() {
echo "START"
v=$(asdasdsd 1 2 3)
echo "FINISH"
}
myfuncSTART
./a.sh: line 5: asdasdsd: command not found−2
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
//типа explode в php;
{
int i=0;
//char s=';';
char s=argv[2][0];
i=100;
//char** data;
//data=(char**)malloc(i+1);
char data[1000][1000];
char* str;
str=malloc(i+1);
str=argv[1];
printf("%s\n",str );
int n=0;
int m=0;
while (*str) {
if (*str==s)
{m++;n=0;str++;continue;};
data[m][n]=*str;
str++;n++;
};
printf("%s\n",data[0] );
}
Типа explode в php
Кто-нить знает как это заставить работать с
//char** data;
//data=(char**)malloc(i+1);
??
0
ВЫБРАТЬ РАЗЛИЧНЫЕ
ВЫРАЗИТЬ(Работы.Ссылка КАК Документ.ЗаказНаряд) КАК СсылкаЗН,
ДЦ.Ссылка КАК ДилерскийЦентр
ИЗ
Документ.ЗаказНаряд.Работы КАК Работы
ЛЕВОЕ СОЕДИНЕНИЕ Справочник.CRM_ДилерскиеЦентры КАК ДЦ
ПО (ЛОЖЬ)
ГДЕ
Работы.Ссылка.ДатаЗакрытия >= &ДатаНачала
И Работы.Ссылка.ДатаЗакрытия < &ДатаОкончания
И ДЦ.Ссылка.ПометкаУдаления = ЛОЖЬ
;
Язык запросов 1С. При таком соединение запрос запрос всегда будет пустым.
0
$products = $this->cart->getProducts();
foreach ($products as $product) {
$product_total = 0;
foreach ($products as $product_2) {
if ($product_2['product_id'] == $product['product_id']) {
$product_total += $product_2['quantity'];
}
}
....
}
Поечему опенкарт так странно вычисляет количество товаров в корзине? неужели нет способа изящней?
0
$id=$id-1;
$id++;
$id=(int)$id;
Дальше в sql запрос ее конкотенируют.
ОМГ, я даже представить не могу для чего нужны первые 3 строки в совокупности в 3-й..
+1
/* Create a JSON object from JSON data stream. The stream should be opened and configured. All other behavior of this method is the same as the JSONObjectWithData:options:error: method.
*/
open class func jsonObject(with stream: InputStream, options opt: ReadingOptions = []) throws -> Any {
var data = Data()
guard stream.streamStatus == .open || stream.streamStatus == .reading else {
fatalError("Stream is not available for reading")
}
repeat {
var buffer = [UInt8](repeating: 0, count: 1024)
var bytesRead: Int = 0
bytesRead = stream.read(&buffer, maxLength: buffer.count)
if bytesRead < 0 {
throw stream.streamError!
} else {
data.append(&buffer, count: bytesRead)
}
} while stream.hasBytesAvailable
return try jsonObject(with: data, options: opt)
}
Потоковое чтение JSON от авторов "iСделаль"
+2
var type = shape switch
{
Rectangle((0, 0), 0, 0) => "Point at origin",
Circle((0, 0), _) => "Circle at origin",
Rectangle(_, var w, var h) when w == h => "Square",
Rectangle((var x, var y), var w, var h) =>
$"A {w}×{h} rectangle at ({x},{y})",
_ => "something else"
};
https://habr.com/ru/post/454446/#comment_20232586
Какой бароп )))
+2
// https://github.com/WebKit/webkit/blob/e0e7e8f907f4c01c723374e8230a63d46e89e6a0/Source/WebCore/platform/graphics/filters/FEComposite.cpp#L98
static unsigned char clampByte(int c)
{
unsigned char buff[] = { static_cast<unsigned char>(c), 255, 0 };
unsigned uc = static_cast<unsigned>(c);
return buff[!!(uc & ~0xff) + !!(uc & ~(~0u >> 1))];
}
+2
#include <type_traits>
struct Foo {
void bar(int) const & {}
};
int main() {
using MethodPtr = decltype(&Foo::bar);
const MethodPtr arr[] = { &Foo::bar };
auto *ptr = &arr;
auto &ref = ptr;
static_assert(std::is_same_v<decltype(ref), void (Foo::* const (*&)[1])(int) const &>);
}
Магия указателей возведенная в степень магии массивов в степени магии ссылок.
https://wandbox.org/permlink/8DygQ6oocrEY1K1M
−2
execute = 0
i = 100
while i < $
load a byte from i
if a = 0xc3
execute = i
i = $
else
i = i + 1
end if
end while
if execute = 0
display "ret not found", 13, 10
execute = $
ret
end if
Прежде чем объявлять подпрограмму, тсарь пройдётся по уже собранному коду в поисках нужных ему байт.