- 1
- 2
@Test
public void getTestcases_OffsetEqTwoAndLomitEqTen_ReturnTwoTestcasesInResponse()
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
@Test
public void getTestcases_OffsetEqTwoAndLomitEqTen_ReturnTwoTestcasesInResponse()
Йажа - это не язык программирования, это состояние сознания
0
template <typename T, size_t size>
pure_nfsv4_op_array_tools::get_max_priority_opindex(
const std::array<T, size>& array, const std::unordered_map<uint32_t, uint32_t>& priority_map size_t pos = 0)
{
std::unordered_map<uint32_t, uint32_t>::const_iterator it, it_end = priority_map.end();
uint32_t max_priority = 0;
size_t i_max_priority = size;
for(; pos < size; ++pos)
{
it = priority_map.find(array[pos].opcode)
priority = (it != it_end) ? it->second : 4; // Анскилл
// лучше так:
// priority = get_priority(opcode);
if (priority > max_priority)
{
i_max_priority = pos;
max_priority = it->second;
}
}
return i_max_priority;
}
Какой дизайн-паттерн применить, если priority_map содержится в классе, методы которого используют эту функцию как вспомогательную?
То есть текущий файл подключается в файл-декларацию класса?
Можно, конечно, подключить его в .cc, но проблема останется.
+2
nameState() {
return this.name.length > 2 ? true : false
}
Из документации Bootstrap Vue
https://bootstrap-vue.org/docs/components/form-input#contextual-states
+2
function isNative (Ctor){
return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
}
https://habr.com/ru/company/ruvds/blog/503634/
>>> 5 интересных JavaScript-находок, сделанных в исходном коде Vue
−1
let windows = [];
for(let i=0;i<30;i++) {
windows.push(open('about:blank', 'w'+i, 'width=220,height=220'));
windows[windows.length-1].document.write('<img width="200" src="https://yandex.ru/images/_crpd/QXyR57D17/58778cEG/ztbSEyQN1MQPOKIh-mQphsVGWJdV_rEIEfYazmN1g0xPpX0igbVWfIKWpfMEAObKC6K6ZWrKj3oC51h2Nj70EtoS5kOEGYXVP10XoFpA">');
}
let x = 0;
for(let i=0;i<30;i++) {
setTimeout(function run() {
if(x > 10000) {
windows[i].close();
return;
}
x++;
windows[i].moveTo((Math.random()*screen.width).toFixed(), (Math.random()*screen.height).toFixed());
setTimeout(run, 100);
});
}
Мой лучший гавнакод
+1
#include <stdbool.h>
bool impl(bool a, bool b) // ->
{
return (!a || b);
}
bool always_true(bool a, bool b)
{
return (impl(a,b) == impl(b,a)) == (a == b); // ( (a -> b) = (b -> a) ) = (a = b) tautology
}
/*
GCC не хочет мне тавтологию оптимизировать!
https://godbolt.org/z/kgFMpR
always_true:
movl %esi, %eax
xorl %edi, %eax
cmpb %dil, %sil
sete %dl
xorl %edx, %eax
ret
Но Clang может
https://godbolt.org/z/YcOat-
always_true: # @always_true
movb $1, %al
retq
*/
ГОВНО!
+2
<script>
qqq = 0;
setInterval(function(){
qqq++;
if ( qqq == 1 ) $('.qqq').text('.');
else if ( qqq == 2 ) $('.qqq').text('..');
else if ( qqq == 3 ) $('.qqq').text('...');
else {
$('.qqq').empty();
qqq = 0;
}
},900);
</script>
Многоточия...
Встретил случайно в одном из сайтов)
+2
import ctypes, sys
if ctypes.windll.shell32.IsUserAnAdmin():
if __name__ == "__main__":
main()
else:
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1)
Ав тозапуск с пра вами адми нис тра тора
Для авто запус ка мы будем исполь зовать сле дующий код:
Те перь при попыт ке запус тить скрипт вызов будет передан на UAC (если акти‐
вен) и откро ется новое окно тер минала, где наш код выпол нится от име ни
адми нис тра тора.
Ес ли такой вари ант не устра ивает, то всег да мож но вос поль зовать ся
готовы ми решени ями.
--------------
Ксакеп. if __name__ == "__main__" не там стоит, автор не понял что это такое.
+1
;;; the toplevel operators of each equation in the system
;;; type : array[term]
(defmacro match-acz-state-methods (state__) `(svref ,state__ 0))
;;; functional terms
;;; type : array[term]
(defmacro match-acz-state-lhs-f (state__) `(svref ,state__ 1))
;;; variables on the LHS
;;; type : array[term]
(defmacro match-acz-state-lhs-v (state__) `(svref ,state__ 2))
;;; contants on the RHS
;;; type : array[term]
(defmacro match-acz-state-rhs-c (state__) `(svref ,state__ 3))
;;; functional terms on RHS
;;; type : array[term]
(defmacro match-acz-state-rhs-f (state__) `(svref ,state__ 4))
;;; notes repeated functional terms of LHS
;;; type : array[bool]
(defmacro match-acz-state-lhs-f-r (state__) `(svref ,state__ 5))
;;; notes repeated variables of LHS
;;; type : array[bool]
(defmacro match-acz-state-lhs-v-r (state__) `(svref ,state__ 6))
;;; notes repeated constants of RHS
;;; type : array[bool]
(defmacro match-acz-state-rhs-c-r (state__) `(svref ,state__ 7))
;;; notes repreated funcational terms of RHS
;;; type : array[bool]
(defmacro match-acz-state-rhs-f-r (state__) `(svref ,state__ 8))
;;; variables and funs acocunted for by RHS-c-sol
;;; type : fixnum
(defmacro match-acz-state-lhs-mask (state__) `(svref ,state__ 9))
;;; funs accounted for by RHS-c-sol
;;; type : fixnum
(defmacro match-acz-state-lhs-f-mask (state__) `(svref ,state__ 10))
;;; bit vector of all repeated (> 0) terms on LHS
(defmacro match-acz-state-lhs-r-mask (state__) `(svref ,state__ 11))
;;; solution matrix for constants
;;; type : array[fixnum]
(defmacro match-acz-state-rhs-c-sol (state__) `(svref ,state__ 12 ))
;;; max value of elements of RHS-C-sol
;;; type : fixnum
(defmacro match-acz-state-rhs-c-max (state__) `(svref ,state__ 13))
;;; solutions matrix; functional terms
;;; type : array[fixnum]
(defmacro match-acz-state-rhs-f-sol (state__) `(svref ,state__ 14))
;;; max value of elements of RHS-f-sol
;;; type : fixnum
(defmacro match-acz-state-rhs-f-max (state__) `(svref ,state__ 15))
;;; type : fixnum 11111 ... 1111
(defmacro match-acz-state-rhs-full-bits (state__) `(svref ,state__ 16))
;;; array of compatibility bitvectors; constants
;;; type : array[fixnum]
(defmacro match-acz-state-rhs-c-compat (state__) `(svref ,state__ 17))
;;; array of compatibility bitvectors; funcs
;;; type : array[fixnum]
(defmacro match-acz-state-rhs-f-compat (state__) `(svref ,state__ 18))
;;; number of constants on LHS after simplification
;;; type : fixnum
(defmacro match-acz-state-lhs-c-count (state__) `(svref ,state__ 19))
;;; number of functions on LHS after simplification
;;; type : fixnum
(defmacro match-acz-state-lhs-f-count (state__) `(svref ,state__ 20))
;;; number of variables on LHS after simplification
;;; type : fixnum
(defmacro match-acz-state-lhs-v-count (state__) `(svref ,state__ 21))
;;; number of constants on RHS after simplification
;;; type : fixnum
(defmacro match-acz-state-rhs-c-count (state__) `(svref ,state__ 22))
;;; number of functions on RHS after simplification
;;; type : fixnum
(defmacro match-acz-state-rhs-f-count (state__) `(svref ,state__ 23))
;;; t iff all solutions have been reported.
(defmacro match-acz-state-no-more (state__) `(svref ,state__ 24))
https://github.com/CafeOBJ/cafeobj/blob/master/chaos/e-match/match-acz.lisp−3
Вот прога на C#:
using System;
namespace SomeNamespace
{
class SomeProgram
{
public static void Main(string[] args)
{
ulong input = ulong.Parse(Console.ReadLine());
int counter = 0;
Console.Write(input + " ");
while(input != 3)
{
switch(input % 3)
{
case 0:
input /= 3;
Console.Write("/ 3 = " + input + " ");
counter++;
break;
case 1:
input--;
Console.Write("- 1 = " + input + " ");
counter++;
break;
case 2:
input++;
Console.Write("+ 1 = " + input + " ");
counter++;
break;
}
}
Console.WriteLine("\n3 reached. Number of moves: " + counter);
}
}
}
А вот на питонии:
inpt = int(input())
counter = 0
print(str(inpt),end=' ')
while not (inpt==3):
if not(inpt%3==0):
if inpt % 3 == 1:
inpt -= 1
print("- 1 = "+str(inpt),end=' ')
counter += 1
else:
inpt += 1
print("+ 1 = "+str(inpt),end=' ')
counter += 1
else:
inpt //= 3
print("/ 3 = "+str(inpt),end=' ')
counter += 1
else:
print("\n3 reached. Number of moves: "+str(counter),end='',flush=True)
И вот теперь скажите что-то, почему C# лучше питона.