-
+145
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
public String readMessage(String subject) throws Exception {
String messageString = null;
try {
for (final Message message : Arrays.asList(this.inbox.getMessages())) {
if (subject.equals(message.getSubject())) {
messageString = "To: " + Arrays.asList(message.getAllRecipients()) + "n" + "From: " + Arrays.asList(message.getFrom()) + "n" + "Sent: "
+ message.getSentDate() + "n" + "Subject: " + message.getSubject() + "n" + "Text: " + message.getContent();
break;
}
}
} catch (final MessagingException me) {
throw new Exception("Error reading Inbox", me);
} catch (final IOException e) {/* Not using streams, only plain text */
}
return messageString;
}
тестовый javamail клиент(отправка тест-письма,поиск его и удаление). В методе ищем письмо с нужной темой, возвращаем текстовое представление.
говно, кроме очевидных ляпов, в том, что мы лазием по всем сообщениям, сверяя тему, а получение письма занимает около секунды. Надо ли говорить, что в современном ящике писем тысячи...
для сравнения:
если заменить в 4 строчке конструкцию
Arrays.asList(this.inbox.getMessages())
на new SubjectTerm(subject)
, то время выполнения сокращается с (неизвестно,точно более времени чаепития) до пары секунд = )
Lure Of Chaos,
14 Января 2011
-
+159
- 1
- 2
- 3
- 4
- 5
- 6
function DateFromDBToHr($date)
{
$datetime = explode(" ", $date);
$dates = explode("-", $datetime[0]);
return (intval($dates[0])) ? date("d-M-Y", mktime(0, 0, 0, $dates[1], $dates[2], $dates[0])) : false;
}
про то, что форматировать дату можно в запросе или про существование strtotime автор даже не догадывается
elw00d,
14 Января 2011
-
+158
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
(function(){ if(!window.adToken) { window.adToken = Math.floor(Math.random() * 999999999999999999); }
var d = new Date();
var url = (location.protocol=='https:'?'https://base.kiwi.kz/?':'http://base.kiwi.kz/?');
url += 'rnd=' + Math.floor(Math.random() * 99999999999);
url += '&slot_id=25';
url += '&type=js';
url += '&t=' + parseInt(((d.getTime() - (d.getTimezoneOffset() * 60)) / 1000));
url += '&token=' + window.adToken;
url += '&r=' + window.location;
var js = '<sc' + 'ript src="' + url + '"></sc' + 'ript>';
document.write(js);
}());
sc' + 'ript ?
govnozmey,
14 Января 2011
-
+120
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
public static string GetRedirectUrl(string userName, bool createPersistentCookie)
{
if (userName == null)
{
return null;
}
return GetReturnUrl(true);
}
из рефлектора, класс FormsAuthentication
ахеренная роль у параметров userName и createPersistentCookie
Semargl,
13 Января 2011
-
+168
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
class TalentsWindow : public PopupWindow {
render::Sprite* m_background_sprite, *m_header_sprite, *m_fucking_sprite;
...
...
};
...
TalentsWindow::TalentsWindow()
{
...
m_fucking_sprite = m_sprites.addSprite(render::SpriteRect(NOINITIALIZE)
.setTop(591.0f)
.setLeft(500.0f)
.setWidth(411.0f)
.setHeight(140.0f),
m_tex,
0.85f
);
m_fucking_sprite->setPosition(math::float2(818.0f, 50.0f));
m_fucking_sprite->idiot = true;
...
}
Самодокументирующий код.
Kirinyale,
13 Января 2011
-
+134
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
private static void GetUserData(User user)
{
if (user == null)
return;
var firm = user.Firm;
if (firm == null)
return;
}
Бессмысленно и беспощадно.
Gizz,
13 Января 2011
-
−137
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
<?php
if($argc<2) exit(0);
print_r($tmp);
for($i=1;$i<=$argc;$i++)readdir_rec($argv[$i]);
function readdir_rec($path){
$dir = opendir($path);
global $size;
while($d = readdir($dir)){
if ($d == '.' || $d == '..') continue;
if (is_file($path.'/'.$d)){
echo $path."/".$d."\n";
}
else if (is_dir($path.'/'.$d)) readdir_rec($path.'/'.$d);
}
}
?>
#!/bin/bash
c=0;
declare -a fls;
for fl in `php /home/markus/bin/ps2.php $*`
do
let c++;
fls[$c]=$fl;
done
for((i=0;i<=${#fls[@]}-1;i++))
{
for((i2=$i+1;i2<=${#fls[@]};i2++))
{
echo "${fls[$i]} ${fls[$i2]}";
diff -acBi --brief ${fls[$i]} ${fls[$i2]}
}
}
Находит одинаковые файлы по содержанию
AliceGoth,
13 Января 2011
-
−126
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
#!/bin/bash
c=0;
declare -a fls;
cat $*| while read line
do
# echo "line $line №$c"
fls[$c]=$line;
let c++;
for((i=0;i<=${#fls[@]}-1;i++))
{
for((i2=$i+1;i2<=${#fls[@]};i2++))
{
# echo "${fls[$i]} ${fls[$i2]}";
if [ ${fls[$i]} = "${fls[$i2]}" ];then
echo "Zeile $i ist gleich Zeile $i2";
#else
# echo "Строка $i не равна строке $i2";
fi
}
}
done
Находит одинаковые строки в файле
AliceGoth,
13 Января 2011
-
+195
- 1
for($j=0;$j<23000000;$j++); //пауза ~3 сек
Ну как вам? :)
Yanovsky,
13 Января 2011
-
+154
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
<?php
require_once('MultiAutoload.php');
class Dispatcher {
private $handle;
function __construct($event_handle) {
$this->handle = $event_handle;
}
function handleEvent() {
$name = 'Handler_'.$this->handle;
if (class_exists($name)) {
$handler_obj = new $name($this->handle);
$response = $handler_obj->secureHandler();
return $response;
}
else {
throw new Exception('Event handling is impossible!');
}
}
}
?>
Немного экзотики: PHP в стиле Win32! Говно за собой не сразу увидел,
но когда "пришло озарение" было смешно.
dwinner,
13 Января 2011