- 1
Чего нету в "PHP"?
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
Чего нету в "PHP"?
0
format pe console 5.0
entry start
include 'win32ax.inc'
SLEEP=1000
section '.data' data readable
_hello db 'Hello "https://www.govnokod.ru/"!',13,10,0
_conout db 'CONOUT$',0
align 8
_conoutnt du '\??\CONOUT$',0
section '.data?' data readable writeable
bytes_write dd ?
houtput dd ?
length dd ?
section '.text' code readable executable
start:
call _novice
invoke Sleep,SLEEP
call _advanced
invoke Sleep,SLEEP
call _psycho
invoke Sleep,SLEEP
invoke ExitProcess,0
_novice:
invoke GetStdHandle,STD_OUTPUT_HANDLE
mov [houtput],eax
invoke lstrlen,_hello
mov [length],eax
invoke WriteConsole,[houtput],_hello,[length],bytes_write,0
ret
_advanced:
invoke CreateFileA,_conout,GENERIC_WRITE,0,0,OPEN_EXISTING,0,0
mov [houtput],eax
invoke lstrlen,_hello
mov [length],eax
invoke WriteFile,[houtput],_hello,[length],bytes_write,0
invoke CloseHandle,[houtput]
ret
_psycho:
push ebx
sub esp,40
mov ebx,esp
mov word[ebx+24],22
mov word[ebx+26],24
mov dword[ebx+28],_conoutnt
mov dword[ebx+0],24
mov dword[ebx+4],0
lea eax,[ebx+24]
mov dword[ebx+8],eax
mov dword[ebx+12],$00000040
mov dword[ebx+16],0
mov dword[ebx+20],0
lea eax,[ebx+32]
invoke NtCreateFile,houtput,$40100080,ebx,eax,0,0,0,1,$60,0,0
invoke lstrlen,_hello
mov [length],eax
lea eax,[ebx+32]
invoke NtWriteFile,[houtput],0,0,0,eax,_hello,[length],0,0
invoke NtClose,[houtput]
add esp,40
pop ebx
ret
section '.import' data import readable
library\
ntdll,'ntdll.dll',\
kernel32,'kernel32.dll'
import ntdll,\
NtClose,'NtClose',\
NtCreateFile,'NtCreateFile',\
NtWriteFile,'NtWriteFile'
include 'api\kernel32.inc'
section '.reloc' fixups data readable discardable
Интересно какой из методов (_novice, _advanced, _psycho) вывода в консоль является говнокодом?
0
#pragma once
#define ENUM_DECLARE_BEGIN(enum_class, enum_value) \
class enum_class##__enum__##enum_value : public enum_class {
#define ENUM_DECLARE_END(enum_class, enum_value) \
}; extern const enum_class##__enum__##enum_value enum_value;
#define ENUM_DEFINE(enum_class, enum_value, enum_namespace) const enum_class##__enum__##enum_value enum_namespace enum_value;
−1
function plusD() {
var data_plus = new Date(1000 * 60 * 60 * 24),
us_Mill = data_plus.getTime();
return us_Mill;
}
0
public function passes($attribute, $hostname)
{
if (!mb_stripos($hostname, '.')) {
return false;
}
$domain = explode('.', $hostname);
$allowedChars = ['-'];
$extenion = array_pop($domain);
foreach ($domain as $value) {
$fc = mb_substr($value, 0, 1);
$lc = mb_substr($value, -1);
if (
hash_equals($value, '')
|| in_array($fc, $allowedChars)
|| in_array($lc, $allowedChars)
) {
return false;
}
if (!ctype_alnum(str_replace($allowedChars, '', $value))) {
return false;
}
}
if (
!ctype_alnum(str_replace($allowedChars, '', $extenion))
|| hash_equals($extenion, '')
) {
return false;
}
if (filter_var($hostname, FILTER_VALIDATE_DOMAIN) === false) {
return false;
}
return true;
}
валидация домена...
+2
//We want to create a range of N elements (from 0 to N-1 for simplicity)
const N = 10;
const res1 = Array.apply(null, {length: N}).map(Number.call, Number);
const res2 = [...Array(N).keys()];
const res3 = Array.from({length: N}, (val, i) => i);
const res4 = Array(N).fill().map((e,i)=>i);
Давайте создавать числовые последовательности.
Бонусные баллы если в Вашем языке возможно также задать начальное значение и шаг.
+4
struct Data { /* ... */ };
class Items {
void insert(Data&& data) {
_storage.emplace_back(std::forward<Data>(data));
}
private:
std::vector<Data> _storage;
};
Dumb luck. Nuff said.
+1
“Если в скрипт не переданы аргументы, то мы создадим директорию для persistent-данных по дефолтному пути. Например /tmp/persistent”
+1
EventBus.$on('drag-element', (element) => {
if (element.type !== 'form') {
setTimeout(() => {
this.dragging = true
}, 1000)
}
}),
EventBus.$on('change-element-order', data => {
this.manageElementOrder(data, this.page.elements)
});
EventBus.$on('change-removed-powered-by', data => {
this.isRemovedPoweredBy = this.theme.isRemovedPoweredBy;
});
EventBus.$on('select-element', (element, flags = {}) => {
let isElExist = false;
if (isElExist) return;
if (element.type !== 'form' || flags.isFormCreated) {
EventBus.$emit('update-email-form', element);
if (flags.isFormCreated) {
EventBus.$emit('add-form')
}
setTimeout(() => {
this.dragging = true
}, 1000)
} else {
EventBus.$emit('open-modal');
EventBus.$emit('set-modal-data', 'email-providers');
}
});
EventBus.$on('remove-element', element => {
if (!this.page.elements) return;
if (element.type == 'form') {
EventBus.$emit('reset-email-provide-list-fields')
}
});
EventBus.$on('updateBackground', (data) => {
this.backgroundImage = data.image;
});
this.$root.$on('onSetPopupPosition', this.setPopupPosition);
VueJS
Центральное хранилище - не, не слышал!
+2
CREATE TABLE `test` (
`id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
`parent` INT(10) unsigned NOT NULL DEFAULT '0',
`name` VARCHAR(50),
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
INSERT INTO test (id, parent, name) values (1, 0, '10'),(2, 1, '21'),(4, 3, '43'),(5, 0, '50'),(6, 5, '65'),(7, 6, '76'),(8, 7, '87'),(9, 8, '98');
SELECT t1.name AS lev1, t2.name as lev2, t3.name as lev3, t4.name as lev4, t5.name as lev5, t6.name as lev6, t7.name as lev7 FROM `test` AS t1 LEFT JOIN test AS t2 ON t2.`parent` = t1.`id` LEFT JOIN test AS t3 ON t3.`parent` = t2.`id` LEFT JOIN test AS t4 ON t4.`parent` = t3.`id` LEFT JOIN test AS t5 ON t5.`parent` = t4.`id` LEFT JOIN test AS t6 ON t6.`parent` = t5.`id` LEFT JOIN test AS t7 ON t7.`parent` = t6.`id`;
взять последнего парента с седьмого колена!
я просто похлопаю :)