mysqld: File ‘/var/log/mysql-slow-queries.log’ not found

touch /var/log/mysql-slow-queries.log

chown -R mysql:mysql /var/log/mysql-slow-queries.log

Advertisements

Delphi vs Alternatives

Broad comparison of programming enviroments (IDE’s) with internal GUI support:

  • Delphi / C++ Builder Community Edition (WINNER)
    • Free (for yearly income under $5000)
    • Small executable file
    • Very fast execution
    • Very fast compiling
    • No external software requirement
    • Good Cross-Platform support
  • Visual Studio
    • Free
    • Small executable file
    • Very fast execution
    • Fast compiling
    • External software requirement (.Net Framework)
    • Very Bad Cross-Platform support (Xamarin sucks)
  • Qt
    • Only free for open source projects
    • Very large executable file
    • Fast execution
    • Slow compiling
    • No external software requirement
    • Very good Cross-Platform support
  • Java
    • Free (with limitations)
    • Small executable file
    • Slow execution
    • Slow compiling
    • External software requirement (Java Virtual Machine)
    • Good Cross-Platform support

PHP getRealIpAddress Function

HTTP_X_FORWARDED_FOR can have multiple IPs like 1.1.1.1, 2.2.2.2

function getRealIpAddr()  
{  
    if (!empty($_SERVER['HTTP_CLIENT_IP']))  
    {  
        $ip=$_SERVER['HTTP_CLIENT_IP'];  
    }  
    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
     
    {  
        $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];  
    }  
    else  
    {  
        $ip=$_SERVER['REMOTE_ADDR'];  
    }  
    return $ip;  
}

dbGo vs dbExpress vs FireDAC

In Community edition: Out of the box FireDAC only talks to local databases, but you could use ADO (dbGo) or a third party library.

dbGo (ADO)
The dbGo components provide data access through the ADO framework. ADO, (Microsoft ActiveX Data Objects) is a set of COM objects that access data through an OLE DB provider. The dbGo components encapsulate these ADO objects in the Delphi database architecture. Windows is the only supported target platform for VCL and FMX applications (32 and 64 bits). Obviously, this technology isn’t available for OS X, iOS and Android operating systems.

dbExpress
dbExpress is Embarcadero’s data driver architecture that replaced the BDE. First released with Borland Delphi 6 and C++Builder 6, it has gone through several iterations itself. It provides unidirectional database access, that means you can traverse data obtained from a database table only in the forward direction. You cannot go back, unless you add other layers. This makes dbExpress a very fast access technology, compared to many others. It can be used in VCL and FMX Windows applications (32 and 64 bits), but also for Mac OS X applications (more information about deploying dbExpress database applications: Deploying dbExpress Database_Applications), and provides local database connectivity for iOS and Android mobile applications (Using InterBase ToGo with dbExpress (iOS and Android)) But dbExpress is being deprecated. This means that it will be removed from RAD Studio in an upcoming release. To migrate your dbExpress application to FireDAC, you can find useful information in this link: Migrating dbExpress Applications to FireDAC

FireDAC
FireDAC is a Universal Data Access library for developing applications for multiple devices, connected to enterprise databases. And its the recommended database access framework in Delphi, C+ + Builder and RAD Studio on the latests releases. It provides high-performance, easy-to-use enterprise database connectivity. Universal data access with database specific features to get the most from every specific database engine. Deploying the final application is way easier as it does not requires any drivers to be installed. It can be used in VCL and FMX Windows applications (32 and 64 bits), for Mac OS X applications, and for local database access in iOS and Android.

Keras Project Example

Download pima indian diabetes data file first.

Python code:

from keras.models import Sequential
from keras.layers import Dense
import numpy
# fix random seed for reproducibility
numpy.random.seed(7)
# load pima indians dataset
dataset = numpy.loadtxt("pima-indians-diabetes.csv", delimiter=",")
# split into input (X) and output (Y) variables
X = dataset[:,0:8] #input data - except last column
Y = dataset[:,8] # last column is real results
# create model
model = Sequential()
model.add(Dense(12, input_dim=8, activation='relu'))
model.add(Dense(8, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
# Compile model
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
# Fit the model - train
model.fit(X, Y, epochs=150, batch_size=10, verbose=2)

# evaluate the model
#scores = model.evaluate(X, Y)
#print("\n%s: %.2f%%" % (model.metrics_names[1], scores[1]*100))

# calculate predictions
predictions = model.predict(X)
rounded = [round(x[0],2) for x in predictions]
print(rounded)

Tested on: python-3.6.3-amd64, Keras API 2

Filesize function for Delphi

Erroneous filesize function: (Files bigger than 2GB are shown 2GB)

function FileSize(const aFilename: String): Int64;
var
 info: TWin32FileAttributeData;
begin
 result := -1;

if NOT GetFileAttributesEx(PWideChar(aFileName), GetFileExInfoStandard, @info) then
 EXIT;

result := Int64(info.nFileSizeLow) or Int64(info.nFileSizeHigh shl 32);
end;

Better filesize function: (sr.FindData is Platform specific warning)

function FileSize(const aFilename: String): Int64;
var
 sr : TSearchRec;
begin
 if FindFirst(aFilename, faAnyFile, sr ) = 0 then
 begin
 result := Int64(sr.FindData.nFileSizeHigh) shl Int64(32) + Int64(sr.FindData.nFileSizeLow);
 end else
 begin
 result := -1;
 end;
 FindClose(sr);
end;

Best way:

function FileSize(const aFilename: String): Int64;
var
 sr : TSearchRec;
begin
 if FindFirst(aFilename, faAnyFile, sr ) = 0 then
 begin
 Result:=Sr.Size;
 end else
 begin
 result := -1;
 end;
 FindClose(sr);
end;