- 1
SCRIPT="<?php http_response_code(429); ob_clean(); //" php -S localhost:80 /proc/self/environ
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
SCRIPT="<?php http_response_code(429); ob_clean(); //" php -S localhost:80 /proc/self/environ
sql injection is for kids, grownups use environment variable injection
+1
import java.util.Scanner;
public class ComputeTax {
public static void main(String[] args) {
// Create a Scanner
Scanner input = new Scanner(System.in);
// Prompt the user to enter filing status
System.out.print(
"(0-single filer, 1-married jointly or qualifying widow(er)",
+ "\n2-married separately, 3-head of household)\n" +
"Enter the filing status: ");
int status = input.nextInt();
// Prompt the user to enter taxable income
System.out.print("Enter the taxable income: ");
double income = input.nextDouble();
// Compute tax
double tax = 0;
if (status == 0) {// Compute tax for single filers
if (income <= 8350)
tax = income * 0.10;
else if (income <= 33950)
tax = 8350 * 0.10 + (income - 8350) * 0.15;
else if (income <= 82250)
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
(income - 33950) * 0.25;
else if (income <= 171550)
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
(82250 - 33950) * 0.25 + (income - 82250) * 0.28;
else if (income <= 372950)
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
(82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 +
(income - 171550) * 0.33;
else
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
(82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 +
(372950 - 171550) * 0.33 + (income - 372950) * 0.35;
}
else if (status == 1) {
// Left as exercise
// Compute tax for married file jointly or qualifying widow(er)
}
else if (status == 2) {
// Compute tax for married separately
// Left as exercise
}
else if (status == 3) {
// Compute tax for head of household
// Left as exercise
}
else {
System.out.println("Error: invalid status");
System.exit(1);
}
// Display the result
System.out.println("Tax is " + (int)(tax * 100) / 100.0);
}
+1
const getSizeString = (size: number) => {
const mesuarments = ["Б", "кБ", "МБ", "ГБ"];
let i = 0;
for (; size/1024 > 1; size /= 1024, i++)
;
return ${Math.floor(size) === size ? size : (size).toFixed(1)} ${mesuarments[i]};
}
+1
class Container:
def __init__(self, liquid):
self.liquid = liquid
def look_inside(self):
return f"{self.liquid} in container"
@classmethod
def create_with(cls, liquid):
return cls(liquid)
class Bottle(Container):
def look_inside(self):
return f"bottle full of {self.liquid}"
class Glass(Container):
def look_inside(self):
return f"A glass of {self.liquid}"
for c in (c.create_with("beer") for c in [Glass, Bottle]):
print(c.look_inside())
ми маємо class polymorphism
+1
<p oncopy="return false" ondragstart="return false"></p>
<p oncopy="return false" ondragstart="return false"></p>
<p oncopy="return false" ondragstart="return false"></p>
<p oncopy="return false" ondragstart="return false"></p>
<p oncopy="return false" ondragstart="return false"></p>
<p oncopy="return false" ondragstart="return false"></p>
<p oncopy="return false" ondragstart="return false"></p>
<p oncopy="return false" ondragstart="return false"></p>
<p oncopy="return false" ondragstart="return false"></p>
Защита контента для самых маленьких
+1
#include <cstdio>
class tag;
template<class>
struct type { friend constexpr auto get(type); };
template<class TKey, class TValue>
struct set { friend constexpr auto get(TKey) { return TValue{}; } };
void foo() { // never called
if constexpr(false) { // never true
if (false) { // never true
constexpr auto call = [](auto value) { std::printf("called %d", value); };
void(set<type<tag>, decltype(call)>{});
}
}
}
int main() {
get(type<tag>{})(42); // prints called 42
}
https://twitter.com/krisjusiak/status/1186363017329594368
Какой C++20 )))
+1
"Performance is easy. All you need to know is everything" (c) S. Kuksenko (@kuksenk0)
Умеете профилировать программы?
Знаете, что такое flame diagram? Умеете посмотреть стектрейс от входа в тред до какого-нить спинлока в ядре? Смотрите асм своего компилятора или джита? Знаете, какая инструкция сколько занимает?
Умеете по vmstat/iostat или xperf/perf counters увидать проблему и соотнести ее с программой? Используете dtrace голый или с instruments? yourkit? vTune? valgrind? bpf?
Или такие же дебилы, как я?
+1
public int HowManyHoursWillGoBackForConvertingUkToUtc(DateTime ukTime) => IsAlreadyGoForward(ukTime) ? 1 : 0;
когда название говорит само за себя
+1
<?php
require_once '../vendor/autoload.php';
require_once 'functions.php';
require_once 'KPFile.php';
require_once 'KPLogger.php';
use Intervention\Image\ImageManagerStatic as Шакализатор;
Шакализатор::configure(array('driver' => 'imagick'));
$logger = new KPLogger();
function сжать(KPFile $шакал, $степеньСжатия, Array $ебучесть, $output) {
$индексЕбучести = 0;
if (!is_null($ебучесть[0])) {
$индексЕбучести = $ебучесть[0];
}
if (!is_null($ебучесть[1]) && ($ебучесть[1] > $ебучесть[0])) {
$индексЕбучести = $ебучесть[1];
}
$img = Шакализатор::make($шакал->path);
$img->resize($ебучесть[0], $ебучесть[1], function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
if ($img->mime() !== 'image/jpeg') {
$img->encode('jpg', 100);
}
$img->save($output."$шакал->name-$индексЕбучести.jpg", $степеньСжатия);
}
function сжатьВсехШакалов($path, $степеньСжатия, $ебучестьШакалов, $output) {
global $logger;
$files = scandir($path);
foreach($files as $key => $file) {
$logger->colorLogWithFiles('blue', $file, $key);
try {
$шакал = new KPFile($path.$file);
if ($шакал->type !== KPFile::FILE_TYPE_IMAGE) {
continue;
}
if (trim($шакал->name) == '') {
throw new Exception("file=$file, kpFileName=$шакал->name");
}
foreach ($ебучестьШакалов as $ебучесть) {
сжать($шакал, $степеньСжатия, $ебучесть, $output);
}
} catch (Exception $e) {
$logger->exception($e, $key);
}
}
}
$степеньСжатия = 22;
$ебучестьШакалов = [
[60, 60],
[38, 38]
];
сжатьВсехШакалов('dataHeavy/carsOrig/', $степеньСжатия, $ебучестьШакалов, "../public/img/cars/");
$logger->colorLogWithFiles('blue', '10/10 *** еб/шакалов', null, "\n");
shakal of jpeg-street
+1
#include "pch.h"
#include <iostream>
#include <conio.h>
#include <stdlib.h>
#include <ctime>
using namespace std;
int main()
{
setlocale(0, "rus");
int n, a[1000], max, c;
cout << "число элементов: "; cin >> n;
srand(time(0));
cout << "\nчисла массива:\n";
for (int i = 0; i < n; i++) {
a[i] = rand() % 2000 -1000;
cout << a[i] << " ";
if (i == 0) max = abs(a[i]); else if (abs(a[i]) > max) max = abs(a[i]);
}
cout << "\n\nабс. максимум = " << max << endl;
for (int i = 0; i < n; i++) {
for (int j = n-1; j > 0; j--) {
if (a[j - 1] < a[j]) {
c = a[j - 1];
a[j - 1] = a[j];
a[j] = c;
}
}
}
cout << "\nотсортированный массив:\n";
for (int i = 0; i < n; i++) {
cout << a[i]<<" ";
}
_getch();
return 0;
}