- 1
Definition WordUpperBound := 65536.
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
Definition WordUpperBound := 65536.
+1
if req.Lang != "" {
req.Lang = "EN"
}
Я сказал английский!
[Поставленная задача: если пришёл запрос без поля, поставить значение по умолчанию]
+1
function main() {
(function () {
print("Hello World!");
})();
}
а ваш С компилятор может так говнокодить? а мой компилятор может :)
0
{
"error": false,
"message": "Ok",
"data": {
"countries": [
{
"country": {
"id": 24,
"iso_a2": "CA",
"name": "Canada",
"prefix": "1",
"vendors": [
1
]
},
"city": {
"id": 3723,
"region_id": 8,
"name": "Toronto",
"prefix": "416",
"icon_url": null,
"setup": 0.25,
"monthly": 1.88
}
},
{
"country": {
"id": 51,
"iso_a2": "IL",
"name": "Israel",
"prefix": "972",
"vendors": [
1
]
},
"city": {
"id": 122,
"region_id": null,
"name": "Jerusalem",
"prefix": "2",
"icon_url": null,
"setup": 0.25,
"monthly": 1.88
}
},
{
"country": {
"id": 94,
"iso_a2": "GB",
"name": "United Kingdom",
"prefix": "44",
"vendors": [
1
]
},
"city": {
"id": 4701,
"region_id": null,
"name": "London",
"prefix": "207",
"icon_url": null,
"setup": 0.25,
"monthly": 1.88
}
},
{
"country": {
"id": 95,
"iso_a2": "US",
"name": "United States",
"prefix": "1",
"vendors": [
1,
2
]
},
"city": {
"id": 6400,
"region_id": 44,
"name": "New York",
"prefix": "332",
"icon_url": null,
"setup": 0.25,
"monthly": 1.88
}
}
]
}
}
CTO написал апишечку для возврата доступных локейшнов по странам для покупки телефонных номеров
изыск 2021 я такого и в 2000ых не встречал !!!
+1
val users = listOf("foo", "bar")
println(users.joinToString{","})
0
public class Checker
{
public bool CheckInn(long inn)
{
var values = inn.ToArray();
switch (values.Length)
{
case 10:
#region Юр. лица
var coefficientsN10 = new byte[] { 2, 4, 10, 3, 5, 9, 4, 6, 8 };
int sumN10 = GetSumNx(values, coefficientsN10);
var checkNumberN10 = (sumN10 % 11) % 10;
return values[^1] == checkNumberN10;
#endregion
case 12:
#region Физ. лица
var coefficientsN11 = new byte[] { 7, 2, 4, 10, 3, 5, 9, 4, 6, 8 };
var coefficientsN12 = new byte[] { 3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8 };
var sumN11 = GetSumNx(values, coefficientsN11);
var checkNumberN11 = (sumN11 % 11) % 10;
var sumN12 = GetSumNx(values, coefficientsN12);
var checkNumberN12 = (sumN12 % 11) % 10;
return values[^2] == checkNumberN11 && values[^1] == checkNumberN12;
#endregion
default:
return false;
}
}
private int GetSumNx(byte[] values, byte[] coefficientsNx)
{
var sumNx = 0;
for (int i = 0; i < coefficientsNx.Length; i++)
sumNx += coefficientsNx[i] * values[i];
return sumNx;
}
}
public static class Extensions
{
public static byte[] ToArray(this long number)
{
var values = new Stack<byte>(12);
while (number != 0)
{
values.Push((byte)(number % 10));
number /= 10;
}
return values.ToArray();
}
}
Проверка ИНН, ну и говно
−1
Get-NetTCPConnection -State Listen | %{[pscustomobject]@{Port=$_.LocalPort; Process=$(Get-Process -Id $_.OwningProcess)}} | sort {[int]$_.Port}
Давайте течь от powershell.
0
-module(server).
-export([start/0]).
start() ->
rooster:start(#{port => 8080},
#{routes => [hello()]}).
hello() ->
{'GET', "/hello", fun(_) -> {200, #{message => <<"hello world">>}} end}.
https://github.com/fbeline/rooster
Rooster
Simplistic REST framework that runs on top of mochiweb.
+3
foreach ($files as $n => $f) {
$new_content = $common.$namespace_begin.$f.$namespace_end;
$std_methods = array();
preg_match_all('/std::[a-z_0-9]*/', $new_content, $std_methods);
$std_methods = array_unique($std_methods[0]);
$needed_std_headers = array();
$type_headers = array(
'std::move' => '',
'std::vector' => '',
'std::string' => '',
// [...]
'std::unordered_set' => 'unordered_set');
foreach ($type_headers as $type => $header) {
if (in_array($type, $std_methods)) {
$std_methods = array_diff($std_methods, array($type));
if ($header && !in_array($header, $needed_std_headers)) {
$needed_std_headers[] = $header;
}
}
}
if (!$std_methods) { // know all needed std headers
$new_content = preg_replace_callback(
'/#include <([a-z_]*)>/',
function ($matches) use ($needed_std_headers) {
if (in_array($matches[1], $needed_std_headers)) {
return $matches[0];
}
return '';
},
$new_content
);
}
Тут вот в https://govnokod.ru/20049 CHayT предлагал использовать «PHP» в качестве препроцессора для «C» — так вот в «Телеграме» совет оценили и решили взять на вооружение.
https://github.com/tdlib/td/blob/master/SplitSource.php
0
public bool IsTransfarable
{
get
{
switch (unitType)
{
case UnitTypes.SIEGE_TANK:
case UnitTypes.WIDOW_MINE:
case UnitTypes.SIEGE_TANK_SIEGED:
case UnitTypes.WIDOW_MINE_BURROWED:
return true;
}
return false;
}
}
если что догадается что это выложу весь код :)