You may optionally enter a comparison operator (<, <=, >, >=, <> or =) at the beginning of each of your search values to specify how the comparison should be done.
Collation (Sortierreihenfolge) einer Datenbank ändern
-- Collation einer Multi-User Datenbank ändern
-- Über SSMS kommt die Fehlermeldung 5030 (Die Datenbank konnte nicht exklusiv gesperrt werden, um den Vorgang auszuführen.)
-- siehe dazu: http://sunali.com/2009/10/08/microsoft-sql-server-error-5030/
-- the following line sets the database to "Single User" mode
ALTER DATABASE MYDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE
-- the following line sets the new collation
ALTER DATABASE MYDB COLLATE Latin1_General_CS_AS
-- the following line sets the database back to "Multi User" mode
ALTER DATABASE MYDB SET MULTI_USER
79
T-SQL
Datenbank, Collation
Datensatz Case-Sesitive abfragen
-- Table containing Values
-- content (column)
-- a
-- A
SELECT content FROM myTable WHERE content='A' COLLATE SQL_Latin1_General_CP1_CS_AS
-- Result: A
78
Delphi
Anwendungskonfigurationsdateien
INI-Datei lesen
uses
IniFiles;
var
iniMem: TMemIniFile; // ini-File (ready only one time)
// Load the ini-information once - maybe at startup
function TMyForm.LoadIniFile:boolean;
var
SL : TStringList;
return : Boolean;
iniFile : String;
begin
iniFile:='myFormConfig.ini';
return:=true;
if not FileExists(ExtractFilePath(Application.Exename)+iniFile) then
begin
MessageDlg('ini-File not found!', mtError, [mbOK], 0);
return:=false;
end;
if not return then halt;
iniMem:=TMemIniFile.Create('');
SL:=TStringList.Create;
SL.LoadFromFile(ExtractFilePath(Application.Exename)+iniFile);
iniMem.SetStrings(SL);
LoadIniFile:=return;
end;
procedure TMyForm.DoThis;
begin
ShowMessage(iniMem.ReadString('Section','Attribute','Default-Value'));
end;
285
Bash Script
Filehandling
Applikations-/Script-Verzeichnis ermitteln
#!/bin/sh
# The script is located in /tmp/abc/myscript.sh
export AppPath=$(dirname $0)
echo $0
# /tmp/abc/myscript.sh
echo $AppPath
# /tmp/abc
77
Delphi
Filehandling
Applikations-/Script-Verzeichnis ermitteln
AppPath:=ExtractFilePath(Application.Exename);
76
Python
Netzwerk, Email
Email versenden
# Found at (and little modified): http://www.semi-legitimate.com/sls/blog/37-quick-notes/62-command-line-smtp-from-python
#!/usr/bin/python
import smtplib, sys
if len(sys.argv) != 5:
print "You must call me like:"
print " mailme from to subject msgfile"
sys.exit()
fromadr = sys.argv[1]
toadr = sys.argv[2]
subject = sys.argv[3]
msgfile = sys.argv[4]
try:
f = open(msgfile)
msg = f.read()
except:
print "Invalid Message File: " + msgfile
sys.exit()
m = "From: %s
To: %s
Subject: %s
X-Mailer: My-Mail
" \
% (fromadr, toadr, subject)
smtpserver="mysmtp.lan"
loginuser="Marty_McFly"
loginpwd="DeLorean"
smtp = smtplib.SMTP()
smtp.connect(smtpserver)
smtp.login(loginuser, loginpwd)
smtp.ehlo()
smtp.sendmail(fromadr, toadr, m+msg)
smtp.close()
73
Delphi
Windows - Prompt Errorlevel
Errorlevel setzen
//...
var
errorlevel: Integer;
begin
if cond1=cond2 then errorlevel:=0;
if cond1<>cond2 then errorlevel:=1;
halt(errorlevel);
end.
72
Delphi
Strings
Replace
procedure foo()
var
str1: String;
begin
str1:=StringReplace('Hello World...','...',[rfReplaceAll, rfIgnoreCase]);
// Output of str1 => "Hello World"
end
201
Excel
Strings
Replace
/*
Cell A1 contains text "abc#def"
*/
=SUBSTITUTE(A1;"*";"/")
/*
Result will be: "abc/def"
*/