- 1
- 2
- 3
- 4
- 5
Если НЕ Объект.Валютный Тогда
Объект.ПересчитыватьВалютнуюСумму=Ложь;
Иначе
Объект.ПересчитыватьВалютнуюСумму=Истина;
КонецЕсли;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
Если НЕ Объект.Валютный Тогда
Объект.ПересчитыватьВалютнуюСумму=Ложь;
Иначе
Объект.ПересчитыватьВалютнуюСумму=Истина;
КонецЕсли;
Типовая УХ
+1
// https://godbolt.org/z/QAR_nT
// https://govnokod.ru/26701#comment550329
#include <cstddef>
#include <string>
#include <cassert>
struct assert_failure
{
explicit assert_failure(const char *sz)
{
std::fprintf(stderr, "Assertion failure: %s\n", sz);
std::quick_exit(EXIT_FAILURE);
}
};
// эта херня не совсем корректно будет обрабатывать всякую хрень вроде ", , , " - оно это посчитает за 4 аргумента,
// и если считать " скобочки, тогда еще надо запилить обработку эскейп-последовательности, для хуйни типа "pidor\" govno"
// но мне лень эту хуйню допиливать.
constexpr std::size_t count_args(const char *s, std::size_t depth = 0, std::size_t pos = 0, std::size_t count = 0)
{
if (s[pos] == '\0'){
if(depth != 0)
throw assert_failure("kakoi bagor)))\n");
if(pos == 0)
return 0;
return count+1;
}
else if(s[pos] == '{')
{
return count_args(s, depth + 1, pos + 1, count);
}
else if(s[pos] == '}')
{
if(depth == 0)
throw assert_failure("kakoi bagor)))\n");
return count_args(s, depth - 1, pos + 1, count);
}
else if(depth == 0)
{
if(s[pos] == ',')
{
return count_args(s, depth, pos + 1, count + 1);
}
}
return count_args(s, depth, pos+1, count);
}
#define TO_STR(...) #__VA_ARGS__
#define ARGNUM(...) count_args(TO_STR(__VA_ARGS__))
#define krestogovnotypeof(a) std::remove_reference<a>::type
#define FOR_RANGE(type, varname, ...) for(struct {size_t cnt; krestogovnotypeof(type) arr[ ARGNUM(__VA_ARGS__) ]; } varname = {0, {__VA_ARGS__}}; varname.cnt < sizeof(varname.arr)/sizeof(type); ++varname.cnt )
int main(void)
{
FOR_RANGE(int[2], k, {1,2}, {3,4}, {5,6}, {7,8})
printf("{%d %d},\n", k.arr[k.cnt][0], k.arr[k.cnt][1]);
return EXIT_SUCCESS;
}
Какая крестопараша((( В вижуальхуюдии вроде собирается, но проверить корректность работы не могу. Как вы этим днищекомпилятором вообще пользуетесь?
Было б круто, если бы были такие constexpr функции, которые в компилтайме могут куски исходного кода высирать как бы прямо в исходник, и потом уже чтоб это компилировалось
0
<!DOCTYPE html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<canvas id='pixel_canvas'></canvas>
<pre id='text_canvas'></pre>
<script>
'use strict';
function tryFetch() {
const array = arguments[0];
const onError = arguments[arguments.length - 1];
let result = array;
for (let i = 1; i < arguments.length - 1; ++i) {
if (arguments[i] < result.length) {
result = result[arguments[i]];
} else {
return onError;
}
}
return result;
}
function bitmap2tetramap(bitmap) {
let tetramap = []
for (let i = 0; i < bitmap.length; i += 2) {
tetramap.push([]);
for (let j = 0; j < bitmap[i].length; j += 2) {
tetramap[tetramap.length - 1].push(
tryFetch(bitmap, i, j, 0) << 3 |
tryFetch(bitmap, i, j + 1, 0) << 2 |
tryFetch(bitmap, i + 1, j, 0) << 1 |
tryFetch(bitmap, i + 1, j + 1, 0)
);
}
}
return tetramap;
}
function renderTetramap(tetramap) {
const tiles = [
' ', '▗', '▖', '▄',
'▝', '▐', '▞', '▟',
'▘', '▚', '▌', '▙',
'▀', '▜', '▛', '█'
];
return tetramap.map(row => row.map(i => tiles[i]).join('')).join('<br>');
}
function renderBitmap(bitmap) {
return renderTetramap(bitmap2tetramap(bitmap));
}
function rgba2bitmap(rgba, width, height) {
let bitmap = [];
for (let i = 0; i < height; ++i) {
bitmap.push([]);
for (let j = 0; j < width; ++j) {
const currentRGBAElementIndex = (i * width * 4) + j * 4;
const red = rgba[currentRGBAElementIndex];
const green = rgba[currentRGBAElementIndex + 1];
const blue = rgba[currentRGBAElementIndex + 2];
const a = rgba[currentRGBAElementIndex + 3];
bitmap[i].push((red + green + blue + a) / 4 > 0? 1 : 0);
}
}
return bitmap;
}
function renderImageData(imageData) {
return renderBitmap(rgba2bitmap(imageData.data, imageData.width, imageData.height));
}
const ctx = pixel_canvas.getContext("2d");
ctx.font = "16px serif";
ctx.fillText("Какой багор )))", 0, 16);
text_canvas.innerHTML = renderImageData(ctx.getImageData(0, 0, pixel_canvas.width, pixel_canvas.height));
</script>
</body>
+3
// https://youtu.be/KdZ4HF1SrFs?t=4473
// про питоновский for
for x in 1, 5, 2, 4, 3
print(x**2)
//> написать это в две строки у вас не получится
for(struct {size_t cnt; int arr[5];} i = {0, {1,5,2,4,3}}; i.cnt < sizeof(i.arr)/sizeof(i.arr[0]); ++i.cnt )
printf("%d ", (int)(pow(i.arr[i.cnt], 2) + 0.5) );
В Си я могу и в 1 строку эту хуйню написать.
0
int ACMEncoder::Encode(int framepos, void *in, int in_avail, int *in_used, void *out, int out_avail)
{
char *pin = (char *)in;
char *pout = (char *)out;
int retval = 0;
if (!m_did_header && do_header)
{
int s = 44;
s = 4 + 4 + 12 - 4;
int t;
if (m_convert_wfx.wfx.wFormatTag == WAVE_FORMAT_PCM) t = 0x10;
else t = sizeof(WAVEFORMATEX) + m_convert_wfx.wfx.cbSize;
s += 4 + t;
if (s&1) s++;
if (m_convert_wfx.wfx.wFormatTag != WAVE_FORMAT_PCM)
s += 12;
s += 8;
if (out_avail < s) return 0;
//xx bytes of randomness
m_hlen = s;
m_did_header = 1;
out_avail -= s;
pout += s;
retval = s;
}
«Winamp» спиздили.
0
Код с продакшена рабочего проекта :-D
Dim got_new_batch As Boolean = False
Dim batch_numb As Integer = 0
Dim temp_batch As Integer = 0
While got_new_batch = False
temp_batch = objRandom.Next(400000000)
If check_batch_avaliable(temp_batch) = True Then
got_new_batch = True
batch_numb = temp_batch
End If
End While
Public Function check_batch_avaliable(ByVal batch_number As Integer) As Boolean
'CWC-7/11/2016-Rewritten to avoid runtime error
Dim RC As Integer = -1
Dim DBConnection As New IfxConnection(INFXConnectionStr_RPCentral)
'Try
Dim SQL As String = ""
SQL = " select first 1 batch_numb from " + System.Configuration.ConfigurationManager.AppSettings("InformixTable") + " where batch_numb = " & batch_number
Dim DBCommand As New IfxCommand(SQL, DBConnection)
DBCommand.CommandType = CommandType.Text
DBCommand.CommandTimeout = 200
DBConnection.Open()
RC = CInt(DBCommand.ExecuteScalar())
DBConnection.Close()
' Catch ex As Exception
' Dim ErrMsg = ex.Message
' Finally
If Not DBConnection Is Nothing Then
If DBConnection.State = ConnectionState.Open Then
DBConnection.Close()
End If
DBConnection = Nothing
End If
' End Try
If RC > 0 Then
Return False
Else
Return True
End If
End Function
+1
<?php
echo count($arr);
$i = count($arr) - 1;
for ($i; $i >= 0; $i--) {
?>
<div class="post" id="p<?php echo $arr[$i]->_id; ?>">
<div class="p_title"><?php echo $arr[$i]->title; ?></div>
<div class="p_content"><?php echo $arr[$i]->content; ?></div>
<div class="p_date"><?php echo $arr[$i]->date; ?></div>
<form id="<?php echo $arr[$i]->_id; ?>" action="index.php" method="get">
<!--<textarea rows="4" cols="50" name="removid" style="display: none;" ><?php echo $arr[$i]->_id; ?></textarea>-->
<input type="text" name="removid" form="<?php echo $arr[$i]->_id; ?>" value="<?php echo $arr[$i]->_id; ?>"/>
<input type="submit" class="p_remove" onclick="dele('<?php echo $arr[$i]->_id; ?>');" form="<?php echo $arr[$i]->_id; ?>" value="Удалить"/>
</form><!--</div>-->
<?php echo $arr[$i]->_id; ?>
</div>
<?php
}
?>
<script>
function dele(param){
var jsVar = "<?php
$removid = $_GET['removid'];
$bulk = new MongoDB\Driver\BulkWrite;
//$bulk->delete(['_id'=> new MongoDB\BSON\ObjectId($removid)]);
$query = new MongoDB\Driver\Query(['_id'=> new MongoDB\BSON\ObjectId($removid)]);
$bulk->delete(['_id'=> new MongoDB\BSON\ObjectId($removid)]);
$writeConcern = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY, 1000);
try {
$result = $manager->executeBulkWrite('forum.posts', $bulk, $writeConcern);
//header('Location: https://benar.wtf/index.php');
}
catch (MongoDB\Driver\Exception\BulkWriteException $e) {
$result = $e->getWriteResult();
}
?>";
}
</script>
Сделал вещь
0
https://news.ycombinator.com/item?id=20426997
LiveJournal data breach impacts 33M users with plaintext passwords
Идиотия, кретинизм, олигофрения, и другие способы стать разработчиком в livejournal
+2
template <typename F, class = decltype(F()(E()))>
auto map(F p) -> std::vector< decltype(p(E())) >
{
std::vector< decltype(p(E())) > result;
std::transform(get().begin(), get().end(), std::back_inserter(result), [=](auto &v) {
return mutable_(p)(v);
});
return result;
}
template <typename F, class = decltype(F()(E(), 0))>
auto map(F p) -> std::vector< decltype(p(E(), 0)) >
{
std::vector< decltype(p(E(), 0)) > result;
auto first = &(get())[0];
std::transform(get().begin(), get().end(), std::back_inserter(result), [=](auto &v) {
auto index = &v - first;
return mutable_(p)(v, index);
});
return result;
}
// и применение (e) => f()
auto strs = (array<int>{ 1, 2, 3 }).map([](auto x)
{
return "X" + x;
});
// или (e, index) => f()
auto strs = (array<int>{ 1, 2, 3 }).map([](auto x)
{
return x + i;
});
как я выкрутился бля... с разными маперами... как генерики в c#
+5
https://github.com/ASDAlexander77/TypeScript2Cxx/blob/master/cpplib/core.h
Нужна помощь смелых и умных людей, надо сделать review кода и посоветовать что там по стандартам улучшить... короче любая помощь welcome
https://github.com/ASDAlexander77/TypeScript2Cxx/blob/master/cpplib/core.h