- 1
- 2
- 3
- 4
- 5
public function accuire($array = array()) {
return $this->acquire($array);
}
public function acquire($array = array()) {
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+54
public function accuire($array = array()) {
return $this->acquire($array);
}
public function acquire($array = array()) {
Spell-master
+124
buildTree sentence graph =
(M.lookup (0, length sentence - 1, DirLeft) finalGraph, finalGraph)
where finalGraph = execState runEisner (M.fromList elementaryPathes)
elementaryPathes =
map (\(i, word) -> ((i, i, DirLeft), elementaryPath DirLeft word)) indexed ++
map (\(i, word) -> ((i, i, DirRight), elementaryPath DirRight word)) indexed
indexed = zip [0..] sentence
runEisner = do
let len = length sentence
forM_ [1 .. len - 1] $ \l -> do
forM [0 .. len - 1 - l] $ \i -> do
matrix <- get
let j = i + l
let w1 = sentence !! i
let w2 = sentence !! j
let buildConcat dir = (catMaybes $ (zipWith (\p1 p2 -> join $ (liftM2 concatenatePath) p1 p2)
[M.lookup (i, k, dir) matrix | k <- [i + 1 .. j - 1]]
[M.lookup (k, j, dir) matrix | k <- [i + 1 .. j - 1]])) :: [Path]
let buildJoin dir key = fromMaybe [] $ M.lookup key graph >>= \link ->
return (catMaybes (zipWith (\p1 p2 -> join $ (liftM2 (\f c -> joinPath f c link)) p1 p2)
[M.lookup (i, k, dir) matrix | k <- [i .. j - 1]]
[M.lookup (k, j, rev dir) matrix | k <- [i + 1 .. j]]))
let posR = (buildConcat DirRight ++ buildJoin DirRight (w1, w2)) :: [Path]
let newMatrix = if (not . null) posR
then M.insert (i, j, DirRight) (minimumBy compWeight posR) matrix
else matrix
let posL = buildConcat DirLeft ++ buildJoin DirRight (w2, w1)
let newMatrix' = if (not . null) posL
then M.insert (i, j, DirLeft) (minimumBy compWeight posL) matrix
else newMatrix
put newMatrix'
Кусок из диплома по NLP. Yuuri неделю как познал монаду State и сделал двумерный императивный цыкл.
−115
#!/usr/bin/perl -w
use strict;
my $enchant_num=1;
my $tries_num=0;
print "Please, enter safe enchant lvl:\n";
my $safe_enchant_num=<STDIN>; chomp $safe_enchant_num;
print "Please enter maximum enchant lvl:\n";
my $max_enchant_num=<STDIN>; chomp $max_enchant_num;
if($max_enchant_num=~/\d/)
{
if($max_enchant_num>$safe_enchant_num)
{
while($enchant_num<=$max_enchant_num)
{
if($enchant_num<=$safe_enchant_num)
{
while($enchant_num<=$safe_enchant_num)
{
print "Succesfully enchanted for +" . $enchant_num++ . "\r";
}
}
else
{
if(rand(100)<=66)
{
print "Succesfully enchanted for +" . $enchant_num++ . "\r";
}
else
{
print "Enchant failed for +" . $enchant_num++ . "\r";
$enchant_num=1;
$tries_num++;
}
}
}
}
}
else
{
print "\nInput is incorrect\n";
}
print "\nEnchanted for $max_enchant_num with: $tries_num fails.";
Комментарии излишни
+39
<?php
set_time_limit(86400);
$begin = new DateTime($_GET["min_date"]);
$end = new DateTime($_GET["max_date"]);
$begincp = clone $begin;
$begincp_2 = clone $begin;
$dt_diff = $begin->diff($end);
$dt_diff = (int) $dt_diff->format("%a");
for($i = 1; $i <= $dt_diff; $i++)
{
$begincp_2->modify("+1 day");
$q = mysql_query("SELECT * FROM `skud_stat` WHERE
`arrival` >= '".$begincp->getTimestamp()."' AND
`arrival` < '".$begincp_2->getTimestamp()."'
ORDER BY `name`");
while($data = mysql_fetch_array($q))
{
$workers[$data["name"]][] = $data;
}
/* Сортировку */
//uksort($workers, "strnatcasecmp");
//ksort($workers);
$coun = 0;
$begincp->modify("+1 day");
}
/* быстрая сортировка */
uksort($workers, "strnatcasecmp");
?>
<table class="table table-striped table-hover table-condensed skud-chart">
<thead></thead>
<tr>
<th style="text-align: left">Имя</th>
<?php
$begin = new DateTime($_GET["min_date"]);
$end = new DateTime($_GET["max_date"]);
$bgcp = clone $begin;
$dt_diff = $begin->diff($end);
$dt_diff = (int) $dt_diff->format("%a");
for($i = 1; $i <= $dt_diff; $i++)
{
?>
<th><?=date("d.m.Y", $bgcp->getTimestamp());?></th>
<?php
$bgcp->modify("+1 day");
}
?>
</tr>
<?php
foreach($workers as $worker => $arr)
{
$begin_copy = clone $begin;
$begin_copy2 = clone $begin;
?>
<tr>
<td class="b"><?=$worker?></td>
<?php
for($i = 1; $i <= $dt_diff; $i++)
{
$begin_copy2->modify("+1 day");
foreach($arr as $day)
{
if($day["arrival"] > $begin_copy->getTimestamp() && $day["leaving"] < $begin_copy2->getTimestamp())
{
/* 28800 - рабочее время (8 часов)
27000 - как погрешность (7 часов 30 минут)
*/
?>
<td><?=date("H:i", $day["arrival"]);?> / <?=date("H:i", $day["leaving"]);?> / <?php if($day["worktime"] < 27000) { ?><b class="notenough"><?php } ?><?=date("H:i", $day["worktime"]);?><?php if($day["worktime"] < 21600) { ?></b><?php } ?></td>
<?php
$success_day = true;
}
else
{
?>
<!--<td>-</td>-->
<?php
}
}
if(!$success_day)
{
?>
<td class="naw">-</td>
<?php
}
unset($success_day);
//if($begin_copy->getTimestamp())
Корпоративная Статистика (!). Читаю из базы и строю отчёт.
+40
<?php
if($_POST["phones_csv_load"]) {
if(is_uploaded_file($_FILES["phones_csv"]["tmp_name"])) {
if (($handle = fopen($_FILES["phones_csv"]["tmp_name"], "r")) !== FALSE) {
$linecount = (exec('perl -pe \'s/\r\n|\n|\r/\n/g\' ' . escapeshellarg($_FILES["phones_csv"]["tmp_name"]) . ' | wc -l')) - 1;
for($i = 0; $i <= $linecount; $i++) {
$data = str_getcsv(iconv("cp1251", "utf8", stream_get_line($handle, 8000, "\n")), "\t");
$datetime = explode(" ", $data[28]);
$datetime["date"] = explode(".", $datetime[0]);
$datetime["time"] = explode(":", $datetime[1]);
$datetime["unix_time"] = mktime($datetime["time"][0], $datetime["time"][1], 0, $datetime["date"][1], $datetime["date"][0], "20".$datetime["date"][2]);
$datetime["unix_time_ar"] = mktime($datetime["time"][0], $datetime["time"][1], 0, 0, 0, 0);
$datetime["unix_day"] = mktime(0, 0, 0, $datetime["date"][1], $datetime["date"][0], "20".$datetime["date"][2]);
sort($fullmassive[$datetime["unix_day"]][$data[20]][] = array($data[17]." ".$data[18], $datetime["unix_time"], $data[20], $datetime["unix_day"], $datetime["unix_time_ar"], "inout" => checkInOut($data[3]), md5($data[20]." ".$data[18].$datetime["unix_time"].$datetime["unix_time"]), date("d.m.Y H:i", $datetime["unix_time"]), date("H:i", $datetime["unix_time_ar"])), SORT_NATURAL);
}
foreach($fullmassive as $fullmassive_day) {
foreach($fullmassive_day as $fullmassive_employee) {
usort($fullmassive_employee, 'invenDescSort');
$employee["uid"] = $fullmassive_employee[0][2];
$employee["in"] = $fullmassive_employee[0][1];
$employee["in_date"] = $fullmassive_employee[0][3];
$employee["in_time"] = $fullmassive_employee[0][4];
$employee["out"] = end($fullmassive_employee)[1];
$employee["out_date"] = mktime(0, 0, 0, date("n", end($fullmassive_employee)[1]), date("j", end($fullmassive_employee)[1]), date("Y", end($fullmassive_employee)[1]));
$employee["out_time"] = mktime(date("H", end($fullmassive_employee)[1]), date("i", end($fullmassive_employee)[1]), 0, 0, 0, 0);
$employee["name"] = $fullmassive_employee[0][0];
if($employee["in"] >= end($fullmassive_employee)[1]) $employee["in"] = mktime(10, 0, 0, date("n", $employee["in"]), date("j", $employee["in"]), date("Y", $employee["in"]));
else if(end($fullmassive_employee)[1] <= $employee["in"]) $employee["out"] = mktime(18, 0, 0, date("n", $employee["in"]), date("j", $employee["in"]), date("Y", $employee["in"]));
else
{
if(mktime(date("H", $employee["in"]), 0, 0, 0, 0, 0) < mktime(12, 0, 0, 0, 0, 0)) {
$employee["out"] = mktime(18, 0, 0, date("n", $employee["in"]), date("j", $employee["in"]), date("Y", $employee["in"]));
}
else {
$employee["in"] = mktime(10, 0, 0, date("n", $employee["in"]), date("j", $employee["in"]), date("Y", $employee["in"]));
}
}
if($employee["in_time"] >= end($fullmassive_employee)[4]) $employee["in_time"] = mktime(10, 0, 0, date("n", $employee["in_time"]), date("j", $employee["in_time"]), date("Y", $employee["in_time"]));
else if(end($fullmassive_employee)[4] <= $employee["in_time"]) $employee["out_time"] = mktime(18, 0, 0, date("n", $employee["in_time"]), date("j", $employee["in_time"]), date("Y", $employee["in_time"]));
$employee["worktime"] = $employee["out"] - $employee["in"];
mysql_query("INSERT INTO `skud_stat` SET `name` = '".$employee["name"]."',
`uid` = '".$employee["uid"]."',
`arrival` = '".$employee["in"]."',
`arrival_date` = '".$employee["in_date"]."',
`arrival_time` = '".$employee["in_time"]."',
`leaving` = '".$employee["out"]."',
`leaving_date` = '".$employee["out_date"]."',
`leaving_time` = '".$employee["out_time"]."',
`worktime` = '".($employee["worktime"])."'");
}
}
fclose($handle);
}
}
}
?>
Корпоративная Статистика (!). Читаю из CSV
+98
Сижу такой набираю код
program Project6;
{$APPTYPE CONSOLE}
var i,j: integer;
begin
repeat
readln(j);
i := 0;
if (j=0) then
i := 1
else
break;
Writeln(i);
until false;
end.
[Hint] : Value assigned to 'i' never used
Ну ладно, похер, уберу
program Project6;
{$APPTYPE CONSOLE}
var i,j: integer;
begin
repeat
readln(j);
// i := 0;
if (j=0) then
i := 1
else
break;
Writeln(i);
until false;
end.
[Warning] : Variable 'i' might not have been initialized
_________________
g@@@@@44444*********9444@@@@@@@@@@@Mggg__
g@M" _an**"""""""**Vw=G______"%%@@@@@gg_
,@@` a^" __a=~v-vvv~~,___ _____`"*@gg_
a@@ _M" _m*"` _______ `""""""""""` " "9@g_
@@ a" ,m"_ar*"'` -, ,amv****-~, 9@g
@@ .* u" C ,~ "\ @
d@ ' __gg____ ` @y
g@ ,g@@@@@@@@4@@gg_ C ______ 9@g
g@@.>~. __ a@""@@@@@@__ "9@g ,g@@@@**4@@_ "@g_
g@"$-*""" *Y, @@@@*""**4@@@g__$@C ggg@@@@@@@@@@*" "'" ""Mg`8@g
g@",` ,g@@@@@@@g_ _g@ ""@M" `"@@" *n_"C"@@
g@' p@" ,`"@@@ggggg@@" 8] ,_ _gM@@@@g ' 'C8@
@@ j@ 8@_ `"""' 8@g_ 3@g@@@`, `" ][@
@L 8@ _g@@@@@gg_ _gMMy "9@g_ `""' 8L j8@
@k 3@ d@@@@ "@@@gg_ *""""" @"``___ '@@g_ @@C n" Q@
"@C $ 9k @@_ "8@@@@gg_ @g_fM4@@M g@""" "n. a@@@ _m*3@"
"@g N, 9@@gg_ 8@ `""9@@@gg__" 8gg@M _g@@@d@k a@%
"@@g_' "@@@@@@@@g_ `"8@@@@ggg____ ""` ___gg@@@@ 8@@@ @@
"@g_ '@g `"@@@@gg__ @L `"""4@@@@@@@@@@@@@@@@" @C @@@ 3@
9@_ `@g 3@"9@@@@@@g@ [@ @@ 4@y @kg@@@ [@
9@ 8@gd@ '"9@@@@@@@gggggd@gggggd@gggggg@W@@@@@@@@ [@
8g "@@g @""9@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@F [@
@g "@@g_ d@ '""@@@@@@@@@@@@@@@@@@@@@@@$@ 3@
`@g_ "@@@g_j@' @C ``"3@@"""8@""j@'j@g@@ 3@
9@g_ ~__ ~._ `"@@@@g_ @C 8@ g@^ p@^ "@@M @C
"@@g "9m_ "Nq_ "*@@@@ggggg@______@____@@gg@@@@@M" @L
"9@@g_`"Mm_`"Nq_ """"*4@@@@@@@@@@M@@4*"""' 8k
"9@@g_ ""Mm_"*w__ ~~~~ aaa~~ _/ $@
`"@@gg_ "*WG_"*w~.____ ___am*" / [@
"*@@gg `"*-~<.__ ` __M" 3@
"9@gg_ `""'** ------**""` d@
`"@@ggggg__ ,d@
""9@@@@@gg__ __g@"
`""*4@@@@MggggggggM@@@@"
`""""""""""'
+95
if length(fsizeS)<=9 then fsize:=strtoint(fsizeS);
if (length(fsizeS)>9) and (length(fsizeS)<18) then
fsize:=strtoint(copy(fsizeS,length(fsizeS)-8,length(fsizeS)-9))+
strtoint(copy(fsizeS,1,length(fsizeS)-9))*1000000000{10**9};
if length(fsizeS)>18 then
begin
writeln;
writeln('File:'+curstr);
writeln('Size:'+fsizeS);
write('Please input file''s size, written above:');
readln(fsize);
end;
Интересный способ конвертации строки в число. Думаю, у вас здесь такого ещё не было. Нашел в своих исходниках времён 8 - 9 класса.
+137
private void SetRowColor()
{
DataGridView dg = new DataGridView();
dg.Sorted += new EventHandler(DataGridView1_Sorted);
foreach (DataGridViewColumn col in DataGridView1.Columns)
{
if (col is DataGridViewTextBoxColumn)
{
if (col.HeaderText == "Status")
{
foreach (DataGridViewRow dgRow in DataGridView1.Rows)
{
if (dgRow.Cells[col.Index].Value.ToString() == "0" || dgRow.Cells[col.Index].Value.ToString() == "Inactive")
{
DataGridViewCellStyle dStyle = new DataGridViewCellStyle();
dStyle.BackColor = Color.Goldenrod;
dStyle.Padding = new System.Windows.Forms.Padding(3, 0, 0, 0);
dgRow.DefaultCellStyle = dStyle;
}
}
}
if (col.HeaderText == "StatusID")
{
foreach (DataGridViewRow dgRow in DataGridView1.Rows)
{
if (dgRow.Cells[col.Index].Value.ToString() == "0" || dgRow.Cells[col.Index].Value.ToString() == "Inactive")
{
DataGridViewCellStyle dStyle = new DataGridViewCellStyle();
dStyle.BackColor = Color.Goldenrod;
dStyle.Padding = new System.Windows.Forms.Padding(3, 0, 0, 0);
dgRow.DefaultCellStyle = dStyle;
}
}
}
}
//if (DataGridView1.Columns[i].ValueType == typeof(System.DateTime) && DataGridView1.Columns[i].Name != "CreateTS" && DataGridView1.Columns[i].Name != "ModifyTS" && DataGridView1.Columns[i].Name != "InactiveTS" && DataGridView1.Columns[i].Name != "PrintedTS")
//{
// DataGridView1.Columns[i].DefaultCellStyle.Format = m_strDateFormat;
// DataGridView1.Columns[i].Width = m_strDateFormat == "dd MMM yyyy hh:mm:ss tt" ? 150 : DataGridView1.Columns[i].Width;
//}
//DataGridView1.Columns[i].DefaultCellStyle.
}
}
Новая работа. WinForms.
90% примерно такое.
+133
#if __BYTE_ORDER == __BIG_ENDIAN
struct DWstruct { Wtype high, low;};
#elif __BYTE_ORDER == __LITTLE_ENDIAN
struct DWstruct { Wtype low, high;};
#else
#error Unhandled endianity
#endif
glibc, sysdeps/wordsize-32/divdi3.c
+21
#define SWITCH(str) switch(str_hash_for_switch(str))
#define CASE(str) static_assert(str_is_correct(str) && (str_len(str) <= MAX_LEN),\
"CASE string contains wrong characters, or its length is greater than 9");\
case str_hash(str, str_len(str))
#define DEFAULT default
typedef unsigned char uchar;
typedef unsigned long long ullong;
const uchar MAX_LEN = 9;
const ullong N_HASH = static_cast<ullong>(-1);
constexpr ullong raise_128_to(const uchar power)
{
return 1ULL << 7 * power;
}
constexpr bool str_is_correct(const char* const str)
{
return (static_cast<signed char>(*str) > 0) ? str_is_correct(str + 1) : (*str ? false : true);
}
constexpr uchar str_len(const char* const str)
{
return *str ? (1 + str_len(str + 1)) : 0;
}
constexpr ullong str_hash(const char* const str, const uchar current_len)
{
return *str ? (raise_128_to(current_len - 1) * static_cast<uchar>(*str) + str_hash(str + 1, current_len - 1)) : 0;
}
inline ullong str_hash_for_switch(const char* const str)
{
return (str_is_correct(str) && (str_len(str) <= MAX_LEN)) ? str_hash(str, str_len(str)) : N_HASH;
}
inline ullong str_hash_for_switch(const std::string& str)
{
return (str_is_correct(str.c_str()) && (str.length() <= MAX_LEN)) ? str_hash(str.c_str(), str.length()) : N_HASH;
}
Запостил из-за ошибки на некоторых платформах и компиляторах.