- 1
normalize((a+b)/2)
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+15
normalize((a+b)/2)
+136
countDigits :: (Integral a) => a -> Int
{-# INLINE countDigits #-}
countDigits v0 = go 1 (fromIntegral v0 :: Word64)
where go !k v
| v < 10 = k
| v < 100 = k + 1
| v < 1000 = k + 2
| v < 1000000000000 =
k + if v < 100000000
then if v < 1000000
then if v < 10000
then 3
else 4 + fin v 100000
else 6 + fin v 10000000
else if v < 10000000000
then 8 + fin v 1000000000
else 10 + fin v 100000000000
| otherwise = go (k + 12) (v `quot` 1000000000000)
fin v n = if v >= n then 1 else 0
Хаскельная магия из исходников Data.Text.
−90
-(BOOL)isGetRest:(CGFloat)page {
NSString *floatToString = [NSString stringWithFormat:@"%.2f",page];
NSArray *sepArray = [floatToString componentsSeparatedByString:@"."];
CGFloat rest = [[sepArray lastObject] floatValue];
if(rest>0.0){
return YES;
}
else{
return NO;
}
}
А вы еще спрашиваете нужно ли программистам знать математику?
−165
CREATE PROCEDURE Out_Message_ECntl
--<@param1, sysname, @p1> <datatype_for_param1, , int> = <default_value_for_param1, , 0>,
--<@param2, sysname, @p2> <datatype_for_param2, , int> = <default_value_for_param2, , 0>
AS BEGIN
--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/* Для Добавления записей в таблицу PPLS2BILLS_SRCO_MESAGE
сначала создадим временную таблицу с номерами документа
и ко-вом рейсов по этой дате */
--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-- Создаем временную таблицу с результатом группировки неотправленных рейсов
SELECT Flag_Data , COUNT(Flag_Data) AS Kol_Reis
INTO Vrem_Tabl_Mesage_Vrem
FROM PPLS2BILLS_SRCO
WHERE Flag_Out_EC = 0 --Не отправленные
GROUP BY Flag_Data
-- Таблица - Стек данные в ней сохраняются до полной обр Рейсов по месяцу
INSERT INTO Steck_Table_Mesage SELECT
Flag_Data = a.Flag_Data,
Kol_Reis = a.Kol_Reis
FROM Vrem_Tabl_Mesage_Vrem a
-- Удаляю Vrem_Tabl_Mesage_Vrem
DROP Table Vrem_Tabl_Mesage_Vrem
-- Добавляю записи в таблицу PPLS2BILLS_SRCO_MESAGE
INSERT INTO PPLS2BILLS_SRCO_MESAGE SELECT
DOCUMENT = Flag_Data,
Nom_Document = dbo.Mesage_Namber(Flag_Data),
Kol_Reis_In_Docum = Kol_Reis,
Cancel_Kol_Reis_Doc = ( SELECT COUNT(*)
FROM PPLS2BILLS_SRCO_DEL a INNER JOIN PPLS2BILLS_SRCO b
ON a.PPLS_ID = b.PPLS_ID
WHERE a.Flag_Out_EC = 0 and b.Flag_Out_EC = 0 ),
Greate_Date_Docum = GetDate(),
Flag_Out_EC = 0
FROM Steck_Table_Mesage WHERE Flag_Data IS NOT NULL
-- Корректирую записи №_Сообщения в PPLS2BILLS_SRCO
UPDATE a SET Flag_Mesage =
(SELECT MAX(Nom_Document) FROM PPLS2BILLS_SRCO_MESAGE a
INNER JOIN PPLS2BILLS_SRCO b
ON a.DOCUMENT = b.Flag_Data )
FROM PPLS2BILLS_SRCO a INNER JOIN PPLS2BILLS_SRCO_MESAGE b
ON a.Flag_Data = b.DOCUMENT
WHERE a.Flag_Out_EC = 0
-- ==================================================================================
-- Курсор выбирает строки из PPLS2BILLS_SRCO_MESAGE, заполняет Vrem_Tabl_NumReis
-- ==================================================================================
-- Создадим временную таблицу
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Vrem_Tabl_NumReis]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Vrem_Tabl_NumReis]
CREATE TABLE [dbo].[Vrem_Tabl_NumReis] (
[ID_PPLS] [int] NULL ,
[Doc] [char] (8) COLLATE Ukrainian_CI_AI_KS_WS NULL ,
[Num] [int] NULL ,
[Reis] [int] IDENTITY (1, 1) NOT NULL
) ON [PRIMARY]
-- Обьявляю курсор
DECLARE Cursor_Num_Reis CURSOR
FOR SELECT DOCUMENT, Nom_Document
FROM PPLS2BILLS_SRCO_MESAGE
-- Обьявляю переменные для приема полей таблицы
DECLARE @count int, @DOCUMENT char(8),
@Nom_Document int
SELECT @count = 1
-- Открываю курсор
OPEN Cursor_Num_Reis
FETCH NEXT FROM Cursor_Num_Reis INTO @DOCUMENT, @Nom_Document -- считываю первую запись
WHILE (@@fetch_status <> -1) -- цикл по записям курсора
BEGIN
-- вставляю в Vrem_Tabl_NumReis (счетчик по выбранным записям)рейсы из PPLS2BILLS_SRCO_MESAGE
insert into Vrem_Tabl_NumReis
select *
from dbo.Fun_Num_Reis_in_Mesage(@DOCUMENT,@Nom_Document)
--корректируем номер рейса в сообщении
UPDATE a
SET Flag_NumReis_Mes = b.Reis
FROM PPLS2BILLS_SRCO a INNER JOIN Vrem_Tabl_NumReis b
ON a.PPLS_ID = b.ID_PPLS
WHERE a.Flag_Out_EC = 0
-- Подготавливаю таблицу для нового документа
truncate table dbo.Vrem_Tabl_NumReis -- при truncate счетчик сбрасывается в 0
FETCH NEXT FROM Cursor_Num_Reis INTO @DOCUMENT, @Nom_Document -- переход на следующую запись
SELECT @count = @count + 1 -- количество записей
END
CLOSE Cursor_Num_Reis -- закрываю курсор
DEALLOCATE Cursor_Num_Reis -- освобождаю курсор
--DROP TABLE Vrem_Tabl_NumReis -- удаляю временно созданную таблицу
END -- Procedure
GO
-- ВНИМАНИЕ! - ДОДЕЛАТЬ ПРИ ОТПРАВКЕ ПО ПОЧТЕ УСТ ФЛАГОВ В ТАБЛИЦАХ "ОТПРАВЛЕНО"
-- И ЗАПОЛНЕНИЕ ТАБЛИЦЫ dbo.PPLS2BILLS_CRCO_Mail_Out
--truncate table PPLS2BILLS_SRCO_MESAGE
--delete dbo.PPLS2BILLS_SRCO
--delete dbo.PPLS2BILLS_SRCO_DEL
--exec dbo.Insert_PPLS2BILLS_SRCO
--EXEC Insert_PPLS2BILLS_SRCO '17 july, 2002'
-- exec Out_Message_ECntl
курсор головного мозга
−98
settings = [int(value, 16) for value in ('09', '0b', '0d', '0f')]
+6
class Log
{
ReverseStruct<std::list<std::string> > _logList;
semafor semafor;
Log()
{
std::list<std::string> right , left;
std::shared_ptr<std::list<std::string> > ptrRight=std::shared_ptr<std::list<std::string> >(*right);
std::shared_ptr<std::list<std::string> > ptrLeft=std::shared_ptr<std::list<std::string> >(*left);
_logList=TReverseStruct<std::list<std::string> >(ptrRight,ptrLeft);
}
void writeMessage(std::string message, Level level ){_logList.getWriteStorage.push_back( currentTime+level+messge); semafor.signal();}
void body()
{
try
{
semafor.wait();
_logList.revers();
for (std::list<std::string>::iterator i =_logList.getReadStorage->begin(); i != _logList.getReadStorage->end(); ++i)
{
fixedBufferString<7000, '\0'> stringLog;
stringLog.append(*i);
FileDevice flashInternal(FLASHINTERNAL);
const DriveErrors::E WriteResult = flashInternal.writeFile("log.iso", (byte*)stringLog.content(), stringLog.length());
}
}
catch()
{}
}
}
+153
<?php
sfConfig::set('show_counters', true);
/**
* Lite
*
* @category Symfony
* @package Plugins
* @subpackage liteSearchsite
* @author
* @since 12.11.2008
* @version $Id: actions.class.php 28664 2011-03-15 13:14:49Z ringtail $
*/
/**
* class liteSearchsiteActions. Функции для работы с поиском
*
* @category Symfony
* @package Plugins
* @subpackage liteSearchsite
* @author Tretyakov Ilya <[email protected]>
* @version $Id: actions.class.php 28664 2011-03-15 13:14:49Z ringtail $
*/
class liteSearchsiteActions extends sfActions
{
protected $searchsite;
protected $search_server = 'http://217.148.52.134:17000/';
/**
* конструктор
*
* @see sfComponent
*/
public function __construct($context, $moduleName, $actionName)
{
$this->searchsite = new liteSearchsite();
parent::__construct($context, $moduleName, $actionName);
}
/**
* Поиск. главная
*
* @param unknown_type $request
*/
public function executeIndex($request)
{
if ($request) {
$page = $request->getParameter('id');
$this->text = htmlspecialchars($request->getParameter('search_text'));
$reqid = $request->getParameter('reqid');
$page = $request->getParameter('p');
$numdoc = $request->getParameter('numdoc');
}
if (!$page) $page = 0;
if (!$this->searchsite->checkServer($this->search_server)) { throw new sfException('Ахтунг!'); }
if (!1) {
$this->search_work = 0;
} else
if ($this->searchsite->uploadXml($this->search_server, $this->text, $reqid, $page, $numdoc)) {
$this->pages_found = $this->searchsite->getCountItem();
$this->start_page = $this->searchsite->getStartPage();
$this->pages_found_word = $this->searchsite->getWordLinks();
$this->reqid = $this->searchsite->getRegId();
$this->pages = $this->searchsite->getPages();
$this->count_results = $this->searchsite->getDifPages();
if ($this->pages) {
$this->nextpagelink = $this->searchsite->getLinkNextPage();
$this->prepagelink = $this->searchsite->getLinkPrePage();
}
$this->search_work = 1;
if (!$this->pages_found) {
$this->no_result = 1;
$this->pages_found = 0;
} else {
$this->no_result = 0;
$this->list = $this->searchsite->getList($page);
//пересчитаем
//$this->pages_found = $this->searchsite->getCountItem();
//$this->searchsite->setCountPages();
//$this->pages_found_word = $this->searchsite->getWordLinks();
//$this->pages = $this->searchsite->getPages();
//$this->count_results = $this->searchsite->getDifPages();
if ($this->pages) {
$this->nextpagelink = $this->searchsite->getLinkNextPage();
$this->prepagelink = $this->searchsite->getLinkPrePage();
}
}
} else {
$this->search_work = 0;
}
}
+15
if( (Input.GetMouseX() >= 545 && Input.GetMouseX() <= 567 && Input.GetMouseY() >= 165 && Input.GetMouseY() <= 197) || (Input.GetMouseX() >= 545 && Input.GetMouseX() <= 567 && Input.GetMouseY() >= 205 && Input.GetMouseY() <= 237) ||
(Input.GetMouseX() >= 545 && Input.GetMouseX() <= 567 && Input.GetMouseY() >= 85 && Input.GetMouseY() <= 117) || (Input.GetMouseX() >= 545 && Input.GetMouseX() <= 567 && Input.GetMouseY() >= 125 && Input.GetMouseY() <= 157) ||
(Input.GetMouseX() >= 675 && Input.GetMouseX() <= 707 && Input.GetMouseY() >= 85 && Input.GetMouseY() <= 117) || (Input.GetMouseX() >= 675 && Input.GetMouseX() <= 707 && Input.GetMouseY() >= 145 && Input.GetMouseY() <= 177) ||
(Input.GetMouseX() >= 675 && Input.GetMouseX() <= 707 && Input.GetMouseY() >= 205 && Input.GetMouseY() <= 237)||
(Input.GetMouseX() >= 780 && Input.GetMouseX() <= 807 && Input.GetMouseY() >= 85 && Input.GetMouseY() <= 117) || (Input.GetMouseX() >= 780 && Input.GetMouseX() <= 807 && Input.GetMouseY() >= 125 && Input.GetMouseY() <= 157) ||
(Input.GetMouseX() >= 780 && Input.GetMouseX() <= 807 && Input.GetMouseY() >= 165 && Input.GetMouseY() <= 197) || (Input.GetMouseX() >= 780 && Input.GetMouseX() <= 807 && Input.GetMouseY() >= 205 && Input.GetMouseY() <= 237) ||
...
{
int i; int e;
if(Input.GetMouseX() >= 55 && Input.GetMouseX() <= 87 && Input.GetMouseY() >= 210 && Input.GetMouseY() <= 242) i = 0;
if(Input.GetMouseX() >= 95 && Input.GetMouseX() <= 127 && Input.GetMouseY() >= 210 && Input.GetMouseY() <= 242) i = 1;
if(Input.GetMouseX() >= 135 && Input.GetMouseX() <= 167 && Input.GetMouseY() >= 210 && Input.GetMouseY() <= 242) i = 2;
if(Input.GetMouseX() >= 175 && Input.GetMouseX() <= 207 && Input.GetMouseY() >= 210 && Input.GetMouseY() <= 242) i = 3;
if(Input.GetMouseX() >= 215 && Input.GetMouseX() <= 247 && Input.GetMouseY() >= 210 && Input.GetMouseY() <= 242) i = 4;
if(Input.GetMouseX() >= 255 && Input.GetMouseX() <= 287 && Input.GetMouseY() >= 210 && Input.GetMouseY() <= 242) i = 5;
if(Input.GetMouseX() >= 295 && Input.GetMouseX() <= 327 && Input.GetMouseY() >= 210 && Input.GetMouseY() <= 242) i = 6;
if(Input.GetMouseX() >= 335 && Input.GetMouseX() <= 367 && Input.GetMouseY() >= 210 && Input.GetMouseY() <= 242) i = 7;
if(Input.GetMouseX() >= 55 && Input.GetMouseX() <= 87 && Input.GetMouseY() >= 250 && Input.GetMouseY() <= 282) i = 8;
if(Input.GetMouseX() >= 95 && Input.GetMouseX() <= 127 && Input.GetMouseY() >= 250 && Input.GetMouseY() <= 282) i = 9;
if(Input.GetMouseX() >= 135 && Input.GetMouseX() <= 167 && Input.GetMouseY() >= 250 && Input.GetMouseY() <= 282) i = 10;
if(Input.GetMouseX() >= 175 && Input.GetMouseX() <= 207 && Input.GetMouseY() >= 250 && Input.GetMouseY() <= 282) i = 11;
if(Input.GetMouseX() >= 215 && Input.GetMouseX() <= 247 && Input.GetMouseY() >= 250 && Input.GetMouseY() <= 282) i = 12;
if(Input.GetMouseX() >= 255 && Input.GetMouseX() <= 287 && Input.GetMouseY() >= 250 && Input.GetMouseY() <= 282) i = 13;
if(Input.GetMouseX() >= 295 && Input.GetMouseX() <= 327 && Input.GetMouseY() >= 250 && Input.GetMouseY() <= 282) i = 14;
if(Input.GetMouseX() >= 335 && Input.GetMouseX() <= 367 && Input.GetMouseY() >= 250 && Input.GetMouseY() <= 282) i = 15;
...
if(Input.GetMouseX() >= 55 && Input.GetMouseX() <= 87 && Input.GetMouseY() >= 410 && Input.GetMouseY() <= 442) i = 40;
if(Input.GetMouseX() >= 95 && Input.GetMouseX() <= 127 && Input.GetMouseY() >= 410 && Input.GetMouseY() <= 442) i = 41;
if(Input.GetMouseX() >= 135 && Input.GetMouseX() <= 167 && Input.GetMouseY() >= 410 && Input.GetMouseY() <= 442) i = 42;
if(Input.GetMouseX() >= 175 && Input.GetMouseX() <= 207 && Input.GetMouseY() >= 410 && Input.GetMouseY() <= 442) i = 43;
if(Input.GetMouseX() >= 215 && Input.GetMouseX() <= 247 && Input.GetMouseY() >= 410 && Input.GetMouseY() <= 442) i = 44;
if(Input.GetMouseX() >= 255 && Input.GetMouseX() <= 287 && Input.GetMouseY() >= 410 && Input.GetMouseY() <= 442) i = 45;
if(Input.GetMouseX() >= 295 && Input.GetMouseX() <= 327 && Input.GetMouseY() >= 410 && Input.GetMouseY() <= 442) i = 46;
if(Input.GetMouseX() >= 335 && Input.GetMouseX() <= 367 && Input.GetMouseY() >= 410 && Input.GetMouseY() <= 442) i = 47;
if(Input.GetMouseX() >= 545 && Input.GetMouseX() <= 567 && Input.GetMouseY() >= 85 && Input.GetMouseY() <= 117) e = 0; // Bracers
if(Input.GetMouseX() >= 545 && Input.GetMouseX() <= 567 && Input.GetMouseY() >= 125 && Input.GetMouseY() <= 157) e = 1; // Hands
if(Input.GetMouseX() >= 545 && Input.GetMouseX() <= 567 && Input.GetMouseY() >= 165 && Input.GetMouseY() <= 197) e = 2; // Sword
if(Input.GetMouseX() >= 545 && Input.GetMouseX() <= 567 && Input.GetMouseY() >= 205 && Input.GetMouseY() <= 237) e = 3; // Off hand
if(Input.GetMouseX() >= 675 && Input.GetMouseX() <= 707 && Input.GetMouseY() >= 85 && Input.GetMouseY() <= 117) e = 4; // Helmet
if(Input.GetMouseX() >= 675 && Input.GetMouseX() <= 707 && Input.GetMouseY() >= 145 && Input.GetMouseY() <= 177) e = 5; // Chest
if(Input.GetMouseX() >= 675 && Input.GetMouseX() <= 707 && Input.GetMouseY() >= 205 && Input.GetMouseY() <= 237) e = 6; // Legs
https://github.com/LaurentGomila/SFML/wiki/Tutorial%3A-Basic-Inventory-System
+128
object Point2D {
type Point2D = Object {def apply(method: Method): method.type#signature}
trait Method {
type signature
}
object ToString extends Method {
override type signature = () => String
}
object GetX extends Method {
override type signature = () => Int
}
object SetX extends Method {
override type signature = (Int) => Point2D
}
def Point2D(x: Int, y: Int): Point2D = {
class Dispatch {
def apply(method: Method): method.signature = (method match {
case ToString => () => s"($x, $y)"
case GetX => () => x
case SetX => (x: Int) => Point2D(x, y)
}).asInstanceOf[method.signature]
}
new Dispatch
}
}
+153
if (/mail\/\?r=mail\/message_list/gim.test(location.href)) {
var ihoho = $($('form')[1]).parent().clone(true);
var myNickName = $($('li.sep_bl:has("a[href*=\'/mysite/\']")').find("a")[0]).prop("title");
eval('var prrtrns = /<b style="color:navy;">' + myNickName + '<\\/b>/gim;');
$($('form')[1]).parent().remove();
$($('.blue_wrap_block')[0]).after(ihoho);
var xls = $($($('form')[1]).find("input[type*='submit']")[0]);
xls.prop('type', 'button');
xls[0].setAttribute('onclick', 'var temp_tT = this.parentNode.parentNode.texttT.value; var rrr = this.parentNode.parentNode.r.value;var sid = this.parentNode.parentNode.sid.value;var CK = this.parentNode.parentNode.CK.value;var texttT = this.parentNode.parentNode.texttT.value;var Link_id = this.parentNode.parentNode.Link_id.value;var user = this.parentNode.parentNode.user.value;$.ajax({type:"POST",url: "http://spaces.ru/mail/?",data: {r:rrr,user:user,CK:CK,sid:sid,Link_id: Link_id,texttT:texttT},success:function(){document.forms[1].texttT.value = "";}});');
xls[0].setAttribute('name', 'okletsgo');
xls[0].setAttribute('style', 'display:none');
$('#navi').before("<script></script>");
document.forms[1].setAttribute('onkeypress', 'function lovly(e) { if (e.keyCode == 87 && e.altKey) document.forms[1].texttT = temp_tT; if (e.keyCode == 13 && !e.shiftKey && !e.ctrlKey) document.forms[1].okletsgo.click(); } lovly(event)');
$('.t-bg3').each(function(i) {
$(this).html($(this).html().replace(/<b style="color:darkmagenta;">Я<\/b>/gim, '<b style="color:navy;"><img src="http://spaces.ru/i//man_on.gif" alt="(ON)"/> <span style="text-decoration:underline">' + myNickName + '</span></b>').replace("<div class=\"overfl_hid service_links_block service_links_block_top clear\">", "<div style='display:none'>"));
}); //replace("<div class=\"left font0 avatar_wrap padd_right\">", '<div style="display:none">').
var reloadedMail = function(data) {
var dt = '';
$($(data).find("form")[1]).parent().each(function() {
dt = this.outerHTML;
});
data = data.replace(dt, "");
$(data).find('.t-bg3').each(function(i) {
if ($(this).html().replace(/Link_id=([0-9]+)/gim) != $($('.main').find('.t-bg3')[i]).html().replace(/Link_id=([0-9]+)/gim))
{
$($('.main').find('.t-bg3')[i]).html($(this).html().replace(/<b style="color:darkmagenta;">Я<\/b>/gim, '<b style="color:navy;"><img src="http://spaces.ru/i//man_on.gif" alt="(ON)"/> <span style="text-decoration:underline">' + myNickName + '</span></b>').replace("<div class=\"overfl_hid service_links_block service_links_block_top clear\">", "<div style='display:none'>"));
if ($(this).html().match(prrtrns) && settings.ajaxMailNotifications) {
$('#navi').before('<audio preload="auto" autoplay src="http://driverjs.webservis.ru/income.ogg"></audio>');
}
}
});
}
var reloadMail = function() {
$.ajax({
url: location.href,
success: reloadedMail
});
setTimeout(reloadMail, settings.ajaxTimeout);
}
reloadMail();
}
Что? Разработчики сайта не сделали отправку/принятие сообщений на AJAX?!
Поправим! Юзерскрипт порешает все.
//P.S. ЭТО КАК-ТО работает. Правда.