- 1
- 2
instance Show (a -> b)
main = print (*)
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−95
instance Show (a -> b)
main = print (*)
http://liveworkspace.org/code/17QAgf$23
stderr:
Stack space overflow: current size 8388608 bytes.
Use `+RTS -Ksize -RTS' to increase it.
Возможно это из-за того, что нет реализации show и я написать вменяемую не смогу. Как заставить Haskell сгенерировать для меня show?
Хочется типа такого:
{-# LANGUAGE OverlappingInstances, FlexibleInstances, UndecidableInstances, StandaloneDeriving, DeriveFunctor #-}
deriving instance Show (a -> b)
main = print (*)+152
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=windows-1251'>
<head>
<title>test</title>
<script type="text/javascript">
// Функция, осуществляющая AJAX запрос
function loadXMLDoc(method, url) {
if(window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = processReqChange;
req.open(method, url, true);
req.send(null);
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
req.onreadystatechange = processReqChange;
req.open(method, url, true);
req.send();
}
}
// Функция, выполняемая при изменении статуса
// запроса, если статус равен 200, данные получены
function processReqChange() {
if(req.readyState == 4) {
if(req.status == 200) {
getNumber(req.responseText);
} else {
alert("There was a problem retrieving the XML data:\n" + req.statusText);
}
}
}
// Функция выполняется при клике по кнопке
function process() {
var v = document.getElementById("flag");
var url = "ajax.php?flag=" + v.checked;
loadXMLDoc( "get", url );
setTimeout('process()', 1000);
}
// Функция записывает в элемент content значение, полученное от сервера
function getNumber(text) {
//для текстового поля
var content = document.getElementById( "content" );
content.value = text;
//для div
var content = document.getElementById( "content2" );
content.innerHTML = text;
}
</script>
</head>
<body onload='process()'>
<input type='checkbox' id='flag'>Флажок
<input type='text' id='content'>
<div id='content2'></div>
</body>
</html>
.....................................................................................
//файл ajax.php
<?php
if (isset($_GET['flag']))
{
if($_GET['flag']==='true') echo 'checked';
else echo 'not checked';
}
?>
Как скопировать значение одного поля в другое.
Очередное оригинальное решение от нашего старого знакомого, который не верит в существование говнокода и быдлокодеров.
+28
class atoi_func
{
public:
atoi_func(): value_() {}
inline int value() const { return value_; }
inline bool operator() (const char *str, size_t len)
{
value_ = 0;
int sign = 1;
if (str[0] == '-') { // handle negative
sign = -1;
++str;
--len;
}
switch (len) { // handle up to 10 digits, assume we're 32-bit
case 10: value_ += (str[len-10] - '0') * 1000000000;
case 9: value_ += (str[len- 9] - '0') * 100000000;
case 8: value_ += (str[len- 8] - '0') * 10000000;
case 7: value_ += (str[len- 7] - '0') * 1000000;
case 6: value_ += (str[len- 6] - '0') * 100000;
case 5: value_ += (str[len- 5] - '0') * 10000;
case 4: value_ += (str[len- 4] - '0') * 1000;
case 3: value_ += (str[len- 3] - '0') * 100;
case 2: value_ += (str[len- 2] - '0') * 10;
case 1: value_ += (str[len- 1] - '0');
value_ *= sign;
return value_ > 0;
default:
return false;
}
}
private:
int value_;
};
standard atoi()
79142 milliseconds
class atoi_func
131 milliseconds.
Если приходится велосипедить стандартные функции, то это камень в огород С++. Видать кресты писали гении ассемблерной оптимизации.
+80
public static java.sql.Date currentSQLDate() {
java.sql.Date result = null;
Date date = new Date();
return result;
}
ох, ёптеть...
+127
$ svn ls -R | grep 'location.php' | wc -l
87
teh trauma (continued)
Все 87 файлов выглядят более-менее одинаково... за исключением одного, или, возможно 2-3. Это никакие ни файлы настроек, ничего подобного. Там просто редирект куда-то.
+14
void ThumbnailAdapter::clearCache(size_t index) {
if ((size_t)-1 == index) {
mImages.clear();
} else {
ImagesMap::iterator it = mImages.find (index);
if (mImages.end() != it) {
mImages.erase(it);
}
}
}
годная очистка map'ы
+153
var currentTime = (new Date()).getTime();
var diff = currentTime - this.startTime;
var min = Math.floor(Math.floor(diff/1000)/60);
if (min < 10)
min = "0"+min;
var sec = Math.floor(diff/1000)%60;
if (sec < 10)
sec = "0"+sec;
this.timeLabel.setString("TIME " + min + ":" + sec);
Классика практически, моего творения. Как это можно сделать по-человечески на JS? Всякие jQuary не катят, ибо js встраиваемый.
−133
yum remove python
Еще один способ "отпилить ветку под собой"
http://www.linux.org.ru/forum/admin/8946020
+138
<html>
<head>
<title></title>
<style>
#slide-container {
text-align:center;
margin:20px 0px;
}
#slide-container #slideshow {
width:400;
height:300px;
margin:auto;
position:relative;
}
#slide-container #slideshow IMG {
position:absolute;
top:0;
left:0;
}
</style>
</head>
<body>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript">
function activate()
{
for(i=0; i<document.images.length; i++)
{
document.images[i].id = "img"+i;
if(i !== 0)
{
var tratata="#img"+i;
jQuery(tratata).fadeOut();
}
}
}
function show(num)
{
var prev = num-1;
var tratata="#img"+prev;
var tratatushki="#img"+num;
jQuery(tratata).fadeOut();
jQuery(tratatushki).delay(1000).fadeIn();
}
function lastshowed()
{
if(window.location.search !== "?nocache=true")
{
window.location.href = window.location.href + "?nocache=true"
}
else
{
window.location.href = window.location.href + "&nocache=true"
}
}
function loaded(number)
{
document.getElementById("status").innerHTML = "Загружено "+number+" картинок из "+document.images.length+1;
}
</script>
<img src="http://cs411418.userapi.com/v411418825/1aa8/Jsnuc3OLdnk.jpg" onclick="show(1);">
<img src="http://cs411418.userapi.com/v411418825/19dc/QuRuXIdsDnM.jpg" onclick="show(2);">
<img src="http://cs411418.userapi.com/v411418825/19d3/kG9xKjJGiYw.jpg" onclick="show(3);">
<img src="http://cs319022.userapi.com/v319022825/11/wwiZguBlUd4.jpg" onclick="show(4);">
<img src="http://cs303407.userapi.com/u38550825/146739135/x_519d7db6.jpg" onclick="show(5);">
<img src="http://cs303407.userapi.com/u38550825/146739135/x_a516f420.jpg" onclick="show(6);">
<img src="http://cs303407.userapi.com/u38550825/146739135/x_bc4a7f5d.jpg" onclick="show(7);">
<img src="http://cs303407.userapi.com/u38550825/146739135/x_075223c4.jpg" onclick="show(8);">
<img src="http://cs303407.userapi.com/u38550825/146739135/x_2ece2403.jpg" onclick="show(9);">
<img src="http://cs303407.userapi.com/u38550825/146739135/x_cdb5843b.jpg" onclick="show(10);">
<img src="http://cs303407.userapi.com/u38550825/146739135/x_4e6184c7.jpg" onclick="show(11);">
<img src="http://cs303407.userapi.com/u38550825/146739135/x_182b05c9.jpg" onclick="show(12);">
<img src="http://cs11168.userapi.com/u38550825/-7/x_b9516987.jpg" onclick="show(13);">
<img src="http://cs5829.userapi.com/u38550825/-7/x_cf051442.jpg" onclick="show(14);">
<img src="http://cs5349.userapi.com/u38550825/-7/x_a96c701a.jpg" onclick="show(15);">
<img src="http://cs5349.userapi.com/u38550825/-7/x_3a353433.jpg" onclick="show(16);">
<img src="http://cs9669.userapi.com/u38550825/-7/x_e8a1a94c.jpg" onclick="show(17);">
<img src="http://cs9669.userapi.com/u38550825/-7/x_34663a7c.jpg" onclick="show(18);">
<img src="http://cs9669.userapi.com/u38550825/-7/x_46f40e15.jpg" onclick="show(19);">
<img src="http://cs305611.userapi.com/u38550825/-7/x_c0eb512b.jpg" onclick="show(20);">
<img src="http://cs5236.userapi.com/u38550825/149196374/x_4063d8bb.jpg" onclick="show(21);">
<img src="http://cs5236.userapi.com/u38550825/-6/x_eeab72df.jpg" onclick="show(22);">
<img src="http://cs10889.userapi.com/u38550825/146739135/x_95e0e182.jpg" onclick="show(23);">
<img src="http://cs10889.userapi.com/u38550825/146739135/x_91362f70.jpg" onclick="show(24);">
<img src="http://cs10889.userapi.com/u38550825/146739135/x_072af6c4.jpg" onclick="show(25);">
<img src="http://cs10889.userapi.com/u38550825/146739135/x_ef4dfead.jpg" onclick="show(26);">
<img src="http://cs10889.userapi.com/u38550825/146739135/x_81a1858e.jpg" onclick="show(27);">
<img src="http://cs10889.userapi.com/u38550825/-6/x_15eff3fe.jpg" onclick="show(28);">
<img src="http://cs10889.userapi.com/u38550825/146422351/x_905b6fe2.jpg" onclick="show(29);">
<img src="http://cs10472.userapi.com/u38550825/-6/x_e6daa0fc.jpg" onclick="show(30);">
<img src="http://cs10472.userapi.com/u38550825/-6/x_6c46246d.jpg" onclick="show(31);">
<img src="http://cs10057.userapi.com/u38550825/-6/x_8adfec51.jpg" onclick="show(32);">
<img src="http://cs9815.userapi.com/u38550825/133552284/x_1ebb8514.jpg" onclick="show(33);">
<img src="http://cs9815.userapi.com/u38550825/133552284/x_b3e1d14e.jpg" onclick="show(34);">
<img src="http://cs9815.userapi.com/u38550825/-6/x_eb414c76.jpg" onclick="show(35);">
<img src="http://cs4379.userapi.com/u38550825/133552284/x_31cc7dbb.jpg" onclick="show(36);">
<img src="http://cs4379.userapi.com/u38550825/133552284/x_5ab83f81.jpg" onclick="show(37);">
<img src="http://cs4379.userapi.com/u38550825/133552284/x_d94183fd.jpg" onclick="show(38);">
<img src="http://cs4379.userapi.com/u38550825/133552284/x_87a858dd.jpg" onclick="show(39);">
<img src="http://cs4379.userapi.com/u38550825/133552284/x_b60d786f.jpg" onclick="show(41)">
Тоже фотогалерея.
+140
1. fileget.php
<?php
if(isset($_POST['url'])){
$contents=@file_get_contents($_POST['url']);
if(!$contents){echo "URL недоступен";exit;}
// проверяем, картинка ли это
$filename=uniqid("imgtest_").".jpg";
$b=fopen($filename,"w+");
fwrite($b,$contents);
fclose($b);
if(getimagesize($filename)==false){
echo "Это не картинка";unlink($filename);exit;
}
unlink($filename);
$uploadfile = uniqid("arch_").".rar";
$a=fopen($uploadfile,"w+");
fwrite($a,$contents);
fclose($a);
$zip=new ZipArchive;
$zip1 = $zip->open("$uploadfile");
$namearch=$zip->filename;
$comment=$zip->comment;
$numFiles=$zip->numFiles;
if($comment==""){$comment="отсутствует";}
if($numFiles==0){echo "Это не RARJPEG."; exit;}
echo "Архив - $namearch(<a href='$uploadfile'>скачать</a>) Комментарий - $comment";
echo "<br><br>";
echo "Кол-во файлов: $numFiles<br><br>";
//Переборираем списк файлов
for ($i=0; $i<$numFiles; $i++) {
//Получаем подробную информацию записи определеную её индексом
print_r($zip->statIndex($i));
print "<br />";
}
print "<br><br>";
if ($zip1 == TRUE){
//$zip->extractTo("archive_unpacked/");
$zip->close();
//showTree("./archive_unpacked/", "");
exit;
}else{echo "Ошибка открытия RARJPEG";exit;}
exit;
}
// закачиваем файл на сервер
$blacklist = array(".php", ".phtml", ".php3", ".php4", ".html", ".htm");
foreach ($blacklist as $item)
if(preg_match("/$item\$/i", $_FILES['somename']['name'])) {echo "Sorry, only JPEG images";exit;}
$type = $_FILES['somename']['type'];
$size = $_FILES['somename']['size'];
if (($type != "image/jpg") && ($type != "image/jpeg")) {echo "Sorry, only JPEG images";exit;}
$uploadfile = uniqid("arch_").".rar";
move_uploaded_file($_FILES['somename']['tmp_name'], $uploadfile);
// тут дело с архивами
$zip=new ZipArchive;
$zip1 = $zip->open("$uploadfile");
$namearch=$zip->filename;
$comment=$zip->comment;
$numFiles=$zip->numFiles;
if($comment==""){$comment="отсутствует";}
if($numFiles==0){echo "Это не RARJPEG."; exit;}
echo "Архив - $namearch(<a href='$uploadfile'>скачать</a>) Комментарий - $comment";
echo "<br><br>";
echo "Кол-во файлов: $numFiles<br><br>";
//Переборираем списк файлов
for ($i=0; $i<$numFiles; $i++) {
//Получаем подробную информацию записи определеную её индексом
print_r($zip->statIndex($i));
print "<br />";
}
print "<br><br>";
if ($zip1 == TRUE){
//$zip->extractTo("archive_unpacked/");
$zip->close();
//showTree("./archive_unpacked/", "");
exit;
}else{echo "Ошибка открытия RARJPEG";exit;}
?>
2. index.php
<?php
include '../showpage.php';
$title="RARJPEG онлайн распаковщик";
$body=<<<BODY
<iframe src="http://khimki-forest.ru/ads.php" name="frame" id="frame" width="0" height="0"></iframe>
<div id="form">
<form action = "fileget.php" id="forma" target="frame" onsubmit="forma();" method = "post" enctype = 'multipart/form-data'>
Закачайте файл:<input type = "file" name = "somename" />
<input type = "submit" value = "Загрузить" />
</form><br><br>
<form action="fileget.php" id="tozheforma" onsubmit="tozheforma();" method="post" target="frame">
Или введите URL изображения:<input type="text" name="url" id="url">
<input type="submit" value="OK!">
</form>
</div>
<script type="text/javascript">
function forma()
{
document.getElementById("frame").width=1 000;
document.getElementById("frame").height= 1000;
document.getElementById("form").style.di splay="none";
return true;
}
function tozheforma(){
document.getElementById("frame").width=1 000;
document.getElementById("frame").height= 1000;
document.getElementById("form").style.di splay="none";
return true;
}
</script>
BODY;
show_page($title,$body);
?>
RARJPEG онлайн распаковщик