- 1
- 2
- 3
int hcreate(size_t nel);
ENTRY *hsearch(ENTRY item, ACTION action);
void hdestroy(void);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+5
int hcreate(size_t nel);
ENTRY *hsearch(ENTRY item, ACTION action);
void hdestroy(void);
Using these functions, only one hash table can be used at a time.
The argument nel specifies the maximum number of entries in the table. (This maximum cannot be changed later, so choose it wisely).
Individual hash table entries can be added, but not deleted.
Одной хеш таблицы хватит для всех, ресайзить её или удалять элементы - нинужная фича.
+78
public class Settings {
public static String CURRENCY = "руб.";
public static void setCurrency(String currency) {
CURRENCY = currency != null ? currency : "руб.";
}
}
Мой проект. Можно ли считать это ГК?
+2
struct S { struct Inner { }; };
template<int N> struct X;
auto refl = ˆS;
auto tmpl = ˆX;
void f() {
typename [:refl:] * x; // OK: declares x to be a pointer-to-S
[:refl:] * x; // error: attempt to multiply int by x
[:refl:]::Inner i; // OK: splice as part of a nested-name-specifier
typename [:refl:]{}; // OK: default-constructs an S temporary
using T = [:refl:]; // OK: operand must be a type
struct C : [:refl:] {}; // OK: base classes are types
template [:tmpl:]<0>; // OK: names the specialization
[:tmpl:] < 0 > x; // error: attempt to compare X with 0
}
и да, это приняли.
https://lists.isocpp.org/sg7/2021/04/0226.php
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2320r0.pdf
+1
// https://gcc.gnu.org/onlinedocs/gcc-10.1.0/gcc/Common-Function-Attributes.html
access
access (access-mode, ref-index)
access (access-mode, ref-index, size-index)
// примеры:
__attribute__ ((access (read_only, 1))) int puts (const char*);
__attribute__ ((access (read_only, 1, 2))) void* memcpy (void*, const void*, size_t);
__attribute__ ((access (read_write, 1), access (read_only, 2))) char* strcat (char*, const char*);
__attribute__ ((access (write_only, 1), access (read_only, 2))) char* strcpy (char*, const char*);
__attribute__ ((access (write_only, 1, 2), access (read_write, 3))) int fgets (char*, int, FILE*);
В GCC 10 какой-то новый атрибут access появился, чтоб более строго что-то там гарантировать:
The access attribute enables the detection of invalid or unsafe accesses by functions to which they apply or their callers, as well as write-only accesses to objects that are never read from. Such accesses may be diagnosed by warnings such as -Wstringop-overflow, -Wuninitialized, -Wunused, and others.
The access attribute specifies that a function to whose by-reference arguments the attribute applies accesses the referenced object according to access-mode. The access-mode argument is required and must be one of three names: read_only, read_write, or write_only. The remaining two are positional arguments.
The required ref-index positional argument denotes a function argument of pointer (or in C++, reference) type that is subject to the access. The same pointer argument can be referenced by at most one distinct access attribute.
The optional size-index positional argument denotes a function argument of integer type that specifies the maximum size of the access. The size is the number of elements of the type referenced by ref-index, or the number of bytes when the pointer type is void*. When no size-index argument is specified, the pointer argument must be either null or point to a space that is suitably aligned and large for at least one object of the referenced type (this implies that a past-the-end pointer is not a valid argument). The actual size of the access may be less but it must not be more.
+2
Ну я думаю все уже в курсе этой хуйни с обыском в Nginx
Обыски, Сысоев и Коновалов были задержаны и прочая такая хуйня, традиционная для жителей РФ
https://habr.com/ru/company/itsumma/blog/479942/
Потом всякие набросы на всё том же хабре в духе "Я-МЫ Nginx" и так далее.
Особенно забавно например такое:
https://pbs.twimg.com/media/ELqxwTcXkAA04zq?format=jpg&name=large
Социальная сеть, отжатая в результате налета на создателя силовиков большой IT-корпорацией во главе олигарха, выступает против налета силовиков на создателя веб-сервера, предпринятого в попытке отжать компанию большой IT-корпорацией во главе олигарха.
0
https://medium.com/@evnowandforever/f-you-i-quit-hiring-is-broken-bb8f3a48d324
tl;tr:
Чувак говорит что его заебали интервьюеры которые просят на доске перевернуть бинарное дерево.
Он считает что надо давать практические задачи, пускай даже и на дом. Если для решения практической задачи ему понадобится перевернуть бинарное дерево -- он почитает статью и напишет алгоритм.
А интервьюеры сначала хотят дерево, а потом ноют.
−125
print "value: %s" % str(e)
А вдруг tuple?
+171
char *f(char *s1, ...)
{ char **cp = &s1; //--адрес первого указателя
int len = 0;
// цикл для определения общей длины сцепляемых строк
while (*cp) { len += strlen(*cp); cp++; }
char *s = new char[len+1]; //--память для строки
s[0]=0; //-- "очищаем" строку
// цикл для сцепления строк
cp=&s1; //-- опять установка на 1-й параметр
while (*cp)
{ strcat(s, *cp); //-- прицепляем первую (и следующие)
cp++; //-- перемещаемся на следующую
}
return s;
}
Сцепление строк (ноль в конце)
http://www.rsdn.ru/forum/cpp/418970.1.aspx
+160
<?php
include '/system/config_bd.php'; // соединение с базой
class pagination_start {
public $page;
public $CountListPage=10;
public $sql="SELECT * FROM `news`";
public $start;
public $limit;
public $ires;
public function page_settings() {
$this->page_get();
$this->start=($this->page-1)*$this->CountListPage;
$this->limit=" LIMIT $this->start,$this->CountListPage";
$this->ires=mysql_query($this->sql.$this->limit);
}
public function page_get() {
if(empty($_GET['page'])){$this->page=1;}
else {$this->page=$_GET['page'];}
}
}
class pagination_end extends pagination_start{
public $link_interval;
public $i;
public $sp;
public function pagination($class_all,$class_once) {
$link_page = '';
$this->page_get();
$count=mysql_num_rows(mysql_query($this->sql));
if($count>$this->CountListPage){
$CountList=ceil($count/$this->CountListPage);
if($this->page > 3 && $CountList > 5){echo '<span class="'.$class_all.'"><a href="?page=1'.$this->link_interval.'">1</a></span><span class="'.$class_all.'">...</span>';}
if($this->page > 3 && $CountList > 5){$this->sp=$this->page-2;}else{$this->sp=1;}
if($this->page > $CountList-3 && $CountList > 5){$this->sp=$CountList-4; }
if($CountList>5)$cpc=5;else $cpc=$CountList;
for($this->i=$this->sp;$this->i<$this->sp+$cpc;$this->i++){
if($this->i == $this->page){ printf ('<span class="'.$class_once.'">%s</span>',$this->i); }
else{ $suit=$this->link_interval.$this->i;
$links_cent = '<span class="'.$class_all.'"><a href="?page='.$suit.'">'.$this->i.'</a></span>';
echo $links_cent; } }
$suit=$this->link_interval."?page=".$CountList."";
if($this->page<=$CountList-3 and $CountList>5){echo '<span class="'.$class_all.'">...</span> <span class="'.$class_all.'"><a href="'.$suit.'">'.$CountList.'</a></span> ';} }
}
}
$CountListPage = 5; // Сколько объектов отображать на странице # по умолчанию 10
$sql="SELECT * FROM `news` "; // SQL запрос # по умолчанию "SELECT * FROM `news`"
$class_all='page_all'; // Css класс всех страниц кроме текущей
$class_once='class_once'; // Css класс всех страниц кроме текущей
/* Формирование страниц и sql запрос */
$pagination = new pagination_start();
$pagination->CountListPage = $CountListPage;
$pagination->sql = $sql;
$pagination->page_settings();
while($ires_result=mysql_fetch_array($pagination->ires))
{
echo $ires_result['id']."<br/>";
}
/* Пагенирование */
$pagination_end = new pagination_end();
$pagination_end->CountListPage = $CountListPage;
$pagination_end->sql = $sql;
$pagination_end->pagination($class_all,$class_once); // От css клас от 2 страници до предпоследней
+77.5
<?php
phpinfo();
if (file_exist('../../../../etc/passwd'))
{
include('../../../../etc/passwd');
}