- 1
- 2
- 3
- 4
- 5
- 6
- 7
if ($site_is_work)
{
}
else
{
exit('Сайт не работает');
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+11.9
if ($site_is_work)
{
}
else
{
exit('Сайт не работает');
}
0
// https://github.com/dotnet/runtime/issues/117233#issuecomment-3028066225
// Issue: Math.Pow relies directly on the OS pow implementation
// Location: [src/coreclr/classlibnative/float/floatdouble.cpp lines 232‑236] and [src/coreclr/classlibnative/float/floatsingle.cpp lines 207‑211]
// COMDouble::Pow and COMSingle::Pow simply call pow/powf from the C runtime. On Windows 11 Insider Preview (build 27881.1000),
// these functions can return incorrect results (e.g., Math.Pow(-1, 2) giving -1). The JIT also uses these functions for constant folding, causing
// wrong constants to be embedded at compile time.
// Suggested Fix: Introduce a managed fallback in COMDouble::Pow/COMSingle::Pow that handles negative bases with integral exponents, bypassing the faulty system call.
//A simple approach:
FCIMPL2_VV(double, COMDouble::Pow, double x, double y)
{
FCALL_CONTRACT;
if ((x < 0.0) && (y == floor(y)))
{
double absResult = pow(-x, y);
return fmod(fabs(y), 2.0) == 1.0 ? -absResult : absResult;
}
return pow(x, y);
}
// Suggested Implementation:
// Add the following code to src/coreclr/classlibnative/float/floatdouble.cpp below line 234 before the return pow:
if ((x < 0.0) && (y == floor(y)))
{
double result = pow(-x, y);
if (fmod(fabs(y), 2.0) != 0.0)
{
result = -result;
}
return result;
}
// Add the following code to src/coreclr/classlibnative/float/floatsingle.cpp below line 209 before the return powf:
if ((x < 0.0f) && (y == floorf(y)))
{
float result = powf(-x, y);
if (fmodf(fabsf(y), 2.0f) != 0.0f)
{
result = -result;
}
return result;
}
// Add the following code to src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/Math.cs below line 1124:
[Fact]
public static void Pow_NegativeBaseEvenExponent_ReturnsPositive()
{
Assert.Equal(1.0, Math.Pow(-1, 2));
Assert.Equal(16.0, Math.Pow(-2, 4));
}
Вот к чему плавучий петух приводит!
+1
/* Python:
def A004086(n):
return int(str(n)[::-1])
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int A004086(int n) {
char str[12]; // Enough to hold the string representation of an int
sprintf(str, "%d", n);
int len = strlen(str);
char reversed[12];
for (int i = 0; i < len; i++) {
reversed[i] = str[len - 1 - i];
}
reversed[len] = '\0'; // Null-terminate the string
return atoi(reversed);
}
Результат переписывание с "Python" на "C". A004086 это последовательность из OEIS https://oeis.org/A004086
0
$_GET
−2
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Scanner;
import java.util.zip.*;
import java.io.*;
public class CitiesPrinter {
public static void main(String[] args) throws IOException {
final String fileName = "/storage/emulated/0/Documents/Jvdroid/single-files/_данные_Сбер_Java_20210407090226.zip";
try(ZipInputStream unzipping = new ZipInputStream(new FileInputStream(fileName)));
{
ZipEntry entry = null;
String name = null;
long size = 0;
while((entry=unzipping.getNextEntry())!= null) {
name = entry.getName();
size = entry.getSize();
System.out.println("FileName: " + name + "FileSize: " + size);
FileOutputStream unzippedFile = new FileOutputStream("/storage/emulated/0/Documents/Jvdroid/single-files/new" + name);
for (int c = unzipping.read(); c != -1; c = unzipping.read()) {
unzippedFile.write(c);
}
unzippedFile.flush();
unzipping.closeEntry();
unzippedFile.close();
}
}
catch(Exception e){
System.out.println(e.getMessage());
}
Path path = Paths.get(fileName);
Scanner scanner = new Scanner(path);
scanner.useDelimiter(System.getProperty("line.separator"));
while(scanner.hasNext()){
System.out.println("Строка: " + scanner.next());
}
scanner.close();
scanner = new Scanner(Paths.get("/storage/emulated/0/Documents/Jvdroid/single-files/_данные_Сбер_Java_20210407090226.zip/city_ru.csv"));
scanner.useDelimiter(System.getProperty("line.separator"));
while(scanner.hasNext()){
Employee emp = parseCSVLine(scanner.next());
System.out.println(emp.toString());
}
scanner.close();
scanner = new Scanner(System.in);
System.out.println("Вводим первое слово: " + scanner.next());
}
private static Employee parseCSVLine(String line) {
Scanner scanner = new Scanner(line);
scanner.useDelimiter("\\s*,\\s*");
String name = scanner.next();
int age = scanner.nextInt();
String gender = scanner.next();
CitiesPrinter jfs = new CitiesPrinter();
return jfs.new Employee(name, age, gender);
}
}
class Employee{
private String name;
private int age;
private String gender;
public Employee(String n, int a, String gen){
this.name = n;
this.age = a;
this.gender = gen;
}
@Override
public String toString(){
return "Name=" + this.name + "::Age=" + this.age + "::Gender=" + this.gender;
}
}
Что не так?
0
const newRecords = {}
for (const prop in overridenRecords) {
if(Object.prototype.hasOwnProperty.call(overridenRecords, prop)) {
const source = Object.values(allRecords).find((record) => record.id == prop)
newRecords[prop] = {...overridenRecords[prop], ...source}
}
}
return newRecords
+5
// Heap memory allocate function (must not be used!)
caddr_t _sbrk(int incr) {
<...>
void some_bastard_called_sbrk();
some_bastard_called_sbrk(); // Produce linker error in case it is used
}
_ATTRIBUTE ((__format__ (__printf__, 1, 2)))
int printf (const char *__restrict format, ...)
{
<маленький трехколесный велосипед>
}
int putchar(int c)
{
<...>
}
int puts(const char *s)
{
<...>
}
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))
int sprintf (char *__restrict s, const char *__restrict format, ...)
{
<...>
}
STM32. Я просто хочу использовать printf для вывода в последовательный порт и не течь. Ведь для этого нужно только реализовать int _write(int file, char *data, int len) и всё. Ой, а почему иногда программа падает где-то в кишках рантайма?
Может, стек переполняется? Да нет, проверил, значения в норме...
Просто стандартная библиотека от ST - это не курсовая ардуинщика, тут все системно, хендлы потоков, дескрипторы устройств и управляющие структуры. При первом обращении printf (и sprintf тоже!) выделяет себе в куче около 400 байт. Замечательное решение, помогающее сэкономить память, если мы не используем стандартный вывод! А куча тут - это просто последовательно заполняемая область памяти, размеры которой задаются в linker script (я вообще 0 указал, я ведь не использую malloc). Проверять выход за пределы кучи мы, конечно, не будем - зачем, когда рядом такая замечательная, никому не нужная область стека.
Да, и если забыть отключить буферизацию setvbuf(stdin/stdout/stderr, NULL, _IONBF, 0); , то он выделит не 400 байт, а килобайт (на контроллере с 8K RAM).
В общем, ах, оставьте меня, сам все напишу.
Только надо еще putchar и puts реализовать, а то компилятор любит printf'ы оптимизировать. И не забыть, что puts добавляет перевод строки. Уф, вроде все.
+1
<?php defined('SYSPATH') or die('No direct script access.');
/*
* Базовый класс главной страницы
*/
class Controller_Index extends Controller {
public function before() {
parent::before();
I18n::lang('ru');
$settings = Kohana::config('settings');
Cookie::$salt = 'asd12d2';
Session::$default = 'cookie';
$this->session = Session::instance();
}
public function action_index() {
//Путь до файла первоночального xml (xsl)
$path_xml='tpl/xml.xsl';
//Путь конечного xsl
$path_xsl='tpl/index.xsl';
$url = $this->request->param('stuff');
//print_r($_SERVER);
/*if($_SERVER ['REQUEST_URI']=='/'){
$this->request->redirect($_SERVER ['HTTP_X_FORWARDED_PROTO'].'://'.$_SERVER['HTTP_HOST'],'301');
}*/
if(empty($url)){
$url='/';
}
$htmlfile='cache-html/'.md5($url);
$allurl=$_SERVER ['REQUEST_URI'];
if($allurl=='/20-40-kvm') $this->request->redirect('/sadovye-domiki','301');
if($allurl=='/40-80-kvm') $this->request->redirect('/sadovye-domiki','301');
if($allurl=='/80-i-bolee-kvm') $this->request->redirect('/sadovye-domiki','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=0&destination%5B%5D=1&destination%5B%5D=2&technology%5B%5D=0&floors%5B%5D=1&floors%5B%5D=1.5&floors%5B%5D=2&price=0-3000000&area=0-400') $this->request->redirect('/sadovye-domiki','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=1&technology%5B%5D=0&technology%5B%5D=1&technology%5B%5D=2&floors%5B%5D=1&floors%5B%5D=1.5&floors%5B%5D=2&price=0-3000000&area=81-400') $this->request->redirect('/80-i-bolee-kvm','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=1&technology%5B%5D=0&technology%5B%5D=1&technology%5B%5D=2&floors%5B%5D=1&floors%5B%5D=1.5&floors%5B%5D=2&price=0-3000000&area=40-80') $this->request->redirect('/40-80-kvm','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=0&technology%5B%5D=0&technology%5B%5D=1&technology%5B%5D=2&floors%5B%5D=1&floors%5B%5D=1.5&floors%5B%5D=2&price=0-3000000&area=0-400') $this->request->redirect('/stroitelstvo-dachnyh-domov','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=2&technology%5B%5D=0&technology%5B%5D=1&technology%5B%5D=2&technology%5B%5D=3&floors%5B%5D=1&floors%5B%5D=1.5&floors%5B%5D=2&price=0-3000000&area=0-400') $this->request->redirect('/kottedzhi','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=3&technology%5B%5D=0&technology%5B%5D=2&technology%5B%5D=3&floors%5B%5D=1&floors%5B%5D=1.5&price=0-3000000&area=0-400') $this->request->redirect('/bani','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=3&technology%5B%5D=2&floors%5B%5D=1&floors%5B%5D=1.5&price=0-3000000&area=0-400') $this->request->redirect('/bani-iz-profilirovannogo-brusa','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=3&technology%5B%5D=0&floors%5B%5D=1&floors%5B%5D=1.5&price=0-3000000&area=0-400') $this->request->redirect('/karkasnye-bani','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=3&technology%5B%5D=3&floors%5B%5D=1&floors%5B%5D=1.5&floors%5B%5D=2&price=0-3000000&area=0-400') $this->request->redirect('/bani-iz-ocilindrovannogo-brevna','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=0&destination%5B%5D=1&destination%5B%5D=2&technology%5B%5D=2&floors%5B%5D=1&floors%5B%5D=1.5&floors%5B%5D=2&price=316018-3000000&area=0-400') $this->request->redirect('/brus','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=0&destination%5B%5D=1&destination%5B%5D=2&technology%5B%5D=2&floors%5B%5D=1&floors%5B%5D=1.5&floors%5B%5D=2&price=0-3000000&area=0-400') $this->request->redirect('/kottedzhi-profilirovannyj-brus','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=0&destination%5B%5D=1&destination%5B%5D=2&technology%5B%5D=0&floors%5B%5D=1&floors%5B%5D=1.5&floors%5B%5D=2&price=329056-3000000&area=0-400') $this->request->redirect('/dachnye-doma-karkasnaya-tehnologiya','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=0&destination%5B%5D=1&destination%5B%5D=2&technology%5B%5D=1&floors%5B%5D=1&floors%5B%5D=1.5&floors%5B%5D=2&price=0-3000000&area=0-400') $this->request->redirect('/individualnye-proekty','301');
Там ещё дальше веселье продолжается, но гк не дает запостить больше
0
Борманд, у тебя спина рыжая!
Ха-ха, я пошутил, с первым апреля )))
0
#define CONSTRUCT_JUMP(name_, opcode_) else if(mnemonic.name == #name_) \
subcompileMnemonic(mnemonic, {\
{constructDescription(CONSTANT), opcode_},\
{constructDescription(LABEL), opcode_}})
CONSTRUCT_JUMP(JMP, JMP);
CONSTRUCT_JUMP(JE, JZ);
CONSTRUCT_JUMP(JZ, JZ);
CONSTRUCT_JUMP(JNZ, JNZ);
CONSTRUCT_JUMP(JNE, JNZ);
CONSTRUCT_JUMP(JG, JG);
CONSTRUCT_JUMP(JNLE, JG);
CONSTRUCT_JUMP(JNLZ, JG);
CONSTRUCT_JUMP(JLE, JNG);
CONSTRUCT_JUMP(JLZ, JNG);
CONSTRUCT_JUMP(JNG, JNG);
CONSTRUCT_JUMP(JGE, JGZ);
CONSTRUCT_JUMP(JGZ, JGZ);
CONSTRUCT_JUMP(JNL, JGZ);
CONSTRUCT_JUMP(JNGZ, JL);
CONSTRUCT_JUMP(JNGE, JL);
CONSTRUCT_JUMP(JL , JL);
CONSTRUCT_JUMP(JB, JB);
CONSTRUCT_JUMP(JNAE, JB);
CONSTRUCT_JUMP(JNAZ, JB);
CONSTRUCT_JUMP(JC, JB);
CONSTRUCT_JUMP(JNB, JNB);
CONSTRUCT_JUMP(JAE, JNB);
CONSTRUCT_JUMP(JAZ, JNB);
CONSTRUCT_JUMP(JNC, JNB);
CONSTRUCT_JUMP(JBE, JBZ);
CONSTRUCT_JUMP(JBZ, JBZ);
CONSTRUCT_JUMP(JNA, JBZ);
CONSTRUCT_JUMP(JA, JA);
CONSTRUCT_JUMP(JNBE, JA);
CONSTRUCT_JUMP(JNBZ, JA);
CONSTRUCT_JUMP(CALL, CALL);
#undef CONSTRUCT_JUMP