- 1
- 2
- 3
https://hr.cetera.ru/tests-developers/
Какой мяуздец )))
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
https://hr.cetera.ru/tests-developers/
Какой мяуздец )))
Внимание, кандидаты в стажёры!
Тестовое задание (поле анкеты «Ссылку на выполненное тестовое задание (ТОЛЬКО ДЛЯ СТАЖЁРОВ).») требуется выполнять сразу. Анкеты без тестового задания не рассматриваем, отказываем сразу. Этот тест — первое, на что смотрит проверяющий анкеты. Если поле пустое или там написано что-то вроде «сделаю потом» — «потом» не будет.
+4
while (1) {
uint16_t state = in(USB_BASE + USB_ISTR);
if (state & 0x8000) {
uint16_t epstat = in(USB_BASE + USB_EP0R);
if (epstat & 0x8000) {
// RX done
if (epstat & 0x0800) {
// setup
if ((usbRead(0x180) == 0x80) && (usbRead(0x181) == 0x06)) {
uint16_t maxlen = (usbRead(0x187) << 8) | usbRead(0x186);
if (usbRead(0x183) == 0x01) {
// send device descriptor
copyToUsb(0x0100, deviceDescriptor, sizeof(deviceDescriptor));
if (sizeof(deviceDescriptor) < maxlen)
maxlen = sizeof(deviceDescriptor);
out(USB_SRAM_BASE + 0x04, 0x9000 + maxlen); // TX count
// STAT_TX=11 (valid)
if ((in(USB_BASE + USB_EP0R) & 0x0010) != 0x0010)
out(USB_BASE + USB_EP0R, 0x0210);
if ((in(USB_BASE + USB_EP0R) & 0x0020) != 0x0020)
out(USB_BASE + USB_EP0R, 0x0220);
} else if (usbRead(0x183) == 0x02) {
// send config descriptor
copyToUsb(0x0100, configDescriptor, sizeof(configDescriptor));
if (sizeof(configDescriptor) < maxlen)
maxlen = sizeof(configDescriptor);
out(USB_SRAM_BASE + 0x04, 0x9000 + maxlen); // TX count
// STAT_TX=11 (valid)
if ((in(USB_BASE + USB_EP0R) & 0x0010) != 0x0010)
out(USB_BASE + USB_EP0R, 0x0210);
if ((in(USB_BASE + USB_EP0R) & 0x0020) != 0x0020)
out(USB_BASE + USB_EP0R, 0x0220);
} else {
// ... и ещё сотня строк в том же духе ...
Иногда в меня вселяется дух PHP...
0
function t_undef(s?: string)
{
assert((s == undefined) == true, "is not undefined")
assert((s != undefined) == false, "is undefined")
assert((s > undefined) == false, "not >");
assert((s < undefined) == false, "not <");
assert((s >= undefined) == true, "not >=");
assert((s <= undefined) == true, "not <=");
}
function t_val(s?: string)
{
assert((s == undefined) == false, "is undefined")
assert((s != undefined) == true, "is not undefined")
assert((s > undefined) == true, ">");
assert((s < undefined) == false, "<");
assert((s >= undefined) == true, ">=");
assert((s <= undefined) == false, "<=");
}
function f(s?: string)
{
print(s == undefined, s != undefined, s > undefined, s < undefined, s >= undefined, s <= undefined);
}
function main() {
f();
t_undef();
f("asd");
t_val("asd");
}
внеочередной говнокод для работы с андефами. А ваш говно-компилятор умеет так (особенно С и С++)
гы гы
+1
vector<int> res;
...
for (int i = 0; i < res.size(); i++) {
printf("%d%c", res[i], " \n"[i + 1 == res.size()]);
}
Решил вспомнить как олимпиадные задачки решать.
+2
function main()
{
f1();
}
function f1(a = 10)
{
return a;
}
// code for 1
module @"1.ts" {
func @main() {
%c0_i32 = constant 0 : i32
%0 = typescript.undef : i32
%1 = call @f1(%c0_i32, %0) : (i32, i32) -> i32
return
}
func private @f1(%arg0: i32, %arg1: i32) -> i32 attributes {OptionalFrom = 1 : i8} {
%c10_i32 = constant 10 : i32
%c1_i32 = constant 1 : i32
%0 = alloca() : memref<i32>
%1 = cmpi ult, %arg0, %c1_i32 : i32
%2 = scf.if %1 -> (i32) {
scf.yield %c10_i32 : i32
} else {
scf.yield %arg1 : i32
}
store %2, %0[] : memref<i32>
%3 = load %0[] : memref<i32>
return %3 : i32
}
}
// code for 2
; ModuleID = 'LLVMDialectModule'
source_filename = "LLVMDialectModule"
target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc"
declare i8* @malloc(i64)
declare void @free(i8*)
define void @main() !dbg !3 {
%1 = call i32 @f1(i32 0, i32 undef), !dbg !7
ret void, !dbg !9
}
define i32 @f1(i32 %0, i32 %1) !dbg !10 {
%3 = alloca i32, i64 ptrtoint (i32* getelementptr (i32, i32* null, i64 1) to i64), align 4, !dbg !11
%4 = insertvalue { i32*, i32*, i64 } undef, i32* %3, 0, !dbg !11
%5 = insertvalue { i32*, i32*, i64 } %4, i32* %3, 1, !dbg !11
%6 = insertvalue { i32*, i32*, i64 } %5, i64 0, 2, !dbg !11
%7 = icmp ult i32 %0, 1, !dbg !11
br i1 %7, label %8, label %9, !dbg !11
8: ; preds = %2
br label %10, !dbg !11
9: ; preds = %2
br label %10, !dbg !11
10: ; preds = %8, %9
%11 = phi i32 [ %1, %9 ], [ 10, %8 ]
br label %12, !dbg !11
12: ; preds = %10
%13 = extractvalue { i32*, i32*, i64 } %6, 1, !dbg !11
store i32 %11, i32* %13, align 4, !dbg !11
%14 = extractvalue { i32*, i32*, i64 } %6, 1, !dbg !11
%15 = load i32, i32* %14, align 4, !dbg !11
ret i32 %15, !dbg !13
}
История о том как я компайлер писал. (предисторию знают думаю все). Посмотрите на код и сравните с ужасным кодом на С. Это простенький javascript который тоже може быть скомпиленным в исполняемый год. а что для этого надо. просто несколько шагов.
1) компилим код через чудо компилятор tsc.exe --emit=mlir-affine c:\1.ts
llc.exe --filetype=obj -o=out.o 1.ll
0
# ------------------- fUnicodeToUTF8----------------------
:global fUnicodeToUTF8
:if (!any $fUnicodeToUTF8) do={ :global fUnicodeToUTF8 do={
:global fByteToEscapeChar
# :local Ubytes [:tonum $1]
:local Nbyte
:local EscapeStr ""
:if ($1 < 0x80) do={
:set EscapeStr [$fByteToEscapeChar $1]
} else={
:if ($1 < 0x800) do={
:set Nbyte 2
} else={
:if ($1 < 0x10000) do={
:set Nbyte 3
} else={
:if ($1 < 0x20000) do={
:set Nbyte 4
} else={
:if ($1 < 0x4000000) do={
:set Nbyte 5
} else={
:if ($1 < 0x80000000) do={
:set Nbyte 6
}
}
}
}
}
:for i from=2 to=$Nbyte do={
:set EscapeStr ([$fByteToEscapeChar ($1 & 0x3F | 0x80)] . $EscapeStr)
:set $1 ($1 >> 6)
}
:set EscapeStr ([$fByteToEscapeChar (((0xFF00 >> $Nbyte) & 0xFF) | $1)] . $EscapeStr)
}
:return $EscapeStr
}}
угадай язык
+1
void tick(void)
{
for (auto&& x : registry.objects)
(x? std::function<void(void)>([&](void) {((IObject*)(x))->tick(); }) : [&]() {})();
}
Мозг сказал что "((IObject*)(x))->tick();" написать слишком сложно и повелел написать вот это.
+3
function strEqual(string a, string b) private returns (bool) {
return sha3(a) == sha3(b);
}
Как проверить идентичность строк, если ты криптовалютчик?
https://github.com/axic/mango/blob/83ef808eba1571097fecd8d8e08303a82f69d68c/MangoRepo.sol#L83-L85
0
// ==UserScript==
// @name Unnamed Script 230178
// @version 1
// @grant none
// @include https://www.instagram.com/*
// ==/UserScript==
window.addEventListener('load', function(){
console.log("my script starting...");
const body = document.querySelector('body');
const config = {
attributes: true,
attributeFilter: ["style"]
};
const callback = function(mutationsList, observer) {
console.log("mutation aaargh-aaarghrghrhg");
for (let mutation of mutationsList) {
console.log('zaloop');
// if (mutation.type === 'attributes' && mutation.attributeName === 'style') {
try {
body.setAttribute('style', '');
document.querySelector('.RnEpo').setAttribute('style', 'display: none;');
observer.disconnect();
console.log("#hide");
} catch (e) {
console.log(e);
}
// }
}
};
const observer = new MutationObserver(callback);
observer.observe(body, config);
console.log("my script stop");
});
Ночью не спал
Инстаграм листал
Чтобы баннер не мешал
Такой скрипт написал.
+1
<?php
namespace App\Http\Controllers\Admin;
use App\Command\Admin\User\Create\Command as UserCreateCommand;
use App\Command\Admin\User\Update\Command as UserUpdateCommand;
use App\Command\Admin\User\Remove\Command as UserRemoveCommand;
use App\Command\User\Auth\Verify\Command as UserVerifyCommand;
use App\Command\Admin\User\Draft\Command as UserDraftCommand;
use App\Command\CommandBus;
use App\Entity\User\User;
use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\Users\CreateRequest;
use App\Http\Requests\Admin\Users\UpdateRequest;
use App\Query\Admin\User\FindUsersByDescQuery;
use App\Query\Admin\User\Role\GetUserRolesQuery;
use App\Query\Admin\User\Status\GetUserStatusesQuery;
use App\Query\QueryBus;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;
class UsersController extends Controller
{
private $commandBus;
private $queryBus;
public function __construct(CommandBus $commandBus, QueryBus $queryBus)
{
$this->commandBus = $commandBus;
$this->queryBus = $queryBus;
}
public function index()
{
$query = $this->queryBus->query(new FindUsersByDescQuery());
$users = $query->paginate(20);
$statuses = $this->queryBus->query(new GetUserStatusesQuery());
$roles = $this->queryBus->query(new GetUserRolesQuery());
return view('admin.users.index', compact('users', 'statuses', 'roles'));
}
public function create()
{
return view('admin.users.create');
}
public function store(CreateRequest $request)
{
$this->commandBus->handle(new UserCreateCommand($request));
return redirect()->route('admin.users.index');
}
public function show(User $user)
{
return view('admin.users.show', compact('user'));
}
public function edit(User $user)
{
$roles = $this->queryBus->query(new GetUserRolesQuery());
return view('admin.users.edit', compact('user', 'roles'));
}
public function update(UpdateRequest $request, User $user)
{
$this->commandBus->handle(new UserUpdateCommand($request, $user));
return redirect()->route('admin.users.index');
}
public function destroy(User $user)
{
$this->commandBus->handle(new UserRemoveCommand($user));
return redirect()->route('admin.users.index');
}
public function verify(User $user)
{
$this->commandBus->handle(new UserVerifyCommand($user));
return redirect()->route('admin.users.show', $user);
}
public function draft(User $user)
{
$this->commandBus->handle(new UserDraftCommand($user));
return redirect()->route('admin.users.show', $user);
}
}