- 1
list($V_id, $V_image, $V_title, $V_text, $V_url, $V_link_to, $V_status) = array('','','','','','','');
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+154
list($V_id, $V_image, $V_title, $V_text, $V_url, $V_link_to, $V_status) = array('','','','','','','');
множественное присваивание?! не, не слыщал
+139
#define InlineIsEqualGUID(rguid1, rguid2) \
(((unsigned long *) rguid1)[0] == ((unsigned long *) rguid2)[0] && \
((unsigned long *) rguid1)[1] == ((unsigned long *) rguid2)[1] && \
((unsigned long *) rguid1)[2] == ((unsigned long *) rguid2)[2] && \
((unsigned long *) rguid1)[3] == ((unsigned long *) rguid2)[3])
Windows SDK, guiddef.h
ret = InlineIsEqualGUID(&g_guid, guid_array + i); /* ??? */
+139
// ==UserScript==
// @name GK parent comment
// @namespace GK
// @description Adds links to parent commentary to GK comments, and sets parent commentary text as link tooltip.
// @include http://govnokod.ru/*
// @include http://www.govnokod.ru/*
// @version 1.0.0
// @updateURL http://userscripts.org/scripts/source/172756.meta.js
// @downloadURL http://userscripts.org/scripts/source/172756.user.js
// ==/UserScript==
(function(){
//hack for Chrome, as it doesn't support unsafeWindow.
if (typeof unsafeWindow == 'undefined')
{
unsafeWindow = (function()
{
var el = document.createElement('p');
el.setAttribute('onclick', 'return window;');
return el.onclick();
}())
};
$ = unsafeWindow.jQuery;
//dirty, DIRTY hack to wait for certain element to appear. -_-
//But I have no idea how to do it right.
function waitForSelector(selector, context, mustexist, callback) {
var l = $(selector, context).length;
if ((l>0) != mustexist)
{
setTimeout(function(){waitForSelector(selector, context, mustexist, callback)}, 50);
return false;
};
callback();
}
//short function for adding custom CSS rules. Why use Greasemonkey specific GM_setStyle() just for that?
function addCSS(rule) {
var styleElement = document.createElement("style");
styleElement.type = "text/css";
if (typeof styleElement.styleSheet !== 'undefined')
styleElement.styleSheet.cssText = rule;
else
styleElement.appendChild(document.createTextNode(rule));
document.getElementsByTagName("head")[0].appendChild(styleElement);
}
addCSS([
'.comment-parent-link {margin-left:10px;font-size:10pt}',
].join('/n'));
var PARENT = '<a class="comment-link comment-parent-link" href="">↑</a>';
var oldLoadComments = unsafeWindow.comments['load'];
function newLoadComments(aElemTrigger) {
var $parent = $(aElemTrigger).closest('.entry-comments');
oldLoadComments.call(this,aElemTrigger);
waitForSelector('.hcomment', $parent, true, function(){
setParentLinks($parent);
});
}
unsafeWindow.comments['load'] = newLoadComments;
function setParentLinks($context) {
$context.find('.hcomment').each(function(i,e){
var $this = $(this);
var $parent = $this.parents('.hcomment:eq(0)');
if ($parent.length) {
var $parentlink = $(PARENT);
$parentlink.attr('href', $parent.find('a.comment-link:eq(0)').attr('href'));
$parentlink.attr('title', $parent.find('.comment-text:eq(0)').text());
$this.find('a.comment-link:eq(0)').after($parentlink);
}
});
}
setParentLinks($('body'));
})();
http://userscripts.org/scripts/show/172756
По просьбам трудящихся, скрипт для поиска родительского комментария. Добавляет ссылку на родителя, и ставит его текст как тултип.
Учитывая подключение либы с самого сайта и метод поиска динамически подгруженных комментариев, вполне себе говнокод. А потому: тов. Страйкер, вынесите уже отдельно функцию comments.loadSuccessful()! А то адский гемморой любую постобработку комментариев делать.
+125
<Target Inputs="@(DeployLabel)" Name="GenericDeploy" Outputs="%(Identity).Dummy">
<PropertyGroup>
<TargetFilter>%(DeployLabel.Dir)</TargetFilter>
<TargetFilterReplaced>$(TargetFilter.Replace('\', ''))</TargetFilterReplaced>
</PropertyGroup>
<WriteLinesToFile
File="$(ProjectDir)tsfiles.txt"
Condition="$([System.Text.RegularExpressions.Regex]::IsMatch(%(Filter),
'$(TargetFilterReplaced)'))"
Lines="@(TypeScriptCompile ->'"%(fullpath)"', ' ')"
Overwrite="false" />
<PropertyGroup>
<TSFilesFiltered>$([System.IO.File]::ReadAllText($(ProjectDir)tsfiles.txt))</TSFilesFiltered>
<TSFilesOneLine>$([System.Text.RegularExpressions.Regex]::Replace(
$(TSFilesFiltered), "[\n\r]+", " "))</TSFilesOneLine>
</PropertyGroup>
<Exec Command="tsc --target ES3 -c -d --out $(Deployroot)\foo.js $(TSFilesOneLine)" />
<Delete Files="$(ProjectDir)tsfiles.txt"/>
</Target>
Кто не был, тот будет, кто был, тот не забудет.
MSBuild: задача отфильтровать массив из строк. Я за два дня ничего лучшего не придумал.
+140
procedure TForm1.CloseChecker1Click(Sender: TObject);
begin
Halt;
end;
procedure TForm1.CoolTrayIcon1DblClick(Sender: TObject);
begin
Form1.Show;
CoolTrayIcon1.IconVisible:=false;
end;
end.
Продолжение. Начало на http://govnokod.ru/13317, http://govnokod.ru/13318
+139
procedure TMyTr.Execute;
var
s,resp,ip,port:string;
cw,i:integer;
begin
http:=TIdHTTP.Create(nil);
cw:=getnumberproxy;
while cw<form1.Memo1.Lines.Count do
begin
s:=form1.Memo1.Lines[cw];
i := Pos(':',s);
IP := Copy(s,1,i-1);
PORT := Copy(s,i+1,Length(s));
try
http.ProxyParams.ProxyServer:=ip;
http.ProxyParams.ProxyPort:=StrToInt(port);
http.ReadTimeout:=Form1.SpinEdit2.Value*1000;
resp:=http.Get('http://ya.ru/');
if pos('ya.ru',resp)<>0 then
form1.Memo2.Lines.Add(ip+':'+port);
except
end;
cw:=getnumberproxy;
checked:=checked+1;
end;
http.Free;
end;
procedure TForm1.Button1Click(Sender: TObject);
var i:integer;
begin
ind:=-1;
label6.caption:=inttostr(Memo1.Lines.count);
for i:=1 to spinedit1.Value do
begin
thr[i]:=TMyTr.Create;
thr[i].Pause(1);
thr[i].Resume;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
form1.label4.caption:=IntToStr(Form1.Memo2.Lines.Count);
Form1.Label6.Caption:=IntToStr(form1.Memo1.Lines.Count);
Form1.Label3.Caption:=IntToStr(checked);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Form1.Memo1.Clear;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
Form1.Memo2.Clear;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
if SaveDialog1.Execute=true then
Form1.Memo2.Lines.SaveToFile(Form1.SaveDialog1.FileName);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if Form1.OpenDialog1.Execute=True
then
Form1.Memo1.lines.LoadFromFile(Form1.OpenDialog1.FileName);
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
Form1.CoolTrayIcon1.IconVisible:=True;
Form1.Hide;
end;
procedure TForm1.Show1Click(Sender: TObject);
begin
Form1.Show;
Form1.CoolTrayIcon1.IconVisible:=false;
end;
procedure TForm1.SaveGood1Click(Sender: TObject);
begin
if SaveDialog1.Execute=true then
Form1.Memo2.Lines.SaveToFile(Form1.SaveDialog1.FileName);
end;
procedure TForm1.ClearGood1Click(Sender: TObject);
begin
Form1.Memo2.Clear;
end;
Продолжение. Начало на http://govnokod.ru/13317
+135
(***************************************************************************
_____ _ _ __ __ _ _ _____
/ ____| | (_) \ \ / / | | | | | __ \
| | ___ __| |_ _ __ __ \ \ /\ / /__ _ __| | __| | | |__) | _
| | / _ \ / _` | | '_ \ / _` \ \/ \/ / _ \| '__| |/ _` | | _ / | | |
| |___| (_) | (_| | | | | | (_| |\ /\ / (_) | | | | (_| |_| | \ \ |_| |
\_____\___/ \__,_|_|_| |_|\__, | \/ \/ \___/|_| |_|\__,_(_)_| \_\__,_|
__/ |
|___/
*****************************************************************************)
(*****************************************************************************
Автор программы - CraftR14
Исходники предоставлены для форума CodingWorld.Ru
*****************************************************************************)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
gsvThread, idhttp, Spin, ShellAPI, Menus, CoolTrayIcon, Dialogs,
ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
SpinEdit1: TSpinEdit;
Button1: TButton;
Memo2: TMemo;
Label5: TLabel;
Label6: TLabel;
Timer1: TTimer;
SpinEdit2: TSpinEdit;
Label1: TLabel;
Label4: TLabel;
Label2: TLabel;
Label3: TLabel;
Button2: TButton;
Button3: TButton;
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
Button4: TButton;
Button5: TButton;
GroupBox3: TGroupBox;
GroupBox4: TGroupBox;
Label7: TLabel;
Label8: TLabel;
GroupBox5: TGroupBox;
SaveDialog1: TSaveDialog;
OpenDialog1: TOpenDialog;
Bevel1: TBevel;
Button6: TButton;
CoolTrayIcon1: TCoolTrayIcon;
PopupMenu1: TPopupMenu;
PopupMenu2: TPopupMenu;
Show1: TMenuItem;
SaveGood1: TMenuItem;
ClearGood1: TMenuItem;
CloseChecker1: TMenuItem;
Label9: TLabel;
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Show1Click(Sender: TObject);
procedure SaveGood1Click(Sender: TObject);
procedure ClearGood1Click(Sender: TObject);
procedure CloseChecker1Click(Sender: TObject);
procedure CoolTrayIcon1DblClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TMyTr = class(TgsvThread)
http:TidHttp;
protected
procedure Execute; override;
end;
var
Form1: TForm1;
ind:integer=-1;
thr: array [1..900] of TMyTr;
checked:Integer=0;
implementation
{$R *.dfm}
function getnumberproxy:integer;
begin
if ind<>form1.Memo1.Lines.Count then
inc(ind);
result:=ind;
end;
Вот эта вот, херня ходит по интернету и называется "Прокси-чеккер". Особо умилило то, что автор каким-то макаром приплел сюда GSVthreads.
+129
// Delpih 7 отказывается компилировать этот код, тогда как в Delphi 2010 он вполне успешно компилируется.
// Отчего это?
for pthread in lst do
...
>>[Error] Unit1.pas(89): Operator not applicable to this operand type
−95
obj.serialized_data = str(serialized_data).replace(
" u'", " '").replace("{u'", "{'").replace(" '", ' "').replace("':", '":').replace(
"{'", '{"').replace("', ", '", ').replace("'}", '"}').replace(' True,', ' true,').replace(
'None', 'null').replace(' False,', 'false,')
Сериализация словаря
+134
using System;
using System.Security.Cryptography;
namespace sha1_calc
{
class Program
{
static void Main(string[] args)
{
SHA1 sha = new SHA1CryptoServiceProvider();
foreach (var fname in args)
{
Console.WriteLine("file: " + fname);
try
{
System.IO.FileStream fs = System.IO.File.Create(fname);
byte [] res = sha.ComputeHash(fs);
fs.Close();
Console.Write("0x");
foreach (var i in res)
{
Console.Write(i.ToString("X"));
}
Console.WriteLine();
Console.WriteLine("---------------------------------");
}
catch(Exception e)
{
Console.WriteLine("error: " + e);
}
}
Console.ReadKey();
}
}
}
Скачал парочку образов и решил проверить их чексуммы. Протестировал программу на скачанных файлах. Удивился, почему же у них хеши одинаковые?