- 1
IT Оффтоп #36
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
IT Оффтоп #36
#2: https://govnokod.ru/18378 https://govnokod.xyz/_18378
#3: https://govnokod.ru/19667 https://govnokod.xyz/_19667
#4: https://govnokod.ru/21160 https://govnokod.xyz/_21160
#5: https://govnokod.ru/21772 https://govnokod.xyz/_21772
#6: (vanished) https://govnokod.xyz/_24063
#7: https://govnokod.ru/24538 https://govnokod.xyz/_24538
#8: (vanished) https://govnokod.xyz/_24815
#9: https://govnokod.ru/24867 https://govnokod.xyz/_24867
#10: https://govnokod.ru/25328 https://govnokod.xyz/_25328
#11: (vanished) https://govnokod.xyz/_25436
#12: (vanished) https://govnokod.xyz/_25471
#13: (vanished) https://govnokod.xyz/_25590
#14: https://govnokod.ru/25684 https://govnokod.xyz/_25684
#15: https://govnokod.ru/25694 https://govnokod.xyz/_25694
#16: https://govnokod.ru/25725 https://govnokod.xyz/_25725
#17: https://govnokod.ru/25731 https://govnokod.xyz/_25731
#18: https://govnokod.ru/25762 https://govnokod.xyz/_25762
#19: https://govnokod.ru/25767 https://govnokod.xyz/_25767
#20: https://govnokod.ru/25776 https://govnokod.xyz/_25776
#21: https://govnokod.ru/25798 https://govnokod.xyz/_25798
#22: https://govnokod.ru/25811 https://govnokod.xyz/_25811
#23: https://govnokod.ru/25863 https://govnokod.xyz/_25863
#24: https://govnokod.ru/25941 https://govnokod.xyz/_25941
#25: https://govnokod.ru/26026 https://govnokod.xyz/_26026
#26: https://govnokod.ru/26050 https://govnokod.xyz/_26050
#27: https://govnokod.ru/26340 https://govnokod.xyz/_26340
#28: https://govnokod.ru/26372 https://govnokod.xyz/_26372
#29: https://govnokod.ru/26385 https://govnokod.xyz/_26385
#30: https://govnokod.ru/26413 https://govnokod.xyz/_26413
#31: https://govnokod.ru/26423 https://govnokod.xyz/_26423
#32: https://govnokod.ru/26440 https://govnokod.xyz/_26440
#33: https://govnokod.ru/26449 https://govnokod.xyz/_26449
#34: https://govnokod.ru/26456 https://govnokod.xyz/_26456
#35: https://govnokod.ru/26463 https://govnokod.xyz/_26463
+3
<?php
define('BOT_TOKEN', '12345678:replace-me-with-real-token');
define('API_URL', 'https://api.telegram.org/bot'.BOT_TOKEN.'/');
function apiRequestWebhook($method, $parameters) {
if (!is_string($method)) {
error_log("Method name must be a string\n");
return false;
}
if (!$parameters) {
$parameters = array();
} else if (!is_array($parameters)) {
error_log("Parameters must be an array\n");
return false;
}
$parameters["method"] = $method;
header("Content-Type: application/json");
echo json_encode($parameters);
return true;
}
function exec_curl_request($handle) {
$response = curl_exec($handle);
if ($response === false) {
$errno = curl_errno($handle);
$error = curl_error($handle);
error_log("Curl returned error $errno: $error\n");
curl_close($handle);
return false;
}
$http_code = intval(curl_getinfo($handle, CURLINFO_HTTP_CODE));
curl_close($handle);
if ($http_code >= 500) {
// do not wat to DDOS server if something goes wrong
sleep(10);
return false;
} else if ($http_code != 200) {
$response = json_decode($response, true);
error_log("Request has failed with error {$response['error_code']}: {$response['description']}\n");
if ($http_code == 401) {
throw new Exception('Invalid access token provided');
}
return false;
} else {
$response = json_decode($response, true);
if (isset($response['description'])) {
error_log("Request was successful: {$response['description']}\n");
}
$response = $response['result'];
}
return $response;
}
function apiRequest($method, $parameters) {
if (!is_string($method)) {
error_log("Method name must be a string\n");
return false;
}
if (!$parameters) {
$parameters = array();
} else if (!is_array($parameters)) {
error_log("Parameters must be an array\n");
return false;
}
foreach ($parameters as $key => &$val) {
// encoding to JSON array parameters, for example reply_markup
if (!is_numeric($val) && !is_string($val)) {
$val = json_encode($val);
}
}
$url = API_URL.$method.'?'.http_build_query($parameters);
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($handle, CURLOPT_TIMEOUT, 60);
return exec_curl_request($handle);
}
function apiRequestJson($method, $parameters) {
if (!is_string($method)) {
error_log("Method name must be a string\n");
return false;
}
if (!$parameters) {
$parameters = array();
} else if (!is_array($parameters)) {
error_log("Parameters must be an array\n");
+2
interface TemplateReducerInterface {
getConfigParameters(): Promise<ConfigParametersResult>
getConfig(): Record<string, any>
setConfig(config: Record<string, any>): void
getDirectoriesForRemove(): Promise<string[]>
getFilesForRemove(): Promise<string[]>
getDependenciesForRemove(): Promise<string[]>
getFilesContentReplacers(): Promise<ReplaceFileContentItem[]>
finish(): Promise<void>
getTestConfigSet(): Promise<Record<string, any>[]>
}
Какой «TypeScript» )))
https://habr.com/ru/post/487648/
0
Какой шанс сдохнуть от пневмонии в ближайшие 3 месяца?
В Москве началась паника.
Может в запой уйти?
0
Type
ONETWO = 1 .. 2;
var I: ONETWO;
begin
I:=1;
I:=I+1;
writeln(I); //2
I:=1+I;
writeln(I); //3
inc(I);
writeln(I); //4
inc(I);
writeln(I); //5
end.
https://ideone.com/mtmPPq
Всё что нужно знать о продвинутой тупизации в «Паскале».
0
let a = 1
let b = 2
setTimeout(() => {
[a, b] = [b, a]
console.log(a) // 2
console.log(b) // 1
}, 0)
Дорогие ребята! Сегодня мы с вами будем изучать самые поехавшие способы обмена значениями двух переменных.
https://yandex.ru/turbo?text=https%3A%2F%2Fgames.sololaki. ru%2F4-sposoba-proizvesti-obmen-znacheniyami-peremennyh%2F
−1
impl<'a, F, S, D, W, O, L, Of, G, DB> BoxedDsl<'a, DB>
for SelectStatement<F, SelectClause<S>, D, W, O, L, Of, G>
where
Self: AsQuery,
DB: Backend,
S: QueryFragment<DB> + SelectableExpression<F> + Send + 'a,
D: QueryFragment<DB> + Send + 'a,
W: Into<BoxedWhereClause<'a, DB>>,
O: Into<Option<Box<dyn QueryFragment<DB> + Send + 'a>>>,
L: QueryFragment<DB> + Send + 'a,
Of: QueryFragment<DB> + Send + 'a,
G: QueryFragment<DB> + Send + 'a,
{
type Output = BoxedSelectStatement<'a, S::SqlType, F, DB>;
fn internal_into_boxed(self) -> Self::Output {
BoxedSelectStatement::new(
Box::new(self.select.0),
self.from,
Box::new(self.distinct),
self.where_clause.into(),
self.order.into(),
Box::new(self.limit),
Box::new(self.offset),
Box::new(self.group_by),
)
}
}
https://github.com/diesel-rs/diesel/blob/master/diesel/src/query_builder/select_statement/dsl_impls.rs#L342
−1
Вас заметили
капча pa9e
Part of the challenge of programming (and for some people, the reason why programming is fun in the first place) is looking at the building blocks provided to you and deciding how to assemble them to build something new. After all, if everything you wanted a program to do already existed ready-made, it wouldn't be called programming any more. It would be called shopping.
>> Is there an API or a quick way to find out which window the mouse is in?
I replied, "The LEGO Group does not make a piece for every possible object. Sometimes you just have to take two LEGO blocks and click them together. Here are some interesting blocks: GetCursorPos, WindowFromPoint."
>> Thanks for your reply. But WindowFromPoint gives me the window of the object at the location of the cursor. But I'm looking for the top level window containing the cursor.
Fine, then use a different block.
I wonder how it is these people manage to write programs at all. I get the impression they write code by asking a million tiny questions and cutting and pasting together all the replies.
No wait, pasting together the replies counts as snapping blocks together. Maybe they just ask for completed programs.
+1
using System;
using System.Runtime.Serialization;
namespace MyCoolProject {
internal sealed class CatastrophicException: Exception
{
private static bool dead = false;
public static bool Dead { get { return dead; } }
void RecurseDeath() {
try {
RecurseDeath();
} finally {
RecurseDeath();
}
}
private void DIE() {
dead = true;
try {
Environment.FailFast("Catastrophic Exception!!!");
} finally {
try {
RecurseDeath();
} finally {
throw this;
}
}
}
public CatastrophicException() {
DIE();
}
public sealed override string ToString() {
DIE();
throw this;
}
public sealed override System.Collections.IDictionary Data {
get {
DIE();
throw this;
}
}
public sealed override bool Equals(object obj) {
DIE();
throw this;
}
public sealed override Exception GetBaseException() {
DIE();
throw this;
}
public sealed override int GetHashCode() {
DIE();
throw this;
}
public sealed override string HelpLink {
get {
DIE();
throw this;
} set {
DIE();
}
}
public sealed override string Message {
get {
DIE();
throw this;
}
}
public sealed override void GetObjectData(SerializationInfo info, StreamingContext context) {
DIE();
}
public sealed override string Source {
get {
DIE();
throw this;
}
set {
DIE();
}
}
public sealed override string StackTrace {
get {
DIE();
throw this;
}
}
~CatastrophicException() {
try {
new CatastrophicException().DIE();
} finally {
try {
new CatastrophicException().DIE();
} finally {
new CatastrophicException().DIE();
}
}
}
}
}
+5
.
Т Е С Т
К А К О Й В Ы П Р О Г Р А М М И С Т ?
Источник: Datamation, march, 1977
Norman Grabowsky "What kind of programmer are you?"
Этот тест расскажет о вашем программировании больше, чем вы сами
хотели бы знать.
Переменная I представляет собой полное слово с фиксированной
точкой. I принимает значения 1 либо 2. Если I оказалось равным 1,
замените его на 2 и наоборот.
Сравните ваше решение с десятью предложенными. Найдите одно или
несколько наиболее похожих на ваше и прочитайте в разделе "категории"
краткую характеристику. Вы можете кодировать на любом языке, но для
сравнения предпочтительнее всего использовать PL/1.
Р е ш е н и я.
1. IF I='2' THEN I=1;
ELSE I=2;
2. IF I=2 THEN I=1;
IF I=1 THEN I=2;
3. IF I=1 THEN GOTO SKIP;
I=1;
GOTO DONE;
SKIP: I=2;
DONE:
4. J=2;
IF I=2 THEN J=1;
I=J;
5. DECLARE SWITCH LABEL;
. . .
IF I=1 THEN SWITCH=ONE;
IF I=2 THEN SWITCH=TWO;
GOTO SWITCH;
ONE: I=2;
GOTO DONE;
TWO: I=1;
DONE:
6. DECLARE ONETWO(2) FIXED BIN(31) INIT (2,1);
. . .
I=ONETWO(I);
7. I=3-I;
8. I=I-(I/2*2)+1;
9. IF I=2
THEN DO;
I=1;
END;
ELSE DO;
I=2;
END;
10. IF I=1 THEN I=2;
IF I^=2 THEN DO;
PUT LIST('ПЛOXOE I - ЗAMEHEHO HA 1');
I=1;
END;
https://www.cs.bgu.ac.il/~barnshte/CompHumor/texts/TEST.koi