- 1
- 2
while($row = mysql_fetch_array($r))
echo $row[0] . '|' . $row[1] . '|' . $row[2] . '|' . $row[3] . '|' . $row[4] . '|' . $row[5] . "\n";
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+163
while($row = mysql_fetch_array($r))
echo $row[0] . '|' . $row[1] . '|' . $row[2] . '|' . $row[3] . '|' . $row[4] . '|' . $row[5] . "\n";
implode? не, не слышал
+165
mysql_query("DELETE FROM tblTokens WHERE intRestaurantID = $id AND cToken = '$token';");
mysql_query("INSERT INTO tblTokens (intRestaurantID, cToken) VALUES ($id, '$token');");
Увеличиваем id, наверное.
+71
/**
* @see ru.dwin.inbox.gtk.videotypes.IVideo#startPlay(int)
*/
@Override public void startPlay(int delay)
{
try
{
Thread.sleep(delay * 1000);
}
catch (InterruptedException e1)
{
RestartAllThreads();
}
if (theTimer == null)
{
theTimer = new Timer(ASECOND, new ActionListener()
{
@Override public void actionPerformed(ActionEvent e)
{
if (elapsedTime >= getDuration())
{
theTimer.stop();
resetPlay();
Toolkit.getDefaultToolkit().beep();
}
else
{
elapsedTime += (int) ASECOND / 1000;
notifyAddedRenderers(USwingWorker.ALL);
}
}
});
}
else
{
theTimer.start();
}
}
Играть через ХЗ сколько секунд...
+161
class Super_Loader extends Zend_Loader {
public static function loadClass($class, $dirs = null)
{
parent::loadClass($class, $dirs);
}
private function moduleIsExist($name) {
if(is_dir(APPLICATION_PATH . "/modules/" . $name . "/")) {
return true;
}
return false;
}
public static function autoload($class)
{
$classArray = explode("_", $class);
$firstPart = array_shift($classArray);
if(self::moduleIsExist($firstPart)) {
$moduleDir = APPLICATION_PATH . "/modules/";
$typePart = array_shift($classArray);
switch($typePart) {
case "Lib":
$file_name = $moduleDir . $firstPart . "/lib/" . implode("/", $classArray) . ".php";
break;
case "Model":
$file_name = $moduleDir . $firstPart . "/models/" . implode("/", $classArray) . ".php";
break;
default:
break;
}
if($file_name) {
try {
self::loadFile($file_name);
return $class;
} catch (Exception $e) {
return false;
}
}
} else {
try {
self::loadClass($class);
return $class;
} catch (Exception $e) {
return false;
}
}
}
}
Свой супер-автолоадер для ZF
−107
- (void)applicationWillTerminate:(UIApplication *)application
{
exit(0);
/*
Called when the application is about to terminate.
Save data if appropriate.
See also applicationDidEnterBackground:.
*/
}
На всякий пожарный, а то вдруг не завершиться апп.
+167
$query1234 = "select ....";
$result1234 = mysql_query($query1234);
$rs1234 = mysql_fetch_assoc($result1234);
Это до такой степени не было фантазии придумать осмысленное название переменным. И бедные боялись, что перепишет где-то другие $query, $result, $rs. Не говоря уже о том, что никакой модели, сплошные фетчи, вместо того, чтобы вытянуть всё сразу
+75
private Connection getConnection() throws SQLException {
Connection conn = null;
try{
conn = DriverManager.getConnection(OnlineUsers.db,OnlineUsers.user,OnlineUsers.pass);
} catch (Exception e) {
log.severe(name + ": " + e.getMessage());
}
checkConnection(conn);
return conn;
}
private boolean checkConnection (Connection conn) throws SQLException {
if (conn == null) {
log.severe("Could not connect to the database. Check your credentials in online-users.settings");
throw new SQLException();
}
if (!conn.isValid(5)) {
log.severe("Could not connect to the database.");
throw new SQLException();
}
return true;
}
private boolean execute(String sql) {
return execute(sql, null);
}
private boolean execute(String sql, String player) {
Connection conn = null;
PreparedStatement ps = null;
try {
conn = getConnection();
ps = conn.prepareStatement(sql);
if (player != null && !player.equalsIgnoreCase("")) {
ps.setString(1, player);
}
if (ps.execute()) {
return true;
}
} catch (SQLException ex) {
log.severe(name + ": " + ex.getMessage());
String msg = name + ": could not execute the sql \"" + sql + "\"";
if (player != null ) {
msg += " ?=" +player;
}
log.severe(msg);
} finally {
try {
if (ps != null) {
ps.close();
}
if (conn != null) {
conn.close();
}
} catch (SQLException ex) {
log.severe(name + ": " + ex.getMessage());
}
}
return false;
}
+991
unsigned long long int value=Bin<unsigned long long int>("1111111111111111111111111111111111111111111111111111111111111111");
+93
Type
Bool8 = ByteBool; PBool8 = ^Bool8;
Bool16 = WordBool; PBool16 = ^Bool16;
Bool32 = LongBool; PBool32 = ^Bool32;
Bool64 = Boolean64; PBool64 = ^Bool64;
Int8 = Shortint; PInt8 = ^Int8;
Int16 = Smallint; PInt16 = ^Int16;
Int32 = Longint; PInt32 = ^Int32;
//Int64 = Int64; PInt64 = ^Int64;
IntPR = Int64; PIntPR = ^IntPR;
Word8 = Byte; PWord8 = ^Word8;
Word16 = Word; PWord16 = ^Word16;
Word32 = LongWord; PWord32 = ^Word32;
Word64 = QWord; PWord64 = ^Word64;
WordPR = Word64; PWordPR = ^WordPR;
//Pointer = Pointer; PPointer = ^Pointer;
Float32 = Single; PFloat32 = ^Float32;
Float64 = Double; PFloat64 = ^Float64;
−121
public function onKeyDown(keyDn:uint):void
{
switch(keyDn)
{
case 38 : isUP = true; break;
case 87 : isUP = true; break;
case 40: isDOWN = true; break;
case 83: isDOWN = true; break;
case 37 : isLEFT = true; break;
case 65 : isLEFT = true; break;
case 39 : isRIGHT = true; break;
case 68 : isRIGHT = true; break;
case 32 : многоКода
case 16 : многоКода
}
копипастка с моего любимого демиарта