- 1
http://pastebin.com/KNAhNqJC
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+153
http://pastebin.com/KNAhNqJC
В связи с тем что толстота освоила новую тактику, выпущена очередная версия говнофильтра™.
* поддержка скрытия постов. Увы, выкинуть пост из выдачи совсем не получится, так что при флуд-атаках будут пустые страницы.
* альтернативный "мягкий" метод скрытия комментариев - белое на белом.
* переписано на jQuery, раз уж оно есть на уютненьком ГК.
Как обычно, заточено под Firefox+GreaseMonkey.
0
pub trait Normalize<T> {
type Output;
fn normalize(&self, baseline_value: &T) -> Self::Output;
fn denormalize(&self, baseline_value: &T) -> Self::Output;
}
impl<T, U, W> Normalize<T> for U
where
T: Copy,
U: Copy + Div<T, Output = W> + Mul<T, Output = W>,
{
type Output = W;
fn normalize(&self, baseline_value: &T) -> Self::Output { *self / *baseline_value }
fn denormalize(&self, baseline_value: &T) -> Self::Output { *self * *baseline_value }
}
impl<T> Normalize<CanvasSize<T>> for Rectangle
where
T: Copy,
f32: Normalize<T, Output = f32>
{
type Output = Rectangle;
fn normalize(&self, baseline_value: &CanvasSize<T>) -> Self::Output {
Rectangle {
x1: self.x1.normalize(&baseline_value.width),
y1: self.y1.normalize(&baseline_value.height),
x2: self.x2.normalize(&baseline_value.width),
y2: self.y2.normalize(&baseline_value.height),
}
}
fn denormalize(&self, baseline_value: &CanvasSize<T>) -> Self::Output {
Rectangle {
x1: self.x1.denormalize(&baseline_value.width),
y1: self.y1.denormalize(&baseline_value.height),
x2: self.x2.denormalize(&baseline_value.width),
y2: self.y2.denormalize(&baseline_value.height),
}
}
}
0
template<typename T>
class SharedPtr {
T* value;
int* ref_count;
public:
SharedPtr(T* value) : value(value) {
ref_count = new int;
*ref_count = 1;
}
SharedPtr(const SharedPtr& other) {
value = other.value;
ref_count = other.ref_count;
(*ref_count)++;
}
SharedPtr(SharedPtr&& other) {
value = other.value;
ref_count = other.ref_count;
other.ref_count = nullptr;
}
~SharedPtr() {
if (ref_count == nullptr) {
return;
}
if (*ref_count == 1) {
delete value;
delete ref_count;
} else {
(*ref_count)--;
}
}
T& operator *() const {
return *value;
}
T* operator ->() const {
return value;
}
};
Реалейзовал минимальную версию shared_ptr. Есть ошибки/замечания?
https://ideone.com/g7gqBM
+158
<?php
define("LOGIN", "login");
define("PASSWORD", "password");
define("BASE", "base");
define("HOST", "IP");
$table = "table";
$err_name = "Вы не написали свое имя! <br />";
$err_text = "Вы не написали текст! <br />";
$err_email = "Вы не указали свой email! <br />";
$conn = mysql_connect(HOST, LOGIN, PASSWORD) or die ('соединение с БД установить не удалось!');
$db = mysql_select_db(BASE, $conn) or die ('проверьте наличие БД!');
$stop = 0;
if (isset($_POST['save'])) {
if ((strlen($_POST['name']) !=0) && (strlen($_POST['text']) !=0) && (strlen($_POST['email']) !=0)) {
$name = $_POST['name'];
$text = $_POST['text'];
$email = $_POST['email'];
if (strlen($_POST['url']) !=0) {
$url = $_POST['url'];
$create = mysql_query("INSERT INTO $table VALUES (NULL, '$name', '$text', '$email', '$url')", $conn) or die ('запрос в БД не выполнен!');
$stop = 1 ;
}
if ($stop != 1) {
$create = mysql_query("INSERT INTO $table VALUES (NULL, '$name', '$text', '$email', NULL)", $conn) or die ('запрос в БД не выполнен!');
}
}
}
if (error('name')) {
echo $err_name;
}
if (error('text')) {
echo $err_text;
}
if (error('email')) {
echo $err_email;
}
function error($err) {
return (isset($_POST['save']) && strlen($_POST[$err]) == 0);
}
$result = mysql_query("SELECT * FROM $table", $conn) or die ('Выбранная таблица не существует!');
$stroki = mysql_num_rows($result);
$stolb = mysql_num_fields($result);
for ($i=0; $i<$stroki; $i++) {
$s = mysql_fetch_row($result);
for ($j=0; $j<$stolb; $j++) {
$massiv[$i][$j] = $s[$j];
}
}
for ($i=0; $i<$stroki; $i++) {
for ($j=0; $j<$stolb; $j++) {
echo $massiv[$stroki-$i-1][$j] . " ";
}
echo "<br />";
}
if (isset($_POST['clear'])) {
$delete = mysql_query("TRUNCATE TABLE $table", $conn) or die ('запрос на удаление выполнить не удалось!');
echo "<br />" . "<hr />" . "Все данные стерты!" . "<hr />" . "<br />";
}
mysql_close($conn);
echo "<form method=\"POST\">\n";
echo "<table border=\"1\" cellpadding=\"5\" cellspacing=\"5\">\n";
echo "<tr><td>Ваше имя</td><td><input type=\"text\" name=\"name\" /></td></tr>\n";
echo "<tr><td>Ваш email</td><td><input type=\"text\" name=\"email\" /></td></tr>\n";
echo "<tr><td>Ваша домашняя страница (URL)</td><td><input type=\"text\" name=\"url\" /></td></tr>\n";
echo "<tr><td>Текст сообщения</td><td><textarea name=\"text\"></textarea></td></tr>\n";
echo "<tr><td colspna=\"2\"><input type=\"submit\" name=\"save\" value=\"Отослать\"/></td></tr>\n";
echo "<tr><td colspna=\"2\"><input type=\"submit\" name=\"clear\" value=\"Очистить\"/></td></tr>\n";
?>
гостевая книга (php +mysql)
+187
function get_rand_symbols($numeric) {
if($numeric == '1') { return 'п'; }
if($numeric == '2') { return 'р'; }
if($numeric == '3') { return 'о'; }
if($numeric == '4') { return 'к'; }
if($numeric == '5') { return 'е'; }
if($numeric == '6') { return 'а'; }
if($numeric == '7') { return 'д'; }
if($numeric == '8') { return 'е'; }
if($numeric == '9') { return 'й'; }
if($numeric == '10') { return 'в'; }
if($numeric == '11') { return 'м'; }
if($numeric == '12') { return 'л'; }
if($numeric == '13') { return 'с'; }
if($numeric == '14') { return 'т'; }
if($numeric == '15') { return 'у'; }
if($numeric == '16') { return 'н'; }
if($numeric == '17') { return 'ш'; }
if($numeric == '18') { return 'х'; }
if($numeric == '19') { return 'щ'; }
if($numeric == '20') { return 'ъ'; }
if($numeric == '21') { return 'ю'; }
if($numeric == '22') { return 'б'; }
if($numeric == '23') { return 'я'; }
if($numeric == '24') { return 'ц'; }
if($numeric == '25') { return 'ч'; }
if($numeric == '26') { return 'ё'; }
if($numeric == '27') { return 'э'; }
if($numeric == '28') { return 'з'; }
if($numeric == '29') { return 'и'; }
if($numeric == '30') { return 'ы'; }
}
function all_rand() {
return get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30));
}
случайная строка с русскими символами
+164
mysql_query("INSERT INTO `classes` (`name`) VALUES('".$_POST["class_name"]."')");
$Mresult=mysql_query("SELECT MAX(`id`) FROM `classes`");
$row=mysql_fetch_row($Mresult);
$class_num=$row[0];
$date1=$_POST["class_start"];
$date2=$_POST["class_end"];
mysql_query("CREATE TABLE `class_".$class_num."_lessons` (`id` INT, `data` TEXT)");
mysql_query("CREATE TABLE `class_".$class_num."_video` (`id` INT, `data` TEXT)");
mysql_query("CREATE TABLE `class_".$class_num."_ege` (`id` INT, `data` TEXT)");
mysql_query("CREATE TABLE `class_".$class_num."_rasp` (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `data` TEXT)");
+1
.chamfer {
display: table;
border-collapse: separate;
empty-cells: show;
background: transparent;
display: inline-block;
margin-bottom: 25px;
margin-right: 25px;
vertical-align: top;}
.chamfer .row {
display: table-row;}
.chamfer .boxcontent {
display: table-cell;
background: #FFFFFF;
font-size: 24px;
vertical-align: middle;
min-width: 200px;
width: 200px;
height: 173px;}
.chamfer .transparentbox {
display: table-cell;
background: transparent;
font-size: 24px;
vertical-align: middle;
min-width: 200px;
width: 200px;}
.chamfer .row .north-west {
display: table-cell;
border: 100px solid transparent;
border-top-width: 0px;
border-right-width: 0px;
border-bottom: 173px solid #FFF;
width: 0px;}
.chamfer .row .north-east {
display: table-cell;
border: 100px solid transparent;
border-top-width: 0px;
border-left-width: 0px;
border-bottom: 173px solid #FFF;
width: 0px;}
.chamfer .row .south-west {
display: table-cell;
border: 100px solid transparent;
border-bottom-width: 0px;
border-right-width: 0px;
border-top: 173px solid #FFF;
width: 0px;}
.chamfer .row .south-east {
display: table-cell;
border: 100px solid transparent;
border-bottom-width: 0px;
border-left-width: 0px;
border-top: 173px solid #FFF;
width: 0px;}
.chamfer .row3 .north-west {
border: 100px solid yellow;
border-top-width: 0px;
border-right-width: 0px;
border-bottom: 173px solid red;}
.chamfer .row3 .north-east {
border: 100px solid yellow;
border-top-width: 0px;
border-left-width: 0px;
border-bottom: 173px solid red;}
.chamfer .row2 .south-west {
border: 100px solid yellow;
border-bottom-width: 0px;
border-right-width: 0px;
border-top: 173px solid #FFF;}
.chamfer .row2 .south-east {
border: 100px solid yellow;
border-bottom-width: 0px;
border-left-width: 0px;
border-top: 173px solid #FFF;}
.chamfer .row4 .south-west {
border: 100px solid transparent;
border-bottom-width: 0px;
border-right-width: 0px;
border-top: 173px solid red;}
.chamfer .row4 .south-east {
border: 100px solid transparent;
border-bottom-width: 0px;
border-left-width: 0px;
border-top: 173px solid red;}
.chamfer .row2 .transparentbox, .chamfer .row3 .transparentbox {
background: yellow;
height: 173px;}
.chamfer .row3 .boxcontent, .chamfer .row4 .boxcontent {
background: red;
height: 173px;}
body {
color: #3B3A37;
background-color: olive;}
Реальный пример шестиугольных блоков (в виде сот) на чистом CSS2.
Страница в действии:
https://output.jsbin.com/xewelufoda/
+7
console.log(parseInt(0.5)); // 0
console.log(parseInt(0.05)); // 0
console.log(parseInt(0.005)); // 0
console.log(parseInt(0.0005)); // 0
console.log(parseInt(0.00005)); // 0
console.log(parseInt(0.000005)); // 0
console.log(parseInt(0.0000005)); // 5
https://ideone.com/YMWUGq
Возможно баян, спижжено с https://vk.com/wall-72495085_1267978
0
Короче, размышлял я как-то на тему того, как надо делать правильный
теорем прувер, а не питушню всякую заедушную. Вот взять тот же Metamath -
там какие-то непонятные distinct правила для хуиты, что надо какие-то там
disjoint переменные, вот тут https://groups.google.com/g/metamath/c/M2dUfFATxD8
про это подробнее сказано.
Есть вот еще Metamath zero https://github.com/digama0/mm0 и это вот кажется ближе
к тому, что мне нравится.
Например вот https://github.com/digama0/mm0/blob/master/examples/assembler.mm1
тут есть какая-то теорема про ELF хедер. Это вот определение ELF идентификатора
local def ELF_IDENT_s: string =
$ ,0x7f ': ,"E" ': ,"L" ': ,"F" ':
_x02 ': _x01 ': _x01 ': _x00 ': _x00x8 $;
и там еще какой-то такой хуйней описывается то, где там точка входа записана в заголовке,
еще separation logic есть какая-то.
Но вот если почитать спецификацию для этого mm0 языка
https://github.com/digama0/mm0/blob/master/mm0.md :
pure means that this sort does not have any term formers. It is an uninterpreted domain which may have
variables but has no constant symbols, binary operators, or anything else targeting this sort. If a sort has
this modifier, it is illegal to declare a term with this sort as the target.
strict is the "opposite" of pure: it says that the sort does not have any variable binding operators. It is illegal
to have a bound variable or dummy variable of this sort, and it cannot appear as a dependency in another
variable. For example, if x: set and ph: wff x then set must not be declared strict. (pure and strict are not
mutually exclusive, although a sort with both properties is not very useful.)
provable means that the sort is a thing that can be "proven". All formulas appearing in axioms and theorems
(between $) must have a provable sort.
free means that definitions and theorems are not allowed to use dummy variables with this sort.
то кажется мне, что слишком это сложно. Надо проще это всё сделать, по принципу какой-нибудь
хрени типа SKI кобенационного исчисления. Т.е. допустим аксиома для модус поненса
AXIOM
%A
P P $IMP %A %B
_
%B
т.е. если мы матчим некую хуйню "%A" и некую хуйню "P P $IMP %A %B" где %A и %B это некая
срань, которая может быть "что-то" "P чтото чтото" или там "P чтото P чтото чтото" и т.д.
ну короче P означает что там две какие-то хуйни, вот как в той хрени https://govnokod.ru/27420
то можем дополнительно синтезировать высказывание "%B"
А теоремы это negj композиции из аксиом и других теорем. Типы можно прикручивать через какую-то хуйню
типа если арифметику Пеано описывать, тип можно так что-то нахуевертить аксиому, ну типа
Определение что ZERO это натуральное число.
AXIOM
_
P NAT ZERO
Что если инкрементнуть натуральное, будет тоже натуральное (S это функция следования)
AXIOM
P S %A
P NAT %A
_
P NAT P S %A
В общем надо бы подумать, как там запилить максимально простой и эффективно расширяемый язык для
доказывания всякой хуйни.
Смотрел Coq - какая-то ебаная перепитушня со всякими там типами-хуипами и какими-то
блядь рекурсиями. Хер поймешь, как эта вся дрнсня работает. Меня ваши типы не ебут
совершенно, я хочу сам свои типы конструировать, а не полагаться на какую-то невнятную
ебанину.
+3
#include <stdio.h>
#include <string.h>
#include "s_gets.h"
#define SIZE 30
void revers(char *);
int main(){
char str[SIZE];
s_gets(str, SIZE);
revers(str);
puts(str);
return 0;
}
void revers(char * str){
int size_ = strlen(str) - 1;
char tmp;
for(int i = size_; i >= 0; i--){
tmp = str[i];
str[i] = str[size_ - i];
str[size_ - i] = tmp;
}
}
https://ru.stackoverflow.com/questions/1173617/Изменения-строки-в-функции
> Собственно задание заключается в написании функции, которая заменяет содержимое указанной строки этой же строкой, но с обратным порядком следования символов. Почему строка не переворачивается?
Какой багор )))