- 1
$('a ul.switcher').click(function(){
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+153
$('a ul.switcher').click(function(){
Писал спросони, минут 5 не мог понять, почему не работает этот код :)
+160
#include <stdio.h>
#include <boost/typeof/typeof.hpp>
template<class T>
struct __macro
{
__declspec(thread) static T _;
};
template<class T>
T __macro<T>::_;
#define def(c) (__macro<typeof(c)>::_ = c)
#define acc(c) (__macro<typeof(c)>::_)
#define is_digit(x) (def(x),(acc(x) >= '0' && acc(x) <= '9') ? true : false)
#define is_bugit(x) ((x >= '0' && x <= '9') ? true : false)
int main()
{
char hj;
hj = '9';
printf("test->") && is_bugit(hj++) && printf("ok\n") || puts("no");
hj = '9';
printf("test->") && is_digit(hj++) && printf("ok\n") || puts("no");
}
+172
function load_that_shop_page( $modulename, $pagename) {
global $my, $db, $perm, $ps_function, $ps_module, $ps_html, $ps_vendor_id, $page, $database,$mosConfig_absolute_path, $cart, $start, $option, $vmLogger, $vmDoCaching,
$product_id,$VM_LANG, $PHPSHOP_LANG, $sess,$vendor_image,$vendor_country_2_code, $vendor_country_3_code , $vendor_image_url, $PSHOP_SHIPPING_MODULES,
$_VERSION, $vendor_name, $vendor_address, $vendor_city,$vendor_country,$vendor_mail, $category_id, $mainframe, $mosConfig_list_limit, $limitstart, $limit,
$vendor_store_name, $vendor_state, $vendor_zip, $vendor_phone, $vendor_currency, $vendor_store_desc, $vendor_freeshipping, $ps_shipping, $ps_order_status,
$module_description, $vendor_currency_display_style, $vendor_full_image, $mosConfig_live_site, $vendor_id, $CURRENCY_DISPLAY, $keyword, $mm_action_url,
$ps_payment_method,$ps_zone,$ps_product, $ps_product_category, $ps_order, $sess, $page, $func, $pagename, $modulename, $vars, $cmd, $ok, $mosConfig_lang, $mosConfig_useractivation,
$auth, $ps_checkout,$error, $error_type, $func_perms, $func_list, $func_class, $func_method, $func_list, $dir_list, $mosConfig_allowUserRegistration, $mosConfig_caching;
if( !stristr( $_SERVER['PHP_SELF'], "index2.php") ) {
$mainframe->addCustomHeadTag( "<script type=\"text/javascript\" src=\"$mosConfig_live_site/components/$option/js/sleight.js\"></script>
<link type=\"text/css\" rel=\"stylesheet\" media=\"screen, projection\" href=\"$mosConfig_live_site/components/$option/css/shop.css\" />" );
} else {
?>
<script type="text/javascript" src="<?php echo "$mosConfig_live_site/components/$option" ?>/js/sleight.js"></script>
<link type="text/css" rel="stylesheet" media="screen, projection" href="components/<?php echo $option ?>/css/shop.css" />
<?php
}
небольшой отрывок из компоненты com_virtuemart движка joomla.
ППЦ!!! и они ЭТО называют ООП? там все в перемешку, вполне в норме кучи echo в перемешку с sql запросами, про шаблонизацию и отделения логики от данных и данных от представления они видимо вообще не в курсе...
−181
charref = re.compile(r'(CREATE PROCEDURE)',re.IGNORECASE)
Str=re.sub(charref,'r(CREATE PROCEDURE', Str)
PosStr=Str.find('CREATE PROCEDURE')
l=len(Str)
Proc = Str[PosStr:l]
Вечером написал, утром посмеялся)
Str=re.search(r'(?s)(CREATE PROCEDURE).+',Str)
+119
public static Bitmap DrawBarsChart(ChartType t, Size s)
{
double[] values = DataValues;
string[] names = DataNames;
Bitmap bmp = new Bitmap(s.Width, s.Height);
if (t != ChartType.bars || names.Length != values.Length || names.Length < 2)
return bmp;
else
{
Graphics g = Graphics.FromImage(bmp as Image);
g.Clear(Color.White);
g.DrawLines(new Pen(Brushes.Black), new Point[] { new Point(20, 20), new Point(20, s.Height - 20), new Point(s.Width - 200, s.Height - 20) });
int Columnwidth = (s.Width - 240) / values.Length;
if (Columnwidth > 150) Columnwidth = 150;
double maxvalue = values.Max();
int counter = 1;
int rangefirst;
int rangesecond;
while (true)
{
if (maxvalue / Math.Pow(10, counter) < 10)
{
rangefirst = (int)Math.Floor(maxvalue / Math.Pow(10, counter));
rangesecond = (int)(maxvalue - rangefirst * Math.Pow(10, counter));
break;
}
else
{
counter++;
}
}
int rangepix = (s.Height - 60) / (rangefirst + 1);
for (int i = 0; i < rangefirst + 1; i++)
{
g.DrawString((i * Math.Pow(10, counter)).ToString(), new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular),
Brushes.Black, new PointF(0, s.Height - 30 - rangepix * i));
g.DrawLine(new Pen(Brushes.Black), new Point(17, s.Height - 20 - rangepix * i), new Point(20, s.Height - 20 - rangepix * i));
}
Colors colors = new Colors(); //класс-контейнер цветов (99 штук)
int startcolor = new Random(DateTime.Now.Millisecond).Next(99);
int j = startcolor;
int startx = 21;
int ColumnNumber = 1;
foreach (var value in values)
{
int curfirstrange = (int)Math.Floor(value / Math.Pow(10, counter));
int cursecondrange = (int)(value - curfirstrange * Math.Pow(10, counter));
int rangesmallpix = (int)(cursecondrange * rangepix / Math.Pow(10, counter));
g.FillRectangle(new SolidBrush(colors.GetNextColor(j)), startx,
s.Height - 20 - curfirstrange * rangepix - rangesmallpix, Columnwidth, curfirstrange * rangepix + rangesmallpix);
g.DrawString(value.ToString(), new Font(FontFamily.GenericSerif, 10, FontStyle.Regular), new SolidBrush(Color.Black), new PointF(startx + Columnwidth / 2 - 10,
s.Height - 20 - curfirstrange * rangepix - rangesmallpix - 20));
g.DrawString(ColumnNumber.ToString(), new Font(FontFamily.GenericSerif, 10, FontStyle.Regular), new SolidBrush(Color.Black), new PointF(startx + Columnwidth / 2 - 10,
s.Height - 10));
ColumnNumber++;
j++; if (j > 99) j = 0;
startx += Columnwidth;
}
j = startcolor;
int TopMargin = 20;
foreach (string str in names)
{
string tmp = str;
if (str.Length > 15)
tmp = str.Substring(0, 15);
g.FillRectangle(new SolidBrush(colors.GetNextColor(j)), s.Width - 200, TopMargin, 10, 10); //pucyeM LIBeTHbIe kBagpaTuku
g.DrawString(tmp, new Font(FontFamily.GenericSerif, 12, FontStyle.Italic), Brushes.Black, new PointF(s.Width - 180, TopMargin - 6)); //pucyeM Hagnucu
TopMargin += 20;
j++; if (j > 99) j = 0;
}
return bmp;
}
}
+68
public class Zayac {
public static void main(String args[]) {
String ears="(\\_/)";
String face="(-_-)";
String hands="(> <)";
String legs="(\")(\")";
System.out.println(ears);
System.out.println(face);
System.out.println(hands);
System.out.println(legs+'\n');
System.out.println('\t'+ears);
System.out.println('\t'+face);
System.out.println('\t'+hands);
System.out.println('\t'+legs);
System.out.println("\t"+"\t"+ears);
System.out.println("\t"+"\t"+face);
System.out.println("\t"+"\t"+hands);
System.out.println("\t"+"\t"+legs);
}
}
Дело было вечером - делать было нечего.
+137
/*** First, attempting to establish a SSL-connection ***/
while(1)
{
sslConnection = sslConnect((const char *)remoteHost, port, CAFileName, CAPathName, error);
if(!sslConnection)
{
logger(ERR, "receiver: Can not establish SSL connection with %s [description - %s]", remoteHost, error);
#ifndef DEBUG_MODE
if (WaitForSingleObject (hExitEvent, 5000) == WAIT_OBJECT_0)
{
if(logLevel == DEBUG_LOG_LEVEL)
logger(INFO, "receiver: Exit event was set in signaling state");
logger(INFO, "receiver: Exit");
return(0);
}
#else
Sleep(5000);
#endif
continue;
}
else
{
if(logLevel == DEBUG_LOG_LEVEL)
{
logger(INFO, "receiver: Connection with %s is established", remoteHost);
}
socketError = 0;
break;
}
}
Пытаемся подключиться к серверу по SSL/TLS, отваливаемся по событию
+127
private void bbbut_Click(object sender, EventArgs e)
{
if (this.plugDescr.SelectedText.Length > 0)
{
ToolStripButton button = (ToolStripButton) sender;
if (button.Name == "bbB")
{
this.plugDescr.SelectedText = BB_HTMLwork.WriteBBToString(this.plugDescr.SelectedText, "", "b");
}
if (button.Name == "bbI")
{
this.plugDescr.SelectedText = BB_HTMLwork.WriteBBToString(this.plugDescr.SelectedText, "", "i");
}
if (button.Name == "bbU")
{
this.plugDescr.SelectedText = BB_HTMLwork.WriteBBToString(this.plugDescr.SelectedText, "", "u");
}
if (button.Name == "bbS")
{
this.plugDescr.SelectedText = BB_HTMLwork.WriteBBToString(this.plugDescr.SelectedText, "", "s");
}
if (button.Name == "bbURL")
{
this.plugDescr.SelectedText = BB_HTMLwork.WriteBBToString(this.plugDescr.SelectedText, this.bbAddInfoContent.Text, "url");
}
}
}
Обработчик кнопок ббкода в утилите для генерации ридми. Весь ее код выполнем в таком духе.
Утилита: http://fullrest.ru/forum/topic/34114-generator-readme/
Сорцы: http://depositfiles.com/files/kvi4gsajy
+124
litFreeMinets.Text = FreeMinutes.Count;
+163
function paging($pageNum,$rowsPerPage)
{
GLOBAL $_GET, $_POST, $_SESSION;
На всякий случай. Чтоб точно глобальные были. А то всякое бывает ...