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.
$testVar = "OK";
$resultVar;
$resultVar = $testVar=="OK" ? true : false;
// same as if-else construction
if ($testVar == "OK")
{
$resultVar = true;
}
else
{
$resultVar = false;
};
201
Excel
Strings
Replace
/*
Cell A1 contains text "abc#def"
*/
=SUBSTITUTE(A1;"*";"/")
/*
Result will be: "abc/def"
*/
200
JavaScript
Datum, Zeit
Aktuelles Datum/Uhrzeit
date = new Date();
// Sat Jun 14 2014 13:15:27 GMT+0200 (CEST)
dateStringISO = date.toISOString();
// "2014-06-14T11:15:27.097Z" // Attention: Time is different because of the timezone
date.toISOString().substring(0,10);
//"2014-06-14"
dateStringISO.split("T")[1];
// 11:15:27.097Z
199
JavaScript
Strings
String auf Wunschlänge zuschneiden
myString = "abc";
mySubString = myString.substring(0,2);
// ab
198
Batch
Konsolenverwaltung
Einlesen Konsoleneingabe
@echo off
SET mydir=%CD%
set /p number=search this number?:
echo %number% > "%mydir%\lastnumbersearched.txt"
echo dir/b/s *%number%*.*
echo.
echo.
dir/b/s *%number%*.*
echo.
echo.
pause
import json
myJSONFile = "/tmp/Test/myData.json"
json_data = open(myJSONFile)
# In Python werden JSON Daten nach dem Laden wie Dictionaries behandelt
data_dict = json.load(json_data)
195
Python
Exceptions
Exception auslösen
if (a!=b):
raise Exception("Not implemented, yet")
194
Python
Filehandling
Filename-Manipultation Basics
import os
myFilename = "/tmp/Test/myFile.txt"
# Get only the path
path_only = os.path.dirname(myFilename)
# /tmp/Test
# Filename only
filename_only = os.path.basename(myFilename)
# myFile.txt
# get only filename without extention
filename_without_ext = os.path.basename(os.path.splitext(myFilename)[0])
# myFile
# get only the extension
filename_extention_only = os.path.splitext(myFilename)[1]
# .txt
# put them together again
myFilename_together = os.path.join(path_only, filename_without_ext + filename_extention_only)
# /tmp/Test/myFile.txt
193
Python
Array
Dictionary Basics
# empty dict
myDict = {}
# some static values
myDict ={
"key1" : {"item1":"value1"},
"key2" : {"itemX":"valueY"},
"keyX" : {"item99":"value98"}
}
# update a key programmatically
myDict.update({"key1" = {"item2":"new value"}})
# iterate
for (key, subdict) in myDict.items():
current_key = key
current_subdict = subdict
# get an specific item
subdict = myDict.get("key2")
print subdict.get("itemX")
# valueY