- 1
- 2
- 3
// Create a Version 4 UUID, panicking on error.
// Use this form to initialize package-level variables.
var u1 = uuid.Must(uuid.NewV4())
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+2
// Create a Version 4 UUID, panicking on error.
// Use this form to initialize package-level variables.
var u1 = uuid.Must(uuid.NewV4())
https://github.com/gofrs/uuid
Питули запилили функцию, которая никогда error не возвращает, и запилили обёртку вокруг неё для "игнорирования" этой "ошибки".
Пиздец
+1
waiting_for_data(info, {Driver,Socket,Data},
#state{socket=Socket, driver=Driver, driver_mod=DriverMod, peer=Peer, control=Control, list=List} = State) ->
%% The meat of the whole project: process a function call and return
%% the data
try erlang:binary_to_term(Data) of
{{CallType,M,F,A}, Caller} when CallType =:= call; CallType =:= async_call ->
{ModVsnAllowed, RealM} = check_module_version_compat(M),
case check_if_module_allowed(RealM, Control, List) of
true ->
case ModVsnAllowed of
true ->
WorkerPid = erlang:spawn(?MODULE, call_worker, [CallType, RealM, F, A, Caller, Socket, Driver, DriverMod]),
?log(debug, "event=call_received driver=~s socket=\"~s\" peer=\"~s\" caller=\"~p\" worker_pid=\"~p\"",
[Driver, gen_rpc_helper:socket_to_string(Socket), gen_rpc_helper:peer_to_string(Peer), Caller, WorkerPid]),
{keep_state_and_data, gen_rpc_helper:get_inactivity_timeout(?MODULE)};
false ->
?log(debug, "event=incompatible_module_version driver=~s socket=\"~s\" method=~s module=~s",
[Driver, gen_rpc_helper:socket_to_string(Socket), CallType, RealM]),
waiting_for_data(info, {CallType, Caller, {badrpc,incompatible}}, State)
end;
false ->
?log(debug, "event=request_not_allowed driver=~s socket=\"~s\" control=~s method=~s module=~s",
[Driver, gen_rpc_helper:socket_to_string(Socket), Control, CallType, RealM]),
waiting_for_data(info, {CallType, Caller, {badrpc,unauthorized}}, State)
end;
{cast, _M, _F, _A} = Cast ->
handle_cast(Cast, State),
{keep_state_and_data, gen_rpc_helper:get_inactivity_timeout(?MODULE)};
BatchCast when is_list(BatchCast) ->
[handle_cast(Cast, State) || Cast <- BatchCast],
{keep_state_and_data, gen_rpc_helper:get_inactivity_timeout(?MODULE)};
{abcast, Name, Msg} ->
_Result = case check_if_module_allowed(erlang, Control, List) of
true ->
?log(debug, "event=abcast_received driver=~s socket=\"~s\" peer=\"~s\" process=~s message=\"~p\"",
[Driver, gen_rpc_helper:socket_to_string(Socket), gen_rpc_helper:peer_to_string(Peer), Name, Msg]),
Msg = erlang:send(Name, Msg);
false ->
?log(debug, "event=request_not_allowed driver=~s socket=\"~s\" control=~s method=~s",
[Driver, gen_rpc_helper:socket_to_string(Socket), Control, abcast])
end,
{keep_state_and_data, gen_rpc_helper:get_inactivity_timeout(?MODULE)};
{sbcast, Name, Msg, Caller} ->
Reply = case check_if_module_allowed(erlang, Control, List) of
true ->
?log(debug, "event=sbcast_received driver=~s socket=\"~s\" peer=\"~s\" process=~s message=\"~p\"",
[Driver, gen_rpc_helper:socket_to_string(Socket), gen_rpc_helper:peer_to_string(Peer), Name, Msg]),
case erlang:whereis(Name) of
undefined -> error;
Pid -> Msg = erlang:send(Pid, Msg), success
end;
false ->
?log(debug, "event=request_not_allowed driver=~s socket=\"~s\" control=~s method=~s",
[Driver, gen_rpc_helper:socket_to_string(Socket), Control, sbcast]),
error
end,
waiting_for_data(info, {sbcast, Caller, Reply}, State);
ping ->
?log(debug, "event=ping_received driver=~s socket=\"~s\" peer=\"~s\" action=ignore",
[Driver, gen_rpc_helper:socket_to_string(Socket), gen_rpc_helper:peer_to_string(Peer)]),
{keep_state_and_data, gen_rpc_helper:get_inactivity_timeout(?MODULE)};
OtherData ->
?log(debug, "event=erroneous_data_received driver=~s socket=\"~s\" peer=\"~s\" data=\"~p\"",
[Driver, gen_rpc_helper:socket_to_string(Socket), gen_rpc_helper:peer_to_string(Peer), OtherData]),
{stop, {badrpc,erroneous_data}, State}
catch
error:badarg ->
{stop, {badtcp,corrupt_data}, State}
end;
%% Handle the inactivity timeout gracefully
waiting_for_data(timeout, _Undefined, #state{socket=Socket, driver=Driver} = State) ->
?log(info, "message=timeout event=server_inactivity_timeout driver=~s socket=\"~s\" action=stopping",
[Driver, gen_rpc_helper:socket_to_string(Socket)]),
{stop, normal, State};
waiting_for_data(info, {DriverClosed, Socket} = Msg, #state{socket=Socket, driver_closed=DriverClosed} = State) ->
handle_event(info, Msg, waiting_for_data, State);
waiting_for_data(info, {DriverError, Socket, _Reason} = Msg, #state{socket=Socket, driver_error=DriverError} = State) ->
handle_event(info, Msg, waiting_for_data, State).
Срочно требуется учитель литературы, чтобы объяснить, что хотел сказать автор.
−1
val cityEq: (City) -> (Customer) -> Boolean = { city -> { it.city == city } }
Какой Kotlin ^_^^_^^_^
+1
1/-~a
Если тоже задолбались писать скобочки
1/(a+1)
+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>
Сделал вещь
+1
Функция УбратьПробел(стрЧисло)
//убирает пустой пробел
нСтр = "";
Для п=1 По СтрДлина(стрЧисло) Цикл
р = Сред(стрЧисло,п,1);
Если р = "1" ИЛИ р = "2" ИЛИ р = "3" ИЛИ р = "4" ИЛИ р = "5" ИЛИ р = "6" ИЛИ р = "7" ИЛИ р = "8" ИЛИ р = "9" ИЛИ р = "0" ИЛИ р = "," Тогда
нСтр = нСтр+р;
КонецЕсли;
КонецЦикла;
Возврат нСтр;
КонецФункции
Senior
0
#include "pch.h"
#include <iostream>
#include <conio.h>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
using namespace std;
int n=0, m=0, a[10][10];
void inputSize();
void input();
void out(int);
void problem();
bool just(int);
void menu();
int main()
{
setlocale(0, "rus");
menu();
return 0;
}
void inputSize() {
system("cls");
cout << "количество строк = "; cin >> n;
cout << "количество столбцов = "; cin >> m;
}
void input() {
system("cls");
if (n == 0 || m == 0) {
cout << "размер массива задан по умолчанию: 3х3";
n = m = 3;
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << "a[" << i + 1 << "][" << j + 1 << "] = "; cin >> a[i][j];
}
}
}
void out(int x = 0 ) {
system("cls");
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << setw(7) << a[i][j];
}
cout << endl;
}
cout << endl;
system("pause");
}
void problem() {
system("cls");
int sum = 0, k = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (just(a[i][j])) {
cout << "a[" << i + 1 << "][" << j + 1 << "] ";
sum += a[i][j];
k++;
}
}
}
if (sum == 0) cout << "нет простых чисел";
else if (sum % k == 0) cout << "ср. арифм. - целое"; else cout << "ср. арифм - не целое";
_getch();
}
bool just(int n) {
if (n == 1)return false;
int c = sqrt(n);
for (int i = 2; i <= c; i++) if (n%i == 0) return false;
return true;
}
void menu() {
system("cls");
int ch = 0;
while (ch != 5) {
cout << " МЕНЮ\n\n";
cout << "1. ввод размера массива\n";
cout << "2. ввод массива\n";
cout << "3. вывод массива\n";
cout << "4. решение задачи\n";
cout << "5. выход\n\n";
cout << ">>"; cin >> ch;
if (ch == 1) inputSize();
if (ch == 2) input();
if (ch == 3) out();
if (ch == 4) problem();
if (ch == 5) break;
system("cls");
}
}
+1
private fun getProviders(): List<Provider> =
applicationContext.getBeansOfType(Provider::class.java).values +
applicationContext.getBeansOfType(List::class.java).values.flatten().flatMap { bean ->
when (bean) {
is Provider -> listOf(bean)
else -> listOf()
}
}
Грамотная работа с applicationContext'ом
+1
#define SWITCHCALL \
dtrick \
switch(cnt){ \
case 0: r = fp(); break; \
case 1: r = fp(d[0]); break; \
case 2: r = fp(d[0], d[1]); break; \
case 3: r = fp(d[0], d[1], d[2]); break; \
case 4: r = fp(d[0], d[1], d[2], d[3]); break; \
case 5: r = fp(d[0], d[1], d[2], d[3], d[4]); break; \
case 6: r = fp(d[0], d[1], d[2], d[3], d[4], d[5]); break; \
case 7: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6]); break; \
case 8: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7]); break; \
case 9: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], \
d[8]); break; \
case 10: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], \
d[8], d[9]); break; \
case 11: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], \
d[8], d[9], d[10]); break; \
case 12: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], \
d[8], d[9], d[10],d[11]); break; \
case 13: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], \
d[8], d[9], d[10],d[11],d[12]); break; \
case 14: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], \
d[8], d[9], d[10],d[11],d[12],d[13]); break; \
case 15: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], \
d[8], d[9], d[10],d[11],d[12],d[13],d[14]); break; \
case 16: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], \
d[8], d[9], d[10],d[11],d[12],d[13],d[14],d[15]); break; \
case 17: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], \
d[8], d[9], d[10],d[11],d[12],d[13],d[14],d[15], \
d[16]); break; \
case 18: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], \
d[8], d[9], d[10],d[11],d[12],d[13],d[14],d[15], \
d[16],d[17]); break; \
case 19: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], \
d[8], d[9], d[10],d[11],d[12],d[13],d[14],d[15], \
d[16],d[17],d[18]); break; \
case 20: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], \
d[8], d[9], d[10],d[11],d[12],d[13],d[14],d[15], \
d[16],d[17],d[18],d[19]); break; \
case 21: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], \
d[8], d[9], d[10],d[11],d[12],d[13],d[14],d[15], \
d[16],d[17],d[18],d[19],d[20]); break; \
case 22: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], \
d[8], d[9], d[10],d[11],d[12],d[13],d[14],d[15], \
d[16],d[17],d[18],d[19],d[20],d[21]); break; \
case 23: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], \
d[8], d[9], d[10],d[11],d[12],d[13],d[14],d[15], \
d[16],d[17],d[18],d[19],d[20],d[21],d[22]); break; \
case 24: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], \
d[8], d[9], d[10],d[11],d[12],d[13],d[14],d[15], \
d[16],d[17],d[18],d[19],d[20],d[21],d[22],d[23]); break; \
case 25: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], \
d[8], d[9], d[10],d[11],d[12],d[13],d[14],d[15], \
d[16],d[17],d[18],d[19],d[20],d[21],d[22],d[23], \
d[24]);break; \
case 26: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], \
d[8], d[9], d[10],d[11],d[12],d[13],d[14],d[15], \
d[16],d[17],d[18],d[19],d[20],d[21],d[22],d[23], \
d[24],d[25]);break; \
case 27: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], \
d[8], d[9], d[10],d[11],d[12],d[13],d[14],d[15], \
d[16],d[17],d[18],d[19],d[20],d[21],d[22],d[23], \
d[24],d[25],d[26]);break; \
case 28: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], \
d[8], d[9], d[10],d[11],d[12],d[13],d[14],d[15], \
d[16],d[17],d[18],d[19],d[20],d[21],d[22],d[23], \
d[24],d[25],d[26],d[27]);break; \
case 29: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], \
d[8], d[9], d[10],d[11],d[12],d[13],d[14],d[15], \
d[16],d[17],d[18],d[19],d[20],d[21],d[22],d[23], \
d[24],d[25],d[26],d[27],d[28]);break; \
case 30: r = fp(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], \
d[8], d[9], d[10],d[11],d[12],d[13],d[14],d[15], \
d[16],d[17],d[18],d[19],d[20],d[21],d[22],d[23], \
d[24],d[25],d[26],d[27],d[28],d[29]);break; \
/******* ну вы понели *******/
Какой кавай )))
https://github.com/jsoftware/jsource/blob/master/jsrc/x15.c
+5
#vCardRoom > div.v-card__text > div > div > form > div > div.flex.xs12 > div > div > div.v-text-field__details > div > div > div {
font-size: 16px;
}