Skip to content

Instantly share code, notes, and snippets.

View scanbix's full-sized avatar

Mindaugas scanbix

View GitHub Profile
sql%rowcount
dbms_output.put_line('Number of lines affected by previous DML operation:'||sql%rowcount);
#https://oracle-base.com/articles/9i/merge-statement
MERGE INTO employees e
USING hr_records h
ON (e.id = h.emp_id)
WHEN MATCHED THEN
UPDATE SET e.address = h.address
WHEN NOT MATCHED THEN
INSERT (id, address)
VALUES (h.emp_id, h.address);
@scanbix
scanbix / Windows 11 cleanup.ps1
Created September 30, 2023 17:08
Windows 11 cleanup
# Remove the installed package for each user "Disable Widgets in Windows 11 Completely"
Get-AppxPackage -AllUsers | Where-Object {$_.Name -like "*WebExperience*"} | Remove-AppxPackage -AllUsers -ErrorAction SilentlyContinue
$LASTEXITCODE. It will always be the exit code of the last program you ran in the current session.
$LastExitCode is the return code of native applications. $? just returns True or False depending on whether the last command (cmdlet or native) exited without error or not.
PowerShell writes its messages to different streams that can be redirected to files for capturing the respective output.
Stream 1 (default): regular output ("STDOUT")
Stream 2: error messages ("STDERR"), including error messages from external programs
Stream 3: warning messages
Stream 4: verbose messages
Stream 5: debug messages
COMMENT ON TABLE,VIEW,SNAPSHOT shipping.notes IS 'Special packing or shipping instructions';
COMMENT ON COLUMN shipping.notes IS 'Special packing or shipping instructions';
python -m venv .venv
.\.venv\Scripts\activate
python -m pip install --upgrade pip
deactivate
python -m pip install -r requirements.txt
python -m pip freeze
-- Deep copy
CREATE OR REPLACE TABLE table1_deep_copy AS SELECT * FROM table1;
-- Shallow copy
CREATE OR REPLACE TABLE table1_shallow_copy LIKE table1;
-- Temporary - for current session. Cannot be cloned.
CREATE TEMPORARY TABLE cust_temp AS SELECT * FROM customers;
-- Transient - multisession, does not use fail-safe storage.
CREATE TRANSIENT TABLE cust_temp AS SELECT * FROM customers;
-- Clone
# powershell
git config --list --show-origin
##
## https://stackoverflow.com/questions/7335420/global-git-ignore
##
# ignore dirs/files in all user's local git repositories
git config --global core.excludesFile "$Env:USERPROFILE\.gitignore"
#review the setting
git config --global core.excludesFile
-- Old powershell version call from command task in infa
powershell -executionpolicy bypass -File "$PMRootDir\check_directory_access_infa.ps1" > "$PMRootDir\check_directory_access_infa.log" 2>&1
-- PowerShell exit sample code
# some logic to set $hasError variable.
if ($hasError) {
Write-Host has errors
exit 1
} else {
@scanbix
scanbix / windows batch snippets
Last active May 26, 2021 09:58
Windows batch snippets
:: Empty file
copy /y NUL EmptyFile.txt >NUL
:: Error handling
somecommand > log.txt 2>&1 | someothercommand
somecommand 2>&1 | someothercommand
:: Check if file exists
if exist \\somefile.txt (
echo file exists