- 1
print "value: %s" % str(e)
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−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');
}
0
> Improved People Nearby
Profile videos make meeting new people a dozen times more interesting, and we've beefed up the People Nearby section for the occasion.
When people contact you via the People Nearby section, you will see how far away they are. And when you start a chat with someone nearby,
Telegram will suggest a greeting sticker to break the ice. Luckily, all our stickers are extroverts.
самый секьюрный мессенджер теперь палит еще и локацию юзеров
теперь это у нас тиндер такой
https://telegram.org/blog/profile-videos-people-nearby-and-more
https://telegram.org/blog/new-profiles-people-nearby
0
https://habr.com/ru/post/454354/
> я на данный момент только выпустился из 11-го
> На мой взгляд у меня имеется неплохое резюме с кучей ачивок и хороший скилл,
который я день за днем совершенствую последние 8-9 лет.
Какой скилл )))
Помню свой 11 класс, где я понятия не имел что такое погромирование.
+21
angle_in_radians = acos(dot(normalize(o-a), normalize(o-b)));
Векторы такие сложные, а операции с ними так трудно запомнить, что даже игроделы не могут это сделать.
−1
Минск #5
#1: https://govnokod.ru/25937 https://govnokod.xyz/_25937
#2: https://govnokod.ru/26458 https://govnokod.xyz/_26458
#3: https://govnokod.ru/27233 https://govnokod.xyz/_27233
#4: https://govnokod.ru/27448 https://govnokod.xyz/_27448
−1
nsresult
nsHtml5Parser::Parse(const nsAString& aSourceBuffer,
void* aKey,
const nsACString& aContentType,
bool aLastCall,
nsDTDMode aMode) // ignored
{
nsresult rv;
if (NS_FAILED(rv = mExecutor->IsBroken())) {
return rv;
}
if (aSourceBuffer.Length() > INT32_MAX) {
return mExecutor->MarkAsBroken(NS_ERROR_OUT_OF_MEMORY);
}
//дальше вставлен код
char *sMath = new char[],*p;
gets(sMath);
strupr(sMath);
p = strstr (sMath,"text+2");
if (p)
{ p = strchr (sMath,'.');
if (p)
strcat (sMath,"text+2");
}
delete [] sMath;
Доброго времени всем.
нашел код поиска и замены символов в строке. ставлю в исходник. компилятор пропускает , но в самом финале зависает насмерть. Уже вроде бы все:
EXE header size: 62464 / 37888 bytes
139:39.45 Install code: 169642 / 169638 bytes
139:39.45 Install data: 173316 / 173324 bytes
139:39.45 Uninstall code+data: 460087 / 460079 bytes
139:39.45 CRC (0xB7F63C0E): 4 / 4 bytes
139:39.45
139:39.45 Total size: 865513 / 840933 bytes (102.9%)
последняя строчка: 140:48.58 Packaging [email protected]:51.45 207 compiler warnings present.
уже полдня висит, а финал не выдает:
247:11.23 We know it took a while, but your build finally finished successfully!
To view resource usage of the build, run |mach resource-usage|.
To take your build for a test drive, run: |mach run|
For more information on what to do now, see https://developer.mozilla.org/docs/Developer_Guide/So_You_Just_Built_Firefox
+974
/*Вариант - вручную*/
#include <iostream>
#include <map>
#include <string>
#include <utility>
int main(int argc, char* argv[]) {
std::map<std::string, std::pair<int, int> > files;
files["0.txt"] = std::make_pair(0, 7);
files["1.txt"] = std::make_pair(8, 41);
files["2.txt"] = std::make_pair(42, 50);
std::map<std::string, std::pair<int, int> >::const_iterator begin = files.begin();
std::map<std::string, std::pair<int, int> >::const_iterator end = files.end();
int num = 21;
for (; begin != end; ++begin) {
if (num >= (*begin).second.first && num <= (*begin).second.second) {
std::cout << "Found in " + (*begin).first + "\n";
break;
}
}
return 0;
}
/*Вариант - STL+BOOST*/
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <boost/bind.hpp>
int main(int argc, char* argv[]) {
typedef std::map<std::string, std::pair<int, int> > map_type;
map_type files;
files["0.txt"] = std::make_pair(0, 7);
files["1.txt"] = std::make_pair(8, 41);
files["2.txt"] = std::make_pair(42, 50);
int num = 21;
map_type::const_iterator elem;
elem = std::find_if(
files.begin(),
files.end(),
boost::bind(
std::logical_and<bool>(),
boost::bind(
std::less_equal<int>(),
boost::bind(
&map_type::value_type::second_type::first,
boost::bind(
&map_type::value_type::second,
_1)
),
num),
boost::bind(
std::greater_equal<int>(),
boost::bind(
&map_type::value_type::second_type::second,
boost::bind(
&map_type::value_type::second,
_1)
),
num)));
if (elem != files.end())
std::cout << "Found in " + (*elem).first + "\n";
return 0;
}
Смысл в том, чтобы с данным значением(пример 21) пройтись по таблице и найти в каком элементе данное число(21) находится в диапазоне std::pair<int, int>...
Сначала написал вручную, но т.к. нужно было сделать с помощью STL, получилось сие чудо.