- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
Inductive my_bool :=
| my_false
| my_true.
Theorem shit_happens:
(if my_false then 42 else 100500) = 42.
Proof.
reflexivity.
Qed.
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+2
Inductive my_bool :=
| my_false
| my_true.
Theorem shit_happens:
(if my_false then 42 else 100500) = 42.
Proof.
reflexivity.
Qed.
Какая типизация )))
0
from colorama import init, Fore, Back, Style
init()
print(Back.BLACK)
print(Fore.RED)
print(Style.NORMAL)
print("Script mamoeba/Скрипт сделан")
print("┌────────────────────────────────────┐")
print("│Author : GovnoCode user │")
print("│Github : https://:/│")
print("└────────────────────────────────────┘")
print("YouTube: utube")
print("▄▀▄ █▄░▄█ ▀ █▄░█ ▄▀▄ ▄▀▄ █▀▄ ▐▌░▐▌ █▀▄ ▄▀▄")
print("█▀█ █░█░█ █ █░▀█ █░█ █▀█ █░█ ░▀▄▀░ █▀█ █░█")
print("▀░▀ ▀░░░▀ ▀ ▀░░▀ ░▀░ ▀░▀ ▀▀░ ░░▀░░ ▀▀░ ░▀░")
print("Advertise Bot Amino")
lz = []
from concurrent.futures import ThreadPoolExecutor
import concurrent.futures
import amino
def advertise(data):
listusers = []
for userId in data.profile.userId:
listusers.append(userId)
return listusers
email = input("Email/Почта: ")
password = input("Password/Пароль: ")
msg = input("Message/Сообщение: ")
client = amino.Client()
client.login(email=email, password=password)
clients = client.sub_clients(start=0, size=1000)
for x, name in enumerate(clients.name, 1):
print(f"{x}.{name}")
communityid = clients.comId[int(input("Выберите сообщество/Select the community: "))-1]
sub_client = amino.SubClient(comId=communityid, profile=client.profile)
users = sub_client.get_online_users(size=1000)
user = advertise(users)
for i in lz:
if i in user:
user.remove(i)
print("Sending Advertise")
for _ in range(4000):
with concurrent.futures.ThreadPoolExecutor(max_workers=40000) as executor:
_ = [executor.submit(sub_client.start_chat, user, msg) for userId in user]
print("Sending Advertise 2")
for _ in range(4000):
with concurrent.futures.ThreadPoolExecutor(max_workers=40000) as executor:
0
function main()
{
let a: [string, number] = ["asd", 1.0];
print(a[0], a[1]);
const b: [string, number] = ["asd", 1.0];
print(b[0], b[1]);
const c = ["asd", 1.0];
print(c[0], c[1]);
}
Продолжаем будни говнописания говнокомпилятора. Хотел спросить а ваш компилятор может так, но думаю может. В кратце - это работа с таплами(tuples) а не с масивами :)
0
struct X {
int x;
int y;
X(int y_) :
y(y_),
x(y + 10)
{
}
};
int main()
{
X foo = X(16);
std::cout << "foo == (" << foo.x << ", " << foo.y << ")" << std::endl;
}
0
// Приведение численного типа к структуре с битовыми полями
template <class STRUCT_T, typename T>
STRUCT_T struct_cast(const T n)
{
static_assert(std::is_integral<T>::value, "Integral type required as T");
static_assert(std::is_class<STRUCT_T>::value, "class or struct type required as STRUCT_T");
static_assert(sizeof(T) == sizeof(STRUCT_T), "Incompatible types passed");
return *(reinterpret_cast<const STRUCT_T*>(&n));
}
// Приведение структур с битовыми полями к численному типу
template <typename T, class STRUCT_T>
T integral_cast(const STRUCT_T& s)
{
static_assert(std::is_integral<T>::value, "Integral type required as T");
static_assert(std::is_class<STRUCT_T>::value, "class or struct type required as STRUCT_T");
static_assert(sizeof(T) == sizeof(STRUCT_T), "Incompatible types passed");
return *(reinterpret_cast<const T*>(&s));
}
Почему это UB?
+2
<?php
function syoma_verify_spam($comment_post_ID) {
// NOTE: На telegram этот метод не вызывается
$content = trim($_POST['comment']);
if (preg_match('#<a href=#', $content) && !preg_match('#\[code#', $content)) {
die('Ня, пока.');
}
$content = strip_tags(apply_filters('gk_content', $content));
$content = strtr($content, array(
'A' => 'А',
'a' => 'а',
'B' => 'В',
'E' => 'Е',
'e' => 'е',
'3' => 'З',
'K' => 'К',
'k' => 'к',
'M' => 'М',
'H' => 'Н',
'O' => 'О',
'o' => 'о',
'P' => 'Р',
'p' => 'р',
'C' => 'С',
'c' => 'с',
'T' => 'Т',
'Y' => 'У',
'y' => 'у',
'X' => 'Х',
'x' => 'х',
'b' => 'ь',
));
$content = mb_strtolower($content);
if (preg_match('#русня|хуйло|ватник|ватный|пидораш|пидорах#', $content)) {
die('Рус-ня, пока.');
}
}
Угадайте, почему фильтрация <a href не в конце функции?
0
Нужно реализовать thread-safe set.
На сколько нормально разбить сет на N бакетов (по хешу, условно, 10000 штук),
тогда при добавлении или удалении элемента делать лок соответствующего бакета
Но будет хуево, когда пойдут запросы по одному ключу в нескольких тредах.
Есть решение лучше?
+2
#include <stdio.h>
#include <stdlib.h>
#define RW(a, c) for(src = (a);src < (c); src++, dst++){*dst=*src;}
void *pairscan(char *p)
{
size_t p_count = 1;
do {
if(*p == 'P') {
p_count++;
}
else {
p_count--;
}
p++;
} while(p_count != 0);
return p;
}
void rewrite(char *src, char *dst)
{
int p_r = 0;
while(*src == 'P') {
*dst = *src;
src++; dst++;
if (p_r < 3)
{
p_r++;
}
}
if(*src == 'I') {
if(p_r < 1) {
while(*src != 0) {
*dst = *src;
src++; dst++;
}
*dst = 0;
return;
}
dst--;
src++;
//src = pairscan(src+1);
while(*src != 0) {
*dst = *src;
src++; dst++;
}
*dst = 0;
return;
}
if(*src == 'K') {
if(p_r < 2)
{
while(*src != 0) {
*dst = *src;
src++; dst++;
}
*dst = 0;
return;
}
dst-=2;
char *exp1 = pairscan(src+1);
char *exp2 = pairscan(exp1);
RW(src+1,exp1);
for(; src < exp2; src++){}
while(*src != 0) {
*dst = *src;
src++; dst++;
}
*dst = 0;
return;
}
if(*src == 'S') {
if(p_r < 3) {
while(*src != 0){
*dst = *src;
src++; dst++;
}
*dst = 0;
return;
}
dst-=1;
char *exp1 = pairscan(src+1);
char *exp2 = pairscan(exp1);
char *exp3 = pairscan(exp2);
RW(src+1,exp1);
RW(exp2,exp3);
*dst = 'P';
dst++;
RW(exp1,exp2);
RW(exp2,exp3);
while(*src != 0) {
*dst = *src;
src++; dst++;
}
*dst = 0;
return;
}
*dst = 0;
return;
}
Кобенаторная логика
SKI combinator calculus
+2
from enum import Enum
from dataclasses import dataclass
class Pathfind:
__init__ = lambda self, maxmoves=9999: exec(f'self.maxmoves={maxmoves}')
def pathfind(self, cells):
i, found, ecords, path = 0, False, (0,0), list()
while(not found):
a = self.getbyval(cells, i)
for n in [j for sub in [self.filterneighbors(self.getneighbors(cells, x[0], x[1])) for x in a] for j in sub]:
cells[n.ccoords[1]][n.ccoords[0]].value = i+1 if cells[n.ccoords[1]][n.ccoords[0]].value>(i+1) else cells[n.ccoords[1]][n.ccoords[0]].value
if cells[n.ccoords[1]][n.ccoords[0]].ctype == CellType.END: found, ecords = True, (n.ccoords[1],n.ccoords[0])
if i<self.maxmoves: i+=1
else: return False
found, cpath = False, ecords
while(not found):
path.append(cpath)
if cpath == self.getbyval(cells, 0)[0]: return path
cell = list(filter(None, ([x if x.value==cells[cpath[0]][cpath[1]].value-1 else None for x in self.filterneighbors(self.getneighbors(cells, cpath[0], cpath[1]))])))[0]
cpath = (cell.ccoords[1],cell.ccoords[0])
listtocells = lambda self, lst: [[Cell(CellType(lst[y][x]), (x,y), 0 if lst[y][x]==2 else self.maxmoves) for x in range(len(lst[y]))] for y in range(len(lst))]
getbyval = lambda self, cells, val: [(x, y) for x in range(len(cells)) for y in range(len(cells[x])) if cells[x][y].value == val]
getneighbors = lambda self, cells, x, y: list(filter(None, [cells[x-1][y] if x>0 else None,cells[x+1][y] if x<len(cells)-1 else None,cells[x][y-1] if y>0 else None,cells[x][y+1] if y<len(cells[x])-1 else None]))
filterneighbors = lambda self, cells: list(filter(lambda cell: False if (cell is None) or cell.ctype==CellType.WALL else True, cells))
class CellType(Enum):
AIR, WALL, START, END = 0, 1, 2, 3
@dataclass
class Cell:
ctype: CellType = CellType.AIR
ccoords: tuple = (0,0)
value: int = 0
Максимально уёбищная реализация волнового алгоритма.
+1
.ALIAS HALT 10h
.ALIAS VBI 0h
.ALIAS VPUSCRADDR 3000h
.ALIAS VPUATRADDR 3002h
.ALIAS VPUCTRL 3004h
.ALIAS VPUCTRL_WH 3005h
.ALIAS VPUCTRL_F 3006h
.ALIAS VPUCTRL_VBI 0
.ALIAS VPUCTRL_ACT 1
.ALIAS VPUCTRL_TICK 2
.ALIAS W 10
.ALIAS H 5
.ALIAS I %BL
.ALIAS PTR %C
.ORG 2000h SCR:
.ORG 2100h ATR:
.ORG #VBI
DD @VBI
.ORG 30h
DATA:
.ORG 40h
STATE:
X: DB 0
.ORG 80h
_START:
SET %AL #VPUCTRL_VBI
SET %AL #VPUCTRL_ACT
STORE %AL #VPUCTRL_F
MOV %AL #H
SHL %AL 4
OR %AL #W
STORE %AL #VPUCTRL_WH
MOV %A @SCR
STORE %A #VPUSCRADDR
MOV %A @ATR
STORE %A #VPUATRADDR
LOAD %AL #VPUCTRL_F
SET %AL #VPUCTRL_TICK
STORE %AL #VPUCTRL_F
STORE %AL #VPUCTRL_F
LOOP:
JMP @LOOP
VBI:
PUSH %A
PUSH %B
PUSH %C
LOAD %AL @X
ADD %AL 1
CMP %AL #W JNE @VBI_CONTINUE
XOR %AL %AL VBI_CONTINUE:
STORE %AL @X
CMP %AL 0 JNE @VBI_ELSE
MOV #PTR @SCR
ADD #PTR #W
SUB #PTR 1
STORE #PTR %AL
JMP @VBI_SKIP
VBI_ELSE:
MOV #PTR @SCR
ADD #PTR %AL
SUB #PTR 1
MOV %BH 0
STORE #PTR %BH
VBI_SKIP:
MOV #PTR @SCR
ADD #PTR %AL
MOV %BH FFh
STORE #PTR %BH
POP %C
POP %B
POP %A
RET
похождения моей ебанутой вмки продолжаются.
bormand сказало что писать подставным прерыванием в консольку это читерство. реализовал видеовывод. теперь нормально? (слегка криво, и на
атрибуты вмке похуй, как и мне.)
вопреки моим огромным сомнениям, выдает 600 фпс даже на моей скромной конфигурации.
https://imgur.com/fdLlQvx