- 1
- 2
- 3
- 4
q)\l sp.q
+`p`city!(`p$`p1`p2`p3`p4`p5`p6`p1`p2;`london`london`london`london`london`lon..
(`s#+(,`color)!,`s#`blue`green`red)!+(,`qty)!,900 1000 1200
+`s`p`qty!(`s$`s1`s1`s1`s2`s3`s4;`p$`p1`p4`p6`p2`p2`p4;300 200 100 400 200 300)
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
q)\l sp.q
+`p`city!(`p$`p1`p2`p3`p4`p5`p6`p1`p2;`london`london`london`london`london`lon..
(`s#+(,`color)!,`s#`blue`green`red)!+(,`qty)!,900 1000 1200
+`s`p`qty!(`s$`s1`s1`s1`s2`s3`s4;`p$`p1`p4`p6`p2`p2`p4;300 200 100 400 200 300)
https://code.kx.com/q/learn/tour/
+1
The authenticity of host 'ololo.fike.nemyx (<ip address>)' can't be established.
fingerprint is SHA256:ololo.
Are you sure you want to continue connecting
? (Y/N) Y
I have no idea what to do with 'Y'
Just say Y or N, please.
The authenticity of host 'ololo.fike.nemyx (<ip address>)' can't be established.
fingerprint is SHA256:ololo.
Are you sure you want to continue connecting
? (Y/N) y
Connecting to ololo.fike.nemyx
Chef
0
# TODO: fix this shit
def publish(self, session: requests.Session, auth_cookie: str, max_retries: int, retry_time: float) -> bool:
for i in range(max_retries):
L.info(f'PostForm.publish(), loading attempt #{i + 1}')
if self.load_new(session, auth_cookie):
break
time.sleep(retry_time)
else: # No break
L.error('PostForm.publish(): could not load the form')
return False
for i in range(max_retries):
L.info(f'PostForm.publish(), posting attempt #{i + 1}')
if not self.try_recognize_captcha(session):
time.sleep(retry_time)
continue # Load an another captcha with the same csrf/captcha_id
if self.try_post(session, auth_cookie) == PostForm.Status.POST_DONE:
return True
time.sleep(retry_time)
L.error(f'PostForm.publish() failed, max_retries exceeded')
return False
Блять, отвратительно.
0
https://habr.com/ru/company/ruvds/blog/514776/
0
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdint.h>
#define GEN_NAME(type) struct myvec_ ## type
#define MK_VEC_TYPE(type) GEN_NAME(type) {size_t sz; type arr[];};
#define MK_VEC_NEW(type) \
GEN_NAME(type) *myvec_new_ ## type (size_t num) \
{ \
struct myvec_ ## type *tmp = malloc(sizeof(type) * num); \
if (tmp == NULL) \
{ \
return NULL; \
} \
tmp->sz = num; \
return tmp; \
}
#define MK_VEC_DELETE(type) \
void myvec_delete_ ## type (GEN_NAME(type) *v) \
{ \
free(v); \
}
#define MK_VEC_GET(type) \
type myvec_get_ ## type (GEN_NAME(type) *v, size_t pos) \
{ \
if(pos < v->sz) \
{ \
return v->arr[pos]; \
} \
else \
{ \
exit(-1); \
} \
}
// исключения - говно
#define MK_VEC_SET(type) \
void myvec_set_ ## type (GEN_NAME(type) *v, size_t pos, type val) \
{ \
if(pos < v->sz) \
{ \
v->arr[pos] = val; \
} \
else \
{ \
exit(-1); \
} \
}
#define MK_VEC_GETSZ(type) \
size_t myvec_getsz_ ## type (GEN_NAME(type) v) \
{ \
return v.sz; \
}
#define MK_SHIT(type) \
MK_VEC_TYPE(type) \
MK_VEC_NEW(type) \
MK_VEC_DELETE(type) \
MK_VEC_GET(type) \
MK_VEC_GETSZ(type) \
MK_VEC_SET(type)
MK_SHIT(int)
MK_SHIT(float)
MK_SHIT(double)
#define test(a) _Generic(a, int : 1, GEN_NAME(int) : 2, default : 0)
#define MTD_C(val,mtd) _Generic( val,\
GEN_NAME(int): myvec_ ## mtd ##_int, \
GEN_NAME(float): myvec_ ## mtd ##_float, \
GEN_NAME(double): myvec_ ## mtd ##_double, \
default: 0) // хуй там!
#define GET(vec,pos) MTD_C(vec,get)(&vec,pos)
#define SET(vec, pos, val) MTD_C(vec,set)(&vec,pos,val)
#define GETSZ(vec) MTD_C(vec,getsz)(vec)
int main(void)
{
GEN_NAME(int) *vec1 = myvec_new_int(10);
SET(*vec1, 0, 123);
size_t size = GETSZ(*vec1);
printf("vector size is %zu\n", size);
printf("vector vec1[0] is %d\n", GET(*vec1,0));
return 0;
}
Какое ООП)))
+1
// Both set_time_limit(...) and ini_set('max_execution_time',...); won't count the time cost of sleep,
// file_get_contents,shell_exec,mysql_query etc, so i build this function my_background_exec(),
// to run static method/function in background/detached process and time is out kill it:
// my_exec.php:
<?php
function my_background_exec($function_name, $params, $str_requires, $timeout=600)
{$map=array('"'=>'\"', '$'=>'\$', '`'=>'\`', '\\'=>'\\\\', '!'=>'\!');
$str_requires=strtr($str_requires, $map);
$path_run=dirname($_SERVER['SCRIPT_FILENAME']);
$my_target_exec="/usr/bin/php -r \"chdir('{$path_run}');{$str_requires} \\\$params=json_decode(file_get_contents('php://stdin'),true);call_user_func_array('{$function_name}', \\\$params);\"";
$my_target_exec=strtr(strtr($my_target_exec, $map), $map);
$my_background_exec="(/usr/bin/php -r \"chdir('{$path_run}');{$str_requires} my_timeout_exec(\\\"{$my_target_exec}\\\", file_get_contents('php://stdin'), {$timeout});\" <&3 &) 3<&0";//php by default use "sh", and "sh" don't support "<&0"
my_timeout_exec($my_background_exec, json_encode($params), 2);
}
// ...
Шедевр (заплюсованный) из https://www.php.net/manual/ru/function.set-time-limit.php.
−1
else if (BallToDown(paddle_2, paddle_2_pos, new Rectangle((int)ball_pos.X, (int)ball_pos.Y, ball.Width, ball.Height)))
{
Paddle_s.Play();
ballSpeed = new Vector2(9.0f, 4.5f);
}
/*Левая Ракетка*/
//Ограничения по Оси Y
if (paddle_2_pos.Y < 0)
paddle_2_pos.Y = 0;
else if (paddle_2_pos.Y > Window.ClientBounds.Height - paddle_2.Height)
paddle_2_pos.Y = Window.ClientBounds.Height - paddle_2.Height;
//Управление Ракеткой
if (Keyboard.GetState().IsKeyDown(Keys.W))
paddle_2_pos.Y -= speed;
else if (Keyboard.GetState().IsKeyDown(Keys.S))
paddle_2_pos.Y += speed;
/*Правая Ракетка*/
//Ограниччения по Оси Y
if (paddle_1_pos.Y < 0)
paddle_1_pos.Y = 0;
else if (paddle_1_pos.Y > Window.ClientBounds.Height - paddle_1.Height)
paddle_1_pos.Y = Window.ClientBounds.Height - paddle_1.Height;
//Управление Ракеткой
if (Keyboard.GetState().IsKeyDown(Keys.Up))
paddle_1_pos.Y -= speed;
else if (Keyboard.GetState().IsKeyDown(Keys.Down))
paddle_1_pos.Y += speed;
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.Black);
spriteBatch.Begin();
spriteBatch.Draw(paddle_1, paddle_1_pos, Color.White);
spriteBatch.Draw(paddle_2, paddle_2_pos, Color.White);
spriteBatch.Draw(ball, ball_pos, Color.White);
spriteBatch.End();
base.Draw(gameTime);
}
public bool BallToUp(Texture2D paddle, Vector2 paddle_pos, Rectangle ballRect)
{
/*Создаётся прямоугольник размером 1/3 от всей ракетки*/
Rectangle paddleRect = new Rectangle((int)paddle_pos.X, (int)paddle_pos.Y, paddle.Width, (int)paddle.Height / 2);
return ballRect.Intersects(paddleRect);
}
public bool BallToDown(Texture2D paddle, Vector2 paddle_pos, Rectangle ballRect)
{
/*Создаётся прямоугольник размером 1/3 от всей ракетки*/
Rectangle paddleRect = new Rectangle((int)paddle_pos.X, (int)paddle_pos.Y + (paddle.Height / 2), paddle.Width, (int)paddle.Height / 2);
return ballRect.Intersects(paddleRect);
}
}
}
Недавно начал программировать на C#, Решил написать Пин-Понг на моногейм, Плучилось нечто но работает отлично: отрывок кода сверху
+2
List<UserScoreDTO> userScores = users.stream()
.map((u) -> ScoreUtils.aggregateUserAndFlagData(u, maxTestScore))
.collect(toList());
return userScores.stream();
Collect to List<UserScoreDTO> then stream the list to Stream<UserScoreDTO>
0
# while 1 через for
shits = ['говно']
for shit in shits:
print('Говно')
shits.append('говно')
Прост while 1 через for
+1
吾有一術。名之曰「斐波那契」。欲行是術。必先得一數。曰「甲」。乃行是術曰。
若「甲」等於零者乃得零也
若「甲」等於一者乃得一也
減「甲」以一。減「甲」以二。名之曰「乙」。曰「丙」。
施「斐波那契」於「乙」。名之曰「丁」。
施「斐波那契」於「丙」。名之曰「戊」。
加「丁」以「戊」。名之曰「己」。
乃得「己」。
是謂「斐波那契」之術也。
施「斐波那契」於十二。書之。
文言 wenyan-lang
Числа Фибоначчи.
https://github.com/wenyan-lang/wenyan