- 1
- 2
config.x = Integer.parseInt(json.get("x").toString());
config.y = Integer.parseInt(json.get("y").toString());
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+71
config.x = Integer.parseInt(json.get("x").toString());
config.y = Integer.parseInt(json.get("y").toString());
Преобразование long в int.
+133
open System
let inline un激辛カレー<'a> (f:obj) (tuple:obj) =
match tuple with
| :? ('a * 'a * 'a) as tuple ->
let a , b , c = tuple
match f with
| :? ('a -> 'a -> 'a -> 'a) as f -> f a b c
| _ -> failwith "type did not matched! 3"
| :? ('a * 'a) as tuple ->
let a,b = tuple
match f with
| :? ('a -> 'a -> 'a) as f -> f a b
| _ -> failwith "type did not matched! 2"
| :? 'a as tuple ->
let a = tuple
match f with
| :? ('a -> 'a) as f -> f a
| _ -> failwith "type did not matched! 1"
| _ -> failwith "type did not matched! tuple"
printfn"%A"<| un激辛カレー<float> (fun x->x + 1.) 2.
printfn"%A"<| un激辛カレー<int> (+) (10,10)
printfn"%A"<| un激辛カレー<string> (fun (x:string) y z->x + y + z) ("How ","are ","you?")
+132
if(fileCounter < 1000){
subDir = "SUBDIREC.001";
//много кода
}else if (fileCounter < 2000 && fileCounter > 999){
subDir = "SUBDIREC.002";
//много кода, плюс еще 17 таких же веток
}else if (fileCounter < 20000 && fileCounter > 18999){
subDir = "SUBDIREC.020";
//много кода
}
+136
SqlConnection con = new SqlConnection(connectionString);
string sql = "SELECT idea.Id, idea.Small_text, idea.Full_text, idea.Example_text, ";
sql = sql + " ul.FullName as Avtor, ref.Name as Status, even.date_act, (select count (*) from events ev where ev.id_action=2 and ev.id_target=idea.Id and ev.type_target=1) as CountComm, (select count (*) from events ev where ev.id_action=57 and ev.id_target=idea.Id and ev.type_target=1) as Voit, (select max(ev.date_act) from events ev where ev.id_action in (1,2,4,5,7,8,9,10,58,60,61,62,63,64,65,66,67,68,69,70,71,72,74) and ev.id_target=idea.Id and ev.type_target=1) as Last_action";
sql = sql + " FROM Idea idea, UserLists ul, Refbook ref, Events even ";
sql = sql + " WHERE idea.Avtor=ul.Id and idea.Status_id = ref.Id and even.id_action=1 and even.type_target=1 and even.id_target=idea.id ";
if (id >= 0)
sql = sql + " and idea.Status_id=" + id;
if (id_avtor >= 0)
sql = sql + " and idea.Avtor=" + id_avtor;
sql = sql + " ORDER BY Last_action desc";
SqlCommand cmd = new SqlCommand(sql, con);
cmd.CommandType = CommandType.Text;
List<Idea> Ideas = new List<Idea>();
using (con)
{
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Idea idea = GetIdeaInfo(Int32.Parse(reader["Id"].ToString()));
Ideas.Add(idea);
}
reader.Close();
return Ideas;
}
Принял еще один проект. ASP.NET MVC4. Автор уехал в Новую Зеландию.
+153
function getCallback( variable ){
return function () {
if (!private["loginManager"].isLogin() )
return ( private["loginManager"].callbackReauth() && false) || null ;
return private[variable];
}
};
когда лень ставить лишние фигурные скобки ( все внимание на средний return )
+91
while usedthrds<>cn do
begin
i:=i+1;
if manual=0 then
if i>ccpun then
break;
if manual=1 then
begin
gotoxy(1,stroka);read(cputime[i]);
end
else
begin
gotoxy(1,stroka);write(cputime[i]);
end;
realsumcpu:=cputime[i]+ost;
sumcpu:=cputime[i]+ost;
found:=0;
bin:=0;
min:=1;max:=cn;
search:
while (min<=max) and (found=0) do
begin
bin:=bin+1;
mid:=(min+max)div 2;
if sumcpu<sortedthrd[mid] then
max:=mid-1
else
if sumcpu>sortedthrd[mid] then
min:=mid+1
else
if used[mid]=1 then
begin
if mid<>cn then
begin
l:=1;
while sortedthrd[mid+l]=sortedthrd[mid] do
begin
if used[mid+l]<>1 then
begin
mdldmas:=sortedthrd[mid+l];
mdldnum:=sortednum[mid+l];
ost:=realsumcpu-mdldmas;
used[mid+l]:=1;
found:=1;break;
end;
l:=l+1;
if mid+l>cn then break;
end;
end;
if (mid<>1) and (found=0) then
begin
l:=1;
while sortedthrd[mid-l]=sortedthrd[mid] do
begin
if used[mid-l]<>1 then
begin
mdldmas:=sortedthrd[mid-l];
mdldnum:=sortednum[mid-l];
ost:=realsumcpu-mdldmas;
used[mid-l]:=1;
found:=1;break;
end;
l:=l+1;
if mid-l<1 then break;
end;
end;
break;
end
else
begin
mdldmas:=sortedthrd[mid];
mdldnum:=sortednum[mid];
used[mid]:=1;
ost:=realsumcpu-mdldmas;
found:=1;
break;
end;
end;
if (found=0) and (sumcpu>0) then
begin
sumcpu:=sumcpu-1;bin:=0;min:=1;max:=cn;
goto search;
end;
if found=0 then
ost:=realsumcpu
else
begin
gotoxy(6,stroka);write (realsumcpu);gotoxy (12,stroka);write (mdldmas);gotoxy(18,stroka);write(mdldnum);gotoxy(24,stroka);write(ost);gotoxy(30,stroka);write(bin);
stroka:=stroka+1;
end;
if found=1 then
begin
realsumcpu:=ost;
sumcpu:=ost;
found:=0;bin:=0;min:=1;max:=cn;
goto search;
end;
Как студенты пишут сортировку (полная версия https://gist.github.com/Karasiq/11184652)
+155
/**
* Handles Registration Links.
*
* @package s2Member\Registrations
* @since 3.5
*
* @attaches-to ``add_action("init");``
*
* @return null Or exits script execution after redirection.
*/
public static function register ()
{
do_action ("ws_plugin__s2member_before_register", get_defined_vars ());
if (!empty ($_GET["s2member_register"])) // If they're attempting to access the registration system.
{
while (@ob_end_clean ()); // Clean any existing output buffers.
$msg_503 = _x ('<strong>Your Link Expired:</strong><br />Please contact Support if you need assistance.', "s2member-front", "s2member");
if (is_array ($register = preg_split ("/\:\.\:\|\:\.\:/", c_ws_plugin__s2member_utils_encryption::decrypt (trim (stripslashes ((string)$_GET["s2member_register"]))))))
{
if (count ($register) === 6 && $register[0] === "subscr_gateway_subscr_id_custom_item_number_time" /* Does the checksum value match up here? */)
{
if (is_numeric ($register[5]) && $register[5] <= strtotime ("now") && $register[5] >= strtotime ("-" . apply_filters ("ws_plugin__s2member_register_link_exp_time", "2 days", get_defined_vars ())))
{
$_COOKIE["s2member_subscr_gateway"] = /* For ``reg_cookies_ok ()``. */ c_ws_plugin__s2member_utils_encryption::encrypt ($register[1]);
$_COOKIE["s2member_subscr_id"] = /* For ``reg_cookies_ok ()``. */ c_ws_plugin__s2member_utils_encryption::encrypt ($register[2]);
$_COOKIE["s2member_custom"] = /* For ``reg_cookies_ok ()``. */ c_ws_plugin__s2member_utils_encryption::encrypt ($register[3]);
$_COOKIE["s2member_item_number"] = /* For ``reg_cookies_ok ()``. */ c_ws_plugin__s2member_utils_encryption::encrypt ($register[4]);
if (($reg_cookies = c_ws_plugin__s2member_register_access::reg_cookies_ok ()) && extract ($reg_cookies) /* Needed? */)
{
status_header(200); // Send a 200 OK status header.
header("Content-Type: text/html; charset=UTF-8"); // Content-Type with UTF-8.
setcookie ("s2member_subscr_gateway", $_COOKIE["s2member_subscr_gateway"], time () + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie ("s2member_subscr_gateway", $_COOKIE["s2member_subscr_gateway"], time () + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
setcookie ("s2member_subscr_id", $_COOKIE["s2member_subscr_id"], time () + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie ("s2member_subscr_id", $_COOKIE["s2member_subscr_id"], time () + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
setcookie ("s2member_custom", $_COOKIE["s2member_custom"], time () + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie ("s2member_custom", $_COOKIE["s2member_custom"], time () + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
setcookie ("s2member_item_number", $_COOKIE["s2member_item_number"], time () + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie ("s2member_item_number", $_COOKIE["s2member_item_number"], time () + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
do_action ("ws_plugin__s2member_during_register", get_defined_vars ());
if (is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && is_main_site () && ($location = c_ws_plugin__s2member_utils_urls::wp_signup_url ()))
{
echo '<script type="text/javascript">' . "\n";
echo "window.location = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq ($location) . "';";
echo '</script>' . "\n";
}
else if (($location = c_ws_plugin__s2member_utils_urls::wp_register_url ()))
{
echo '<script type="text/javascript">' . "\n";
echo "window.location = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq ($location) . "';";
echo '</script>' . "\n";
}
exit (); // Clean exit. The browser will now be redirected to ``$location``.
}
else
status_header(503) . header ("Content-Type: text/html; charset=UTF-8") . exit ($msg_503);
}
else
status_header(503) . header ("Content-Type: text/html; charset=UTF-8") . exit ($msg_503);
}
else
status_header(503) . header ("Content-Type: text/html; charset=UTF-8") . exit ($msg_503);
}
else
status_header(503) . header ("Content-Type: text/html; charset=UTF-8") . exit ($msg_503);
}
do_action ("ws_plugin__s2member_after_register", get_defined_vars ());
}
Концовка особенно захватывающа.
Плагин для Wordpress - s2member, https://www.s2member.com/codex/stable/source/s2member/includes/classes/register-in.inc.php
+61
std::cout << std::cout << "Hello, world";
С гейдевчика, странно, что здесь не было.
+152
// Will we have a result object instantiated? If not - we'll simply return TRUE
if ($return_object !== TRUE) {
if ($this->cache_on === TRUE && $this->cache_autodel === TRUE && $this->_cache_init()) {
$this->CACHE->delete();
}
return TRUE;
}
// Return TRUE if we don't need to create a result object
if ($return_object !== TRUE) {
return TRUE;
}
Codeigniter / классика
https://github.com/EllisLab/CodeIgniter/blob/develop/system/database/DB_driver.php#L668
+157
/**
* Определение типа документа - Комплектация/Разукомплектация
* @param $reverse
* @return string
*/
protected function get_reverse($reverse)
{
if(in_array($reverse, ['TRUE', 'true', true, 1, '1'], true)) {
return 'TRUE';
}
if(in_array($reverse, ['FALSE', 'false', false, 0, '0', ''], true)) {
return 'FALSE';
}
}
Продолжение вот этого http://govnokod.ru/15643 кода придется делать