- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
func (c *Client) DeleteFile(filename string) {
_, err := s3.New(c.session).DeleteObject(&s3.DeleteObjectInput{
Bucket: aws.String(c.bucket),
Key: aws.String(filename),
})
if err != nil {
return
}
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
func (c *Client) DeleteFile(filename string) {
_, err := s3.New(c.session).DeleteObject(&s3.DeleteObjectInput{
Bucket: aws.String(c.bucket),
Key: aws.String(filename),
})
if err != nil {
return
}
}
Ошибочка обработана
0
let glb1 = 0;
function doubleIt(f: (x: number) => number) {
return f(1) - f(2);
}
function testLambdas() {
let x = doubleIt(k => k * 108);
assert(x == -108, "l0");
}
function main() {
testLambdas();
print("done.");
}
я вам еще принес новых фич.
+4
#!/usr/bin/env instantfpc
program PrintCharTable;
const
space = ' '; { }
point = '.'; {.}
caret = '^'; {^}
vline = '|'; {│}
hline = '-'; {─}
cross = '+'; {┼}
hex_0 = ord('0');
hex_a = ord('A')-10;
function tohex(d: integer): char;
begin
if d < 10 then
tohex := chr(d+hex_0)
else
tohex := chr(d+hex_a)
end;
var
i, j: integer;
code: integer;
begin
write(space, space, vline);
for i := 0 to 15 do
write(space, point, tohex(i));
writeln;
write(hline, hline, cross);
for i := 0 to 15 do
write(hline, hline, hline);
writeln;
for i := 0 to 15 do begin
write(tohex(i), point, vline);
for j := 0 to 15 do begin
code := i * 16 + j;
if code < 32 then
write(space, caret, chr(code+64))
else if code = 127 then
write(space, caret, chr(code-64))
else
write(space, space, chr(code))
end;
writeln
end
end.
{
$ ./print_ascii.pas | iconv -f koi8-r
| .0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .A .B .C .D .E .F
--+------------------------------------------------
0.| ^@ ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O
1.| ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^\ ^] ^^ ^_
2.| ! " # $ % & ' ( ) * + , - . /
3.| 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
4.| @ A B C D E F G H I J K L M N O
5.| P Q R S T U V W X Y Z [ \ ] ^ _
6.| ` a b c d e f g h i j k l m n o
7.| p q r s t u v w x y z { | } ~ ^?
8.| ─ │ ┌ ┐ └ ┘ ├ ┤ ┬ ┴ ┼ ▀ ▄ █ ▌ ▐
9.| ░ ▒ ▓ ⌠ ■ ∙ √ ≈ ≤ ≥ ⌡ ° ² · ÷
A.| ═ ║ ╒ ё ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞
B.| ╟ ╠ ╡ Ё ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ©
C.| ю а б ц д е ф г х и й к л м н о
D.| п я р с т у ж в ь ы з ш э щ ч ъ
E.| Ю А Б Ц Д Е Ф Г Х И Й К Л М Н О
F.| П Я Р С Т У Ж В Ь Ы З Ш Э Щ Ч Ъ
}
Печатает таблицу нужной кодировки. Пример использования в комменте после end.
0
class XFoo {
pin: number;
buf: number[];
constructor(k: number, l: number) {
this.pin = k - l;
}
setPin(p: number) {
this.pin = p;
}
getPin() {
return this.pin;
}
init() {
this.buf = [1, 2];
}
toString() {
return `Foo${this.getPin()}`;
}
}
function main() {
let f = new XFoo(44, 2);
let s = "" + f;
print(s);
}
я вам тут хрень принес.. новая фича :)
0
IT Оффтоп #103
#73: https://govnokod.ru/27136 https://govnokod.xyz/_27136
#74: https://govnokod.ru/27160 https://govnokod.xyz/_27160
#75: https://govnokod.ru/27166 https://govnokod.xyz/_27166
#76: https://govnokod.ru/27168 https://govnokod.xyz/_27168
#77: https://govnokod.ru/27186 https://govnokod.xyz/_27186
#78: https://govnokod.ru/27219 https://govnokod.xyz/_27219
#79: https://govnokod.ru/27254 https://govnokod.xyz/_27254
#80: https://govnokod.ru/27270 https://govnokod.xyz/_27270
#81: https://govnokod.ru/27280 https://govnokod.xyz/_27280
#82: https://govnokod.ru/27284 https://govnokod.xyz/_27284
#83: https://govnokod.ru/27296 https://govnokod.xyz/_27296
#84: https://govnokod.ru/27336 https://govnokod.xyz/_27336
#85: https://govnokod.ru/27381 https://govnokod.xyz/_27381
#86: https://govnokod.ru/27405 https://govnokod.xyz/_27405
#87: https://govnokod.ru/27429 https://govnokod.xyz/_27429
#88: https://govnokod.ru/27432 https://govnokod.xyz/_27432
#89: https://govnokod.ru/27435 https://govnokod.xyz/_27435
#90: https://govnokod.ru/27439 https://govnokod.xyz/_27439
#91: https://govnokod.ru/27449 https://govnokod.xyz/_27449
#92: https://govnokod.ru/27460 https://govnokod.xyz/_27460
#93: https://govnokod.ru/27463 https://govnokod.xyz/_27463
#94: https://govnokod.ru/27466 https://govnokod.xyz/_27466
#95: https://govnokod.ru/27473 https://govnokod.xyz/_27473
#96: https://govnokod.ru/27478 https://govnokod.xyz/_27478
#97: https://govnokod.ru/27484 https://govnokod.xyz/_27484
#98: https://govnokod.ru/27495 https://govnokod.xyz/_27495
#99: https://govnokod.ru/27504 https://govnokod.xyz/_27504
#100: https://govnokod.ru/27508 https://govnokod.xyz/_27508
#101: https://govnokod.ru/27511 https://govnokod.xyz/_27511
#102: https://govnokod.ru/27518 https://govnokod.xyz/_27518
0
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
typedef struct list list;
struct list
{
list* next;
uint32_t data;
};
#define ADD_LIST(ptr, val) \
do { \
(ptr)->next = (list *)alloca(sizeof(list)); \
(ptr)->next->data = val; \
(ptr)->next->next = NULL;\
} while (0)
// https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
#define INIT_LIST(val) \
({ \
list *INIT_LIST = (list *)alloca(sizeof(list)); \
INIT_LIST->data = val; \
INIT_LIST->next = NULL; \
INIT_LIST; \
})
int main(void)
{
list *a = INIT_LIST(5);
ADD_LIST(a,10);
ADD_LIST(a->next,15);
ADD_LIST(a->next->next,20);
ADD_LIST(a->next->next->next,25);
ADD_LIST(a->next->next->next->next,30);
for(list *ptr = a; ptr != NULL; ptr = ptr->next)
{
printf("%d ", ptr->data);
}
return EXIT_SUCCESS;
}
А можно ли в крестоговне так сделать без Сишного Препроцессора?
0
using System;
namespace MainNamespace
{
class SelectionSort
{
private static int FindSmallest(int[] arr)
{
int smallest = arr[0];
int smallestIndex = 0;
for (int i = 1; i < arr.Length; i++)
{
if (arr[i] < smallest)
{
smallest = arr[i];
smallestIndex = i;
}
}
return smallestIndex;
}
public static int[] ArraySort(int[] arr)
{
int[] newArr = new int[arr.Length];
for (int i = 0; i < arr.Length; i++)
{
int smallestIndex = FindSmallest(arr);
int arrayBeginningIndex = i;
newArr[arrayBeginningIndex] = arr[smallestIndex];
arr[smallestIndex] = Int32.MaxValue;
}
return newArr;
}
}
class MainClass
{
const int sizeOfArr = 7;
static int FindMaxProduct(int[] arr)
{
int maxProduct = 1;
int firstIndex = 0;
int secondIndex = 1;
int lastIndex = sizeOfArr - 1;
int beforeLastIndex = sizeOfArr - 1 - 1;
int beforeBeforeLastIndex = sizeOfArr - 1 - 2;
if (arr[firstIndex] * arr[secondIndex] * arr[lastIndex] > arr[beforeLastIndex] * arr[beforeBeforeLastIndex] * arr[lastIndex])
{
maxProduct = arr[firstIndex] * arr[secondIndex] * arr[lastIndex];
}
else
for (int i = 0; i < 3; i++)
maxProduct *= arr[lastIndex - i];
return maxProduct;
}
static void Main()
{
int[] arr = new int[sizeOfArr] {-31, 54, -39, -34, 0, 56, 92};
arr = SelectionSort.ArraySort(arr);
Console.WriteLine( FindMaxProduct(arr) );
Console.ReadKey();
}
}
}
Есть массив с целыми числами. Найти в этом массиве самое большое произведение 3 чисел и вывести в консоль.
0
Тестовый Оффтоп #3
#1: https://govnokod.ru/26373 https://govnokod.xyz/_26373
#1: https://govnokod.ru/26611 https://govnokod.xyz/_26611
#1: https://govnokod.ru/26824 https://govnokod.xyz/_26824
#1: https://govnokod.ru/26850 https://govnokod.xyz/_26850
#2: https://govnokod.ru/27102 https://govnokod.xyz/_27102
+2
...
fun([N1, _N2], Trace) ->
?assert(
?strict_causality( #{?snk_kind := "Adding table to a shard", shard := _Shard, live_change := true}
, #{?snk_kind := "Shard schema change"}
, ?of_node(N1, Trace)
)),
?assert(
?strict_causality( #{?snk_kind := "Shard schema change", shard := _Shard}
, #{?snk_kind := "Restarting shard server", shard := _Shard}
, ?of_node(N1, Trace)
)),
%% Schema change must cause restart of the replica process and bootstrap:
{_, Rest} = ?split_trace_at(#{?snk_kind := "Shard schema change"}, Trace),
?assert(
?strict_causality( #{?snk_kind := "Restarting shard server", shard := _Shard}
, #{?snk_kind := state_change, to := bootstrap}
, Rest
))
end).
Немного galaxy-brain тестов
0
Пиздец-оффтоп #25
#1: https://govnokod.ru/26503 https://govnokod.xyz/_26503
#2: https://govnokod.ru/26541 https://govnokod.xyz/_26541
#3: https://govnokod.ru/26583 https://govnokod.xyz/_26583
#4: https://govnokod.ru/26689 https://govnokod.xyz/_26689
#5: https://govnokod.ru/26784 https://govnokod.xyz/_26784
#5: https://govnokod.ru/26839 https://govnokod.xyz/_26839
#6: https://govnokod.ru/26986 https://govnokod.xyz/_26986
#7: https://govnokod.ru/27007 https://govnokod.xyz/_27007
#8: https://govnokod.ru/27023 https://govnokod.xyz/_27023
#9: https://govnokod.ru/27098 https://govnokod.xyz/_27098
#10: https://govnokod.ru/27125 https://govnokod.xyz/_27125
#11: https://govnokod.ru/27129 https://govnokod.xyz/_27129
#12: https://govnokod.ru/27184 https://govnokod.xyz/_27184
#13: https://govnokod.ru/27286 https://govnokod.xyz/_27286
#14: https://govnokod.ru/27298 https://govnokod.xyz/_27298
#15: https://govnokod.ru/27322 https://govnokod.xyz/_27322
#16: https://govnokod.ru/27328 https://govnokod.xyz/_27328
#17: https://govnokod.ru/27346 https://govnokod.xyz/_27346
#18: https://govnokod.ru/27374 https://govnokod.xyz/_27374
#19: https://govnokod.ru/27468 https://govnokod.xyz/_27468
#20: https://govnokod.ru/27469 https://govnokod.xyz/_27469
#21: https://govnokod.ru/27479 https://govnokod.xyz/_27479
#22: https://govnokod.ru/27485 https://govnokod.xyz/_27485
#23: https://govnokod.ru/27493 https://govnokod.xyz/_27493
#24: https://govnokod.ru/27501 https://govnokod.xyz/_27501