- 1
$('img.avatar').attr("src", "http://upload.wikimedia.org/wikipedia/commons/a/a4/Human_penis_2_by_Yiyi1394.jpg")
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+140
$('img.avatar').attr("src", "http://upload.wikimedia.org/wikipedia/commons/a/a4/Human_penis_2_by_Yiyi1394.jpg")
= http://prntscr.com/36l35i
+27
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>
#include <utility>
#include <sstream>
#include <assert.h>
using namespace std;
struct PeriodDescription{
size_t length, repeat_amount, last_items_amount;
/*friend ostream& operator<<(ostream& os, const PeriodDescription& s){
os<<" (PeriodDescription){"<<s.length<<", "<<s.repeat_amount<<", "<<s.last_items_amount<<"} ";
return os;
}*/
};
/*template<class C>
string co(C&& c){
ostringstream r;
r<<" (C) {";
copy(c.begin(), c.end(), ostream_iterator<typename C::value_type>(r, ", "));
r<<"}; ";
return move(r.str());
}*/
vector<PeriodDescription> find_repeat_sequences_since_begin(const string& sequence){
vector<PeriodDescription> result;
if(sequence.empty())
return result;
auto position_at_last_period=sequence.begin();
const char first_item = *position_at_last_period;
const auto after_last=sequence.end();
auto position_at_current_period = position_at_last_period;
while(true){
position_at_last_period=sequence.begin();
position_at_current_period = find(next(position_at_current_period), after_last, first_item);
PeriodDescription new_period {size_t(distance(position_at_last_period, position_at_current_period)), 1, 0};
while(position_at_current_period!=after_last && *position_at_last_period==*position_at_current_period){
++position_at_last_period; ++position_at_current_period;
if(++new_period.last_items_amount>=new_period.length){
new_period.last_items_amount = 0;
++new_period.repeat_amount;
}
}
if(new_period.repeat_amount==1 && new_period.last_items_amount==0)
return result;
result.push_back(new_period);
if(position_at_current_period==after_last)
return result;
}
}
vector<size_t> generate_FSM_failJumpIndices(const vector<PeriodDescription>& periodDescriptions, const size_t stringLength){
vector<size_t> r(stringLength+1);
for(const auto& pd : periodDescriptions){
for(size_t periodIndex=1; periodIndex<pd.repeat_amount; ++periodIndex)
for(size_t indexAtPeriod=0; indexAtPeriod<pd.length; ++indexAtPeriod)
r[(periodIndex*pd.length)+indexAtPeriod]=(periodIndex-1)*pd.length + indexAtPeriod;
for(size_t indexAtAfterPeriods=0; indexAtAfterPeriods<pd.last_items_amount; ++indexAtAfterPeriods)
r[pd.length*pd.repeat_amount+indexAtAfterPeriods]=pd.length*(pd.repeat_amount-1)+indexAtAfterPeriods;
}
return r;
}
vector<size_t> make_FSM_failJumpIndices(const string& sequence){
return generate_FSM_failJumpIndices(find_repeat_sequences_since_begin(sequence), sequence.size());
}
class FSM_for_find_equal_ranges{
size_t state;
vector<size_t> failJumpIndices;
string sequence;
string::const_iterator find_next(string::const_iterator checkPosition, const string::const_iterator last){
struct atReturn{
size_t& state;
~atReturn(){state = 0;}
}nullify{state};
if(checkPosition==last)
return last;
if(sequence.empty())
return next(checkPosition);
if(size_t(distance(checkPosition, last))<sequence.size())
return last;
while(true){
if(checkPosition==last)
return last;
if(*checkPosition==sequence[state])
++state;
else
state=failJumpIndices[state];
++checkPosition;
if(state>=sequence.size())
return prev(checkPosition, sequence.size());
}
}
public:
template<class T>
FSM_for_find_equal_ranges(T&& sequence):
Очередное собеседование. Пригласили на должность дельфина. Но оп отказался проходить собеседование на дельфи.
http://ideone.com/zp5CRb
+167
gl.drawArrays(gl.QUADS, 0, 4);
// WebGL рисует черный экран с четырьмя точками.
bormand vs WebGL. Акт второй.
Как оказалось, в OpenGL ES выпилили GL_QUADS и GL_POLYGON.
Но т.к. в js несуществующее поле это null, а null это 0, а 0 это GL_POINTS, то рисуются 4 точки ;)
+155
//users.php
public function search_()
{
// --- Поиск по пользователям
$sql_search = mysql_query($this->sql);
$folder = $this->folder;
if (mysql_num_rows($sql_search)>0)
{
$row_search = mysql_fetch_assoc($sql_search);
do
{
$user_id = $row_search["id"];
$sql = mysql_query("SELECT SOCIAL_fotos.picture_mini FROM SOCIAL_fotos WHERE fotoalbum_id = '0' and user_id = '$user_id' LIMIT 1");
if (mysql_num_rows($sql)>0)
{
$row_sql = mysql_fetch_assoc($sql);
$picture_mini = $row_sql["picture_mini"];
}
else
$picture_mini = "picture/empty_mini.jpg";
printf("<p><a href=\"%s\" target=\"_blank\"><img src=\"$folder/%s\">%s</a><br>%s", $row_search["alias"], $picture_mini, $row_search["lfm"], $row_search["city"]);
}
while($row_search = mysql_fetch_assoc($sql_search));
}
}
//funct_prover.php
function prover($con)
{
$element = array("'");
$con = str_replace($element, ";appost;", $con);
return htmlspecialchars(trim($con));
}
//conf_connect.php
$server_con = 'localhost'; // Адрес сервера mysql
$username_con = ''; // Имя пользователя
$password_con = ''; // Пароль
$dbname_con = 'socialdb';
$url = $_SERVER["HTTP_HOST"];
$site1 = 'panzins.ru';
$site2 = 'www.panzins.ru';
if ($url != $site1 and $url != 'localhost' and $url != $site2)
exit();
$url_path = $_SERVER["REQUEST_URI"];
if ($url == $site2)
{
header("Location: http://panzins.ru$url_path");
exit();
}
mysql_connect($server_con, $username_con, $password_con) or die("No connection");
mysql_query('SET NAMES utf8') or die("Set names error");
mysql_select_db($dbname_con) or die("No database");
header('Content-Type:text/html; charset=utf-8');
$table_log = "SOCIAL_log";
$table_alias = "SOCIAL_alias";
$table_user = "SOCIAL_user";
// И еще много няшек
MVC, PDO, Framework, для лохов ибо там избыточный код. Написать свою соц сеть за 30 дней легко. Знакомьтесь, Сергей Панзин, скромный адепт Жопова. http://rutracker.org/forum/viewtopic.php?t=4619804
Сам шидевр. http://panzins.ru/
+135
bool exit = false;
while (!exit)
{
if (Console.KeyAvailable)
{
ConsoleKeyInfo key = Console.ReadKey(true);
exit = true;
}
}
Православная замена Console.ReadKey();
−133
yum remove python
Еще один способ "отпилить ветку под собой"
http://www.linux.org.ru/forum/admin/8946020
+16
char tab1[22][8]={"program","var","begin","end","int","float","bool","if","then","else","for","to","do","while","readln","writeln","as","||","!","&&","true","false"};
char tab2[18][3]={"==","<",">","+","-","*","/","(",")",".",",",";"," ","!=","<=",">=",10};
//Много кода
if(!strcmp("program",st.top())&&!strcmp("program",&mas[j][0]))
{
st.pop();
j++;
}
else
if(!strcmp("var",st.top())&&!strcmp("var",&mas[j][0]))
{
st.pop();
j++;
}
else
if(!strcmp("begin",st.top())&&!strcmp("begin",&mas[j][0]))
{
st.pop();
j++;
}
else
if(!strcmp("end",st.top())&&!strcmp("end",&mas[j][0]))
{
st.pop();
j++;
}
else
if(!strcmp("int",st.top())&&!strcmp("int",&mas[j][0]))
{
st.pop();
j++;
}
else
if(!strcmp("float",st.top())&&!strcmp("float",&mas[j][0]))
{
st.pop();
j++;
}
//Еще строк 200 такого
−101
- (void)viewDidLoad
{
// ...
float os_verson = [[[UIDevice currentDevice] systemVersion] floatValue];
NSString* dev_ver_str = [[UIDevice currentDevice] systemVersion];
if (os_verson >= 4 || [dev_ver_str hasPrefix:@"3.2"]) {
[self viewWillAppear:NO];
[self viewDidAppear:NO];
}
}
Костыли наше всё
+10
for (int i = 0; i < 15; i++) {
// Прикольное место, надо прокомментировать
// Если наша функция Fork() вернула true, то мы
// в дочернем процессе и форкаться больше не надо
// Форканье - это задача родителя
// Дети этим заниматься не должны
if (Fork()) break;
}
Создание дочерних процессов. Вот такой костыль. Есть идеи, как улучшить?
+19
//generate the new objects
EnterCriticalSection(&csWinEvent);
value arr = alloc_array(windowStates.size());
int i=0;
for(
std::tr1::unordered_map<int,windowState>::const_iterator it = windowStates.begin();
it!=windowStates.end();
++it )
{
value o = alloc_empty_object();
//int hwnd
//int x,y,w,h
//int minimized,maximized,restored,closed
alloc_field(o, val_id("hwnd"), alloc_int(it->first));
alloc_field(o, val_id("window"), *(value*)GetWindowLongPtr((HWND)it->first,GWLP_USERDATA) );
alloc_field(o, val_id("x"), alloc_int(it->second.x));
alloc_field(o, val_id("y"), alloc_int(it->second.y));
alloc_field(o, val_id("w"), alloc_int(it->second.w));
alloc_field(o, val_id("h"), alloc_int(it->second.h));
alloc_field(o, val_id("minimized"), alloc_int(it->second.minimized));
alloc_field(o, val_id("maximized"), alloc_int(it->second.maximized));
alloc_field(o, val_id("restored"), alloc_int(it->second.restored));
alloc_field(o, val_id("closed"), alloc_int(it->second.closed));
val_array_set_i(arr,i,o);
++i;
}
windowStates.clear();
LeaveCriticalSection(&csWinEvent);
Casts ;]