- 1
- 2
- 3
- 4
- 5
try {
die(@date("d.m.Y H:i:s") . "\t" . $this->x($id, true) . "\r\n");
} catch (Exception $e) {
die(@date("d.m.Y H:i:s") . "\tERROR: " . $e->getMessage() . "\r\n");
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+162
try {
die(@date("d.m.Y H:i:s") . "\t" . $this->x($id, true) . "\r\n");
} catch (Exception $e) {
die(@date("d.m.Y H:i:s") . "\tERROR: " . $e->getMessage() . "\r\n");
}
остаться в живых
+12
// precondition: you already have a boost::shared_ptr<> to this or a derived object
template<typename T>
inline boost::shared_ptr<T> get_shared_ptr()
{
// this cast lets the compiler verify the type compatibility
assert( dynamic_cast<typename boost::shared_ptr<T>::element_type*>( &(*shared_from_this()) ) != 0);
return *(boost::shared_ptr<T>*) &shared_from_this();
}
-
+139
class MainClass
{
public static char[,] titato = new char[3, 3] { { ' ', ' ', ' ' }, { ' ', ' ', ' ' }, { ' ', ' ', ' ' } };
static bool CheckWin(char s)
{
if ((titato[0, 0] == titato[1, 1] & titato[1, 1] == titato[2, 2] & titato[0, 0] != ' ') ||
(titato[0, 1] == titato[0, 2] & titato[0, 2] == titato[0, 0] & titato[0, 1] != ' ') ||
(titato[1, 1] == titato[1, 2] & titato[1, 2] == titato[1, 0] & titato[1, 1] != ' ') ||
(titato[2, 1] == titato[2, 2] & titato[2, 2] == titato[2, 0] & titato[2, 1] != ' ') ||
(titato[1, 0] == titato[2, 0] & titato[2, 0] == titato[0, 0] & titato[1, 0] != ' ') ||
(titato[1, 1] == titato[2, 1] & titato[2, 1] == titato[0, 1] & titato[1, 1] != ' ') ||
(titato[1, 2] == titato[2, 2] & titato[2, 2] == titato[0, 2] & titato[1, 2] != ' ') ||
(titato[2, 0] == titato[1, 1] & titato[1, 1] == titato[0, 2] & titato[2, 0] != ' '))
{
return true;
}
return false;
}
public static void PrintTicTacToe(char s)
{
Console.Clear();
Console.Write(" ");
Console.BackgroundColor = ConsoleColor.White;
for (int i = 0; i < titato.GetLength(0); i++) {
Console.Write(" {0} ", i);
}
Console.WriteLine();
for (int i = 0; i < titato.GetLength(0); i++) {
Console.BackgroundColor = ConsoleColor.White;
Console.Write("{0}", i);
for (int j = 0; j < titato.GetLength(1); j++) {
Console.BackgroundColor = ConsoleColor.Black;
if (titato[i, j] == 'x') {
Console.ForegroundColor = ConsoleColor.Red;
}
else if (titato[i, j] == 'o') {
Console.ForegroundColor = ConsoleColor.Green;
}
else {
Console.ForegroundColor = ConsoleColor.Black;
}
Console.Write(" {0} ", titato[i, j]);
}
Console.WriteLine();
}
Console.BackgroundColor = ConsoleColor.White;
Console.ForegroundColor = ConsoleColor.Black;
if (CheckWin(s)) {
Console.WriteLine(s + " win!!!");
}
}
public static void PushXO(int i, int j, char s)
{
titato[i, j] = s;
}
public static void Main(string[] args)
{
bool symbolX = true;
char s = 'x';
int i = 0, j = 0;
do {
Console.WriteLine("TIC TAC TOE!");
PrintTicTacToe(s);
if (symbolX == true) {
Console.WriteLine("Ходит Х");
Console.WriteLine("Введите номер столбца а затем введите номер строки:");
s = 'x';
symbolX = false;
}
else {
Console.WriteLine("Ходит О");
Console.WriteLine("Введите номер столбца а затем введите номер строки:");
s = 'o';
symbolX = true;
}
i = int.Parse(Console.ReadLine());
j = int.Parse(Console.ReadLine());
PushXO(j, i, s);
// Console.ReadLine();
PrintTicTacToe(s);
} while (true);
}
Крестики-нолики
−86
...
_testMode = new uint(1);
...
_appID = new String("blah_blah");
...
Продолжаю вкуривать в новый чужой проект. Не устает радовать.
+6
#define SET_VTYPE_AND_VARREF(type, val) \
this->vt = VT_ ## type | VT_BYREF; \
V_ ## type ## REF (this) = val;
TVariantT& operator=(System::Currency* src)
{
Clear();
if(src)
SET_VTYPE_AND_VARREF(CY,
reinterpret_cast<tagCY*>(&(src->Val)));
return* this;
}
Быдлер такой быдлер
стырено отсюда http://habrahabr.ru/company/pvs-studio/blog/179615/
+12
#include <iostream>
namespace dynamic {
template <class T> class scope;
template <class T> class variable {
public:
variable() : initial(0), current(&initial) {}
variable(const T &val) : initial(val, 0), current(&initial) {}
operator T() { return current->val; }
const T & operator = (const T & new_val) {
return current->val = new_val;
}
private:
struct node {
node(node *prev) : val(), prev(prev) {}
node(const T &val, node *prev) : val(val), prev(prev) {}
T val;
node *prev;
};
node initial;
node *current;
friend class scope<T>;
};
template <class T> class scope {
public:
scope(variable<T> &var) : var(var), node(var.current) {
var.current = &node;
}
scope(variable<T> &var, const T &val) : var(var), node(val, var.current) {
var.current = &node;
}
~scope() {
var.current = node.prev;
}
private:
variable<T> &var;
typename variable<T>::node node;
};
}
dynamic::variable<int> x(100500);
void foo() {
std::cout << x << std::endl;
}
void bar() {
dynamic::scope<int> x_(x, 42);
foo();
x = 265;
foo();
}
int main() {
foo();
bar();
foo();
return 0;
}
Навеяно http://govnokod.ru/12993.
https://ideone.com/7AA33Q
+20
#include <iostream>
#include <cstring>
const char tag[] = "Secret tag!";
const size_t tagSize = sizeof(tag);
const size_t nameSize = 32;
template<class T>
struct Value
{
Value(const char* name, const T& data) :
data(data)
{
std::strncpy(this->tag, ::tag, tagSize);
std::strncpy(this->name, name, nameSize);
}
char tag[tagSize];
char name[nameSize];
T data;
};
int getStackDir()
{
char a;
char b;
return &b > &a ? 1 : -1;
}
template<class T>
T getValue(const char* name)
{
static const size_t stackSize = 1024 * 1024;
const int stackDir = getStackDir();
char begin;
for(char* p = &begin, *end = &begin - stackSize * stackDir; p != end; p -= stackDir)
{
Value<T>* value = (Value<T>*)p;
if(std::strcmp(value->tag, tag) != 0) continue;
if(std::strcmp(value->name, name) != 0) continue;
return value->data;
}
return T();
}
#define SET(type, name, value) Value<type> name(#name, value)
#define GET(type, name) getValue<type>(#name)
//-----------------------------------------------------------
void test()
{
std::cout << GET(int, x) << std::endl;
}
int main()
{
SET(int, x, 13);
test();
}
Отсюда http://www.rsdn.ru/forum/cpp/5163916.flat#5163916
−94
#/usr/bin/python
import sys, os, time, httplib
if sys.platform == 'linux' or sys.platform == 'linux2':
clearing = 'clear'
else:
clearing = 'cls'
os.system(clearing)
if len(sys.argv) != 2:
print "\n|-------------------------------------------------------------|"
print "| Admin login finder v2.0 |"
print "| Help: admin-find.py -h |"
print "|---------------------------------------------------------------|\n"
sys.exit(1)
for arg in sys.argv:
if arg == '-h':
print "\n|-----------------------------------------------------------------------------|"
print "| Admin login finder v2.0 |"
print "| Usage: admin-find.py www.site.com |"
print "| Example: admin-find.py site.com |"
print "|-------------------------------------------------------------------------------|\n"
sys.exit(1)
site = sys.argv[1].replace("http://","").rsplit("/",1)[0]
site = site.lower()
admin_path = ['admin.php','admin/','administrator/','moderator/','webadmin/','adminarea/','bb-admin/','adminLogin/','admin_area/','panel-administracion/','instadmin/','memberadmin/','administratorlogin/','adm/','admin/account.php','admin/index.php','admin/login.php','admin/admin.php','admin/account.php','joomla/administrator','login.php',
'admin_area/admin.php','admin_area/login.php','siteadmin/login.php','siteadmin/index.php','siteadmin/login.html','admin/account.html','admin/index.html','admin/login.html','admin/admin.html','admin_area/index.php','bb-admin/index.php','bb-admin/login.php','bb-admin/admin.php','admin/home.php','admin_area/login.html','admin_area/index.html','admin/controlpanel.php','admincp/index.asp','admincp/login.asp','admincp/index.html','admin/account.html','adminpanel.html','webadmin.html','w ebadmin/index.html','webadmin/admin.html','webadmin/login.html','admin/admin_login.html','admin_login.html','panel-administracion/login.html','admin/cp.php','cp.php','administrator/index.php','administrator/login.php','nsw/admin/login.php','webadmin/login.php','admin/admin_login.php','admin_login.php','administrator/account.php','administrator.php','admin_area/admin.html','pages/admin/admin-login.php','admin/admin-login.php','admin-login.php','bb-admin/index.html','bb-admin/login.html','bb-admin/admin.html','admin/home.html','modelsearch/login.php','moderator.php','moderator/login.php','moderator/admin.php','account.php','pages/admin/admin-login.html','admin/admin-login.html','admin-login.html','controlpanel.php','admincontrol.php',
'admin/adminLogin.html','adminLogin.html','admin/adminLogin.html','home.html','rcjakar/admin/login.php','adminarea/index.html','adminarea/admin.html','webadmin.php','webadmin/index.php','webadmin/admin.php','admin/controlpanel.html','admin.html','admin/cp.html','cp.html','adminpanel.php','moderator.htm l','administrator/index.html','administrator/login.html','user.html','administrator/account.html','administrator.html','login.html','m odelsearch/login.html','moderator/login.html','adminarea/login.html','panel-administracion/index.html','panel-administracion/admin.html','modelsearch/index.html','modelsearch/admin.html','admincontrol/login.html','adm/index.html','adm.html','moderator/admin.html','user.php','account.html','controlpane l.html','admincontrol.html','panel-administracion/login.php','wp-login.php','adminLogin.php','admin/adminLogin.php','home.php','adminarea/index.php','adminarea/admin.php','adminarea/login.php','panel-administracion/index.php','panel-administracion/admin.php','modelsearch/index.php','modelsearch/admin.php','admincontrol/login.php','adm/admloginuser.php','admloginuser.php','admin2.php', 'admin2/login.php','admin2/index.php','adm/index.php','adm.php','affiliate.php','adm_auth.php ','memberadmin.php','administratorlogin.php']
print "\n|-------------------------------------------------------------|"
print "| Admin login finder v2.0 |"
print "|---------------------------------------------------------------|\n"
print "\n[-] %s" % time.strftime("%X")
print "[+] Target:",site
print "[+] Checking paths..."
print
try:
for admin in admin_path:
admin = admin.replace("\n","")
admin = "/" + admin
connection = httplib.HTTPConnection(site)
connection.request("GET",admin)
response = connection.getresponse()
print "%s %s %s" % (admin, response.status, response.reason)
except(KeyboardInterrupt,SystemExit):
raise
except:
pass
Оригинал тут:
http://paste.org.ru/?8l6f57
+149
$this->t = (date('w')+1)>6?0:(date('w')+1);
фак мой мозг
+161
$useDummy = true;
do {
if (!file_exists($filename)){ break; }
require_once $filename;
if (!class_exists($className)){ break; }
$useDummy = false;
} while(false);
Новый оператор ветвления do ... while