- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
class ProjectIssue(
UserAgentDetailMixin,
SubscribableMixin,
TodoMixin,
TimeTrackingMixin,
ParticipantsMixin,
SaveMixin,
ObjectDeleteMixin,
RESTObject,
):
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+4
class ProjectIssue(
UserAgentDetailMixin,
SubscribableMixin,
TodoMixin,
TimeTrackingMixin,
ParticipantsMixin,
SaveMixin,
ObjectDeleteMixin,
RESTObject,
):
0
.org 80h
data:
db "Hello, world!\n"
wait:
.loop:
inb %cl E9h
cmp %cl 0h
jnz @.loop
ret
start:
mov %sp 300h
.loop:
mov %al [%b + @data]
inc %b
outb E9h %al
call @wait
cmp %al Ah
jnz @.loop
int 0h
забацал port-mapped io, работает в отдельном потоке
sudo bormand
0
function move1(direction: "up" | "down") {
switch (direction) {
case "up":
return 1;
case "down":
return -1;
}
return 0;
}
function main() {
print(move1("up"));
print(move1("down"));
print("done.");
}
а ты умеешь так говнокодить на C/C++?
+1
function main() {
let c = 0;
try {
c++;
print("try");
throw "except";
c--;
print("after catch");
} finally {
c++;
print("finally");
}
assert(2 == c);
}
ну вот и все... проимплементил последний keyword в языке... (осталось только темплейты - ну и головняк меня ждем)
0
package test.sandbox
object Main {
def foo(implicit a: Int): Int = a * 2
def main(args: Array[String]): Unit = {
{
import Test._
val result = foo
println(s"Result1 = $result") // Result1 = 42
}
{
implicit val x = 16
println(s"Result2 = $foo") // Result2 = 32
}
}
}
object Test {
implicit val x: Int = 21
}
"Scala" — сахарная. (*^‿^*)
+2
...
fun([N1, _N2], Trace) ->
?assert(
?strict_causality( #{?snk_kind := "Adding table to a shard", shard := _Shard, live_change := true}
, #{?snk_kind := "Shard schema change"}
, ?of_node(N1, Trace)
)),
?assert(
?strict_causality( #{?snk_kind := "Shard schema change", shard := _Shard}
, #{?snk_kind := "Restarting shard server", shard := _Shard}
, ?of_node(N1, Trace)
)),
%% Schema change must cause restart of the replica process and bootstrap:
{_, Rest} = ?split_trace_at(#{?snk_kind := "Shard schema change"}, Trace),
?assert(
?strict_causality( #{?snk_kind := "Restarting shard server", shard := _Shard}
, #{?snk_kind := state_change, to := bootstrap}
, Rest
))
end).
Немного galaxy-brain тестов
0
using System;
namespace NoName
{
class TwoVariables
{
static void Main(string[] args)
{
Int32 FirstVariable = Convert.ToInt32(Console.ReadLine());
Int32 SecondVariable = Convert.ToInt32(Console.ReadLine());
FirstVariable = FirstVariable + SecondVariable;
SecondVariable = FirstVariable - SecondVariable;
FirstVariable = FirstVariable - SecondVariable;
Console.WriteLine("First Variable is: " + FirstVariable);
Console.WriteLine("Second Variable is: " + SecondVariable);
Console.ReadKey();
}
}
}
// Продам гараж
0
// -------------------------------------------
// 2.2. binary calls
// -------------------------------------------
/*
combination table:
+- | c a n
---|-------
c | C A N
a | A A N
n | N N N
* | c a n
---|-------
c | C A N
a | A N N
n | N N N
/ | c a n
---|-------
c | C N N
a | A N N
n | N N N
argument:
c : constant, as scalar, point, tensor, ect
l : affine homogeneous expr argument: as field, field_indirect or field_expr_node::is_affine_homogeneous
n : function, functor or ! field_expr_node::is_affine_homogeneous
result:
C : constant : this combination is not implemented here
A,N : are implemented here
rules:
at least one of the two args is not of type "c"
when c: c value is embeded in bind_first or bind_second
and the operation reduces to an unary one
when a: if it is a field_convertible, it should be wrapped
in field_expr_v2_nonlinear_terminal_field
when c: no wrapper is need
implementation:
The a and n cases are grouped, thanks to the wrapper_traits
and it remains to cases :
1) both args are field_expr_v2_nonlinear or a function
2) one arg is a field_expr_v2_nonlinear or a function and the second argument is a constant
*/
#define _RHEOLEF_make_field_expr_v2_nonlinear_binary(FUNCTION,FUNCTOR) \
template<class Expr1, class Expr2> \
inline \
typename \
std::enable_if< \
details::is_field_expr_v2_nonlinear_arg<Expr1>::value \
&& details::is_field_expr_v2_nonlinear_arg<Expr2>::value \
&& ! details::is_field_expr_v2_constant <Expr1>::value \
&& ! details::is_field_expr_v2_constant <Expr2>::value \
,details::field_expr_v2_nonlinear_node_binary< \
FUNCTOR \
,typename details::field_expr_v2_nonlinear_terminal_wrapper_traits<Expr1>::type \
,typename details::field_expr_v2_nonlinear_terminal_wrapper_traits<Expr2>::type \
> \
>::type \
FUNCTION (const Expr1& expr1, const Expr2& expr2) \
{ \
typedef typename details::field_expr_v2_nonlinear_terminal_wrapper_traits<Expr1>::type wrap1_t; \
typedef typename details::field_expr_v2_nonlinear_terminal_wrapper_traits<Expr2>::type wrap2_t; \
return details::field_expr_v2_nonlinear_node_binary <FUNCTOR,wrap1_t,wrap2_t> \
(FUNCTOR(), wrap1_t(expr1), wrap2_t(expr2)); \
} \
template<class Expr1, class Expr2> \
inline \
typename \
std::enable_if< \
details::is_field_expr_v2_constant <Expr1>::value \
&& details::is_field_expr_v2_nonlinear_arg<Expr2>::value \
&& ! details::is_field_expr_v2_constant <Expr2>::value \
,details::field_expr_v2_nonlinear_node_unary< \
details::binder_first< \
FUNCTOR \
,typename details::field_promote_first_argument< \
Expr1
0
<!DOCTYPE html>
<html>
<head>
<title>loop ass</title>
</head>
<body>
<script>
function s(){
var a="A and B sat on the pipe!";
alert(a)
alert("A fell!")
alert("B gone!")
alert("who stayed on the pipe?")
prompt(" who stayed on the pipe?")==a[2]+a[3]+a[4]?alert(@):s()
}
s()
</script>
</body>
</html>
Что не так?
0
void s_sort(int *a, size_t sz)
{
if ((sz == 0) || (sz == 1))
{
return;
}
if (sz == 2)
{
int a_max = a[0] > a[1] ? a[0] : a[1];
int a_min = a[0] > a[1] ? a[1] : a[0];
a[0] = a_min;
a[1] = a_max;
return;
}
s_sort(a, sz - 1);
s_sort(a + 1, sz - 1);
s_sort(a, sz - 1);
}
Крайне тупая по своей сути рекурсивная сортировка. Есть ли у нее название?
Вряд ли она имеет какое-то практическое применение именно как сортировка, но зато можно ее переписать на какой-нибудь Coq и об нее доказывать другие сортировки. Типа если какая-то там другая сортировка на всех возможных входных массивах выдает то же, что и выдает вот эта сортировка, то сортировка правильная.