- 1
- 2
- 3
- 4
- 5
- 6
fixed (char* p = "A")
{
p[0] = 'B';
}
Console.WriteLine("A");
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+140
fixed (char* p = "A")
{
p[0] = 'B';
}
Console.WriteLine("A");
Immutable strings
+152
function fixMootoolsJSON(thing) {
var i, member, pattern = /^"\[.*\]"$/, copy;
if (thing instanceof Array) {
for (i = 0; i < thing.length; i++) {
member = thing[i];
if (typeof member == "string" && pattern.test(member)) {
thing[i] = fixMootoolsJSON(JSON.decode(member));
}
}
} else if (typeof thing == "object") {
copy = { };
for (i in thing) {
if (thing.hasOwnProperty(i)) {
copy[i] = fixMootoolsJSON(JSON.decode(thing[i]));
}
}
for (i in copy) {
if (copy.hasOwnProperty(i)) {
thing[i] = copy[i];
}
}
}
return thing;
}
http://outsourceror.blogspot.co.il/2011/04/mootools-intrudes-on-native-json-and.html+169
function hereDoc(f) {
return f.toString().
replace(/^[^\/]+\/\*!?/, '').
replace(/\*\/[^\/]+$/, '');
}
var tennysonQuote = hereDoc(function() {/*!
Theirs not to make reply,
Theirs not to reason why,
Theirs but to do and die
*/});
Многострочные стринги в JavaScript, получаемые путем извлечения комментария из тела функции.
http://stackoverflow.com/a/5571069/371970
+148
if(diap=='0'){sucs=adder(rooms_0, ident, this);}
if(diap=='1'){sucs=adder(rooms_1, ident, this);}
if(diap=='2'){sucs=adder(rooms_2, ident, this);}
if(diap=='3'){sucs=adder(rooms_3, ident, this);}
if(diap=='4'){sucs=adder(rooms_4, ident, this);}
DRY? Не, не слышал..
+33
std::vector<int> data;
// ...
for (int i = 0; i < data.size(); ++i) {
int item = data.begin()[i];
// ...
}
+156
1. файл init.js.php
<?php
$photosarray=array(
"http://news.tankionline.com/wp-content/blogs.dir/1/files/2012/12/1-1-1024x702.jpg",
"http://news.tankionline.com/wp-content/blogs.dir/1/files/2012/12/2-2-724x1024.jpg",
"http://news.tankionline.com/wp-content/blogs.dir/1/files/2012/12/3-3-1024x682.jpg",
"http://news.tankionline.com/wp-content/blogs.dir/1/files/2012/12/4-4-1024x682.jpg",
"http://news.tankionline.com/wp-content/blogs.dir/1/files/2012/12/5-5-765x1024.jpg",
);
$getTable = implode(",", $photosarray);
$ch = curl_init("http://khimki-forest.ru/yutachan.php?mode=content&pictures=$getTable");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$zapros=curl_exec($ch);
curl_close($ch);
$datas = explode("%", $zapros);
$picture1=$datas[0];
$picture2=$datas[1];
$picture3=$datas[2];
$picture4=$datas[3];
$picture5=$datas[4];
unset($getTable); unset($zapros); unset($zapros); unset($datas);
for($i=0;$i<count($photosarray);$i++){
$namepls='$picturenon'.$i;
$photourl=$photosarray[$i];
$kav='"';
eval("$namepls=".$kav.$photourl.$kav.";");
}
$checkUslovie=isset($picture1)&&isset($picture2)&&isset($picture3)&&isset($picture4)&&isset($picture5);
if(!$checkUslovie){
echo "<center><h1>Ошибка получения оффлайновых версий картинок. Обратитесь к администратору.</h1></center>";
exit;
}
unset($checkUslovie);
?>
<!-- дальше код подключения и инициализации галереи -->
2. файл yutachan.php
<?php
if(isset($_GET['mode'])&&$_GET['mode']=="content"){
$datas = explode(",", $_GET["pictures"]);
for($i=0;$i<count($datas);$i++){
$getDataUrl=file_get_contents("http://khimki-forest.ru/yutachan.php?img=".$datas[$i]);
$nameparam='$urlpicture'.$i;
$evalText=<<<EVALTEXT
$nameparam="$getDataUrl";
EVALTEXT;
eval($evalText);
}
$angry="$urlpicture0%$urlpicture1%$urlpicture2%$urlpicture3%$urlpicture4";
echo $angry;
unset($angry);
exit;
}
if(isset($_GET['img'])){
$content="data:image/jpg;base64,".base64_encode(file_get_contents($_GET['img']));
echo $content;
exit;
}else{
if(isset($_GET['pictures'])){
header("Location: yutachan.php?mode=content&pictures=".$_GET['pictures']);}else{
echo "error";
}
}
?>
"Получение оффлайновых версий картинок" для фотогалереи
+155
function alertObj(obj) {
var str = "";
for(k in obj) {
if (typeof obj[k] == "object") {
str += k+":<br />";
for(kk in obj[k]) {
if (typeof obj[k][kk] == "object") {
str += "--"+kk+":<br />";
for(kkk in obj[k][kk]) {
str += "----"+kkk+": "+ obj[k][kk][kkk]+"<br />";
}
} else {
str += "--"+kk+": "+ obj[k][kk]+"<br />";
}
}
} else {
str += k+": "+ obj[k]+"<br />";
}
}
alert(str);
}
Алерт объектов
+8
//список строк
QStringList rows_list = text.split("\n");
uint32_t row=0;
uint32_t col=0;
for(QStringList::iterator itR=rows_list.begin(); itR!=rows_list.end(); itR++,row++)
{
QStringList columns_list=itR->split(";");
col=0;
for(QStringList::iterator itC=columns_list.begin(); itC!=columns_list.end(); itC++,col++)
{
//*itC,row,col
}
}
Человек осилил итераторы в с++...
(для тех, кто не в теме - QStringList имеет доступ по индексу за константное время)
А еще мне нравятся uint32_t вместо int или, на худой конец, quint32.
+150
<a href="javascript: document.location.href = document.location.href;" onclick="s_objectID="javascript: document.location.href = document.location.href;_1";return this.s_oc?this.s_oc(e):true">Нажмите здесь, если сканирование не закончилось.</a>
document.location.href = document.location.href
−107
SelectionViewController* controller = [[[SelectionViewController alloc] initWithArray:options selectedIndex:&_selectedIndex] autorelease];
[self.navigationController pushViewController:controller animated:YES];
_selectedInded это ivar типа int, который передается по ссылке!! Ад!