- 1
Андроидотред #3
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−4
Андроидотред #3
#1: https://govnokod.xyz/_19062
#2: https://govnokod.xyz/_25537 (стерла пидорва сракер)
−2
#include <stdio.h>
#include <stdlib.h>
int main ()
{
int a=120;
printf("%i\n",*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&*&*&*&*&*&*&*&*&*&
*&*&*&a);
}
+18
template <typename T>
struct canref {
struct yes { uint8_t bytes[1]; };
struct no { uint8_t bytes[2]; };
template <typename U> static yes test(U*p);
template <typename U> static no test(...);
static const bool value = sizeof(test<T>(NULL)) == sizeof(yes);
};
template <typename T, int N, bool CanRef=canref<T>::value>
class array;
// class for all types
template <typename T, int N>
class array <T,N,true>
{
struct Bytes
{
uint8_t bytes[sizeof(T)];
};
struct TStruct
{
T t;
TStruct(T t):t(t){}
};
Bytes elements[N];
int count;
void copy_ctor (int index, const T& t)
{
new (&((*this)[index])) T(t);
}
void copy (int index, const T& t)
{
(*this)[index] = t;
}
void dtor (int index)
{
(*this)[index].~T();
}
public:
array () : count(0) {}
~array ()
{
resize(0);
}
T& operator [] (int index)
{
assert (index>=0 && index<count);
return ((TStruct*)(&elements[index]))->t;
}
const T& operator [] (int index) const
{
assert (index>=0 && index<count);
return ((TStruct*)(&elements[index]))->t;
}
template <int M>
array (const array<T,M> &a)
{
assert(a.count<=N);
count = a.count;
for (int i=0; i<count; ++i)
copyctor(i, a[i]);
}
template <int M>
array& operator = (const array<T,M> &a)
{
if (this != &a)
{
if (count>a.count)
{
for (int i=0; i<a.count; ++i) copy(i, a[i]);
for (int i=a.count; i<count; ++i) dtor(i);
count = a.count;
} else
{
assert(a.count<=N);
int ocount = count;
count = a.count;
for (int i=0; i<ocount; ++i) copy(i, a[i]);
for (int i=ocount; i<count; ++i) copy_ctor(i, a[i]);
}
}
}
int size()
{
return count;
}
Скоро даже сратору станет очевидно откуда это.
−87
>>> r=range(16);print '\n'.join(' '*y+' '.join('# '[x&y>0] for x in r) for y in r)
# # # # # # # # # # # # # # # #
# # # # # # # #
# # # # # # # #
# # # #
# # # # # # # #
# # # #
# # # #
# #
# # # # # # # #
# # # #
# # # #
# #
# # # #
# #
# #
#
1. Почему f(x, y) = 1-sign(x&y) даёт в результате треугольник Серпинского?
2. Олимпиада: на вашем любимом языке написать программу, которая выводит аналогичный фрактал(см. код). Победит тот язык, программа на котором займёт наименьшее число символов. Нулевое приближение на Python - 78 символов.
+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)");