Added initial code.
This commit is contained in:
parent
b20c62c46e
commit
aa8e08afca
27 changed files with 565 additions and 8 deletions
14
LICENSE
14
LICENSE
|
@ -1,7 +1,7 @@
|
||||||
GNU GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC LICENSE
|
||||||
Version 3, 29 June 2007
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
@ -208,25 +208,25 @@ If you develop a new program, and you want it to be of the greatest possible use
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
lazy-code
|
code_snippets
|
||||||
Copyright (C) 2024 eplots
|
Copyright (C) 2023 eplots
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
lazy-code Copyright (C) 2024 eplots
|
code_snippets Copyright (C) 2023 eplots
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
|
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <https://www.gnu.org/licenses/>.
|
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <https://www.gnu.org/philosophy/why-not-lgpl.html>.
|
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
# lazy-code
|
# lazy-code
|
||||||
|
|
||||||
A collection of lazy-code for making my life easier (sometimes)...
|
A collection of lazy-code for making my life easier (sometimes)...
|
||||||
|
|
26
bash/deploy-hugo.sh
Normal file
26
bash/deploy-hugo.sh
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
echo 'Checking if Hugo Docker development server is running...'
|
||||||
|
echo 'If nothing happens after this, start the development server using:'
|
||||||
|
echo 'docker run -p 1313:1313 --rm -v /opt/containers/hugo/site/:/src --name hugo klakegg/hugo:0.111-3-ext-alpine server'
|
||||||
|
|
||||||
|
if [ -n "$(docker ps -f "name=hugo" -f "status=running" -q )" ]; then
|
||||||
|
while true; do
|
||||||
|
read -p "Do you want to build the website? " yn
|
||||||
|
case $yn in
|
||||||
|
[Yy]* ) docker exec -it hugo hugo build; break;;
|
||||||
|
[Nn]* ) exit;;
|
||||||
|
* ) echo "Please answer yes or no.";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
read -p "Do you want to upload the website? " yn
|
||||||
|
case $yn in
|
||||||
|
[Yy]* ) scp -q -r /opt/containers/hugo/site/public/* websrv:/home/eplots/eplots.xyz/blog/static/; break;;
|
||||||
|
[Nn]* ) exit;;
|
||||||
|
* ) echo "Please answer yes or no.";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
echo "Done!"
|
||||||
|
fi
|
4
bash/reset-websrv.sh
Normal file
4
bash/reset-websrv.sh
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# One-liner to reset websrv
|
||||||
|
sed -i '/^185.193.125.246/ d' ~/.ssh/known_hosts && cat ~/.ssh/websrv.pub | xclip -sel c
|
3
bash/sb-vpn
Normal file
3
bash/sb-vpn
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
ip -o -4 a show tun0 | awk '/inet 10\./ {print $4}' | cut -d'/' -f1
|
10
bash/scp-dir.sh
Normal file
10
bash/scp-dir.sh
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Store destination paths in variables
|
||||||
|
nasty="eplots@192.168.50.212:~/NASty/hackz"
|
||||||
|
|
||||||
|
# Parse directory path to get directory name only and store it in a variable
|
||||||
|
dir="$(basename $2)"
|
||||||
|
|
||||||
|
# If $1 variable equals "NASty", format SCP to copy dir ($2) to NASty:
|
||||||
|
[ "$1" == nasty ] && scp -P 1886 -r "$2" "$nasty"/"$dir"
|
10
bash/scp-file.sh
Normal file
10
bash/scp-file.sh
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Store destination path in variable
|
||||||
|
nasty="eplots@192.168.50.212:~/NASty/hackz"
|
||||||
|
|
||||||
|
# Parse filepath to get filename only and store in variable
|
||||||
|
file="$(basename $2)"
|
||||||
|
|
||||||
|
# If $1 variable equals "nasty", format SCP to copy file ($2) to NASty:
|
||||||
|
[ "$1" == nasty ] && scp -P 1886 "$2" "$nasty"/"$file"
|
4
bash/webp.sh
Normal file
4
bash/webp.sh
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# One-liner to convert all *.png to *.webp
|
||||||
|
for x in ls *.png; do cwebp -q 80 $x -o ${x%.png}.webp; done
|
37
mssql/SUP-7719.sql
Normal file
37
mssql/SUP-7719.sql
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
Control code that should be run after the year.
|
||||||
|
This control goes against case SUP-7719.
|
||||||
|
Probably need to check the dates below before running it.
|
||||||
|
|
||||||
|
Save this file for future questions, especially when updating.
|
||||||
|
*/
|
||||||
|
|
||||||
|
USE FAST2;
|
||||||
|
|
||||||
|
DECLARE @fomdat VARCHAR(8)
|
||||||
|
DECLARE @tomdat VARCHAR(8)
|
||||||
|
DECLARE @uppldat VARCHAR(8)
|
||||||
|
|
||||||
|
SET @fomdat = '20220101'
|
||||||
|
SET @tomdat = '20220401'
|
||||||
|
SET @uppldat = '20221201'
|
||||||
|
|
||||||
|
SELECT DISTINCT *
|
||||||
|
FROM ((((avr a
|
||||||
|
INNER JOIN pr p
|
||||||
|
ON a.avr_avtnr = p.pr_avtnr)
|
||||||
|
INNER JOIN obj o
|
||||||
|
ON a.avr_objnr = o.obj_objnr)
|
||||||
|
INNER JOIN pr pr_hg1
|
||||||
|
ON a.avr_avtnr = pr_hg1.pr_avtnr)
|
||||||
|
INNER JOIN pku u
|
||||||
|
ON p.pr_kundnr = u.pku_kundnr)
|
||||||
|
INNER JOIN pku pku_hg1
|
||||||
|
ON pr_hg1.pr_kundnr = pku_hg1.pku_kundnr
|
||||||
|
INNER JOIN spin s
|
||||||
|
ON p.pr_avtnr = s.spin_parent_key
|
||||||
|
WHERE (a.avr_fomdat BETWEEN @fomdat AND @tomdat)
|
||||||
|
AND ( o.obj_obotyp LIKE 'P%'
|
||||||
|
OR o.obj_obotyp LIKE 'G%')
|
||||||
|
AND a.avr_tomdat = 'TV'
|
||||||
|
AND a.avr_uppldat >= @uppldat
|
33
mssql/avtals_forhandlingar.sql
Normal file
33
mssql/avtals_forhandlingar.sql
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
SELECT
|
||||||
|
OBJ.OBJ_OBJNR AS 'Objektsnr',
|
||||||
|
PKU.PKU_HNAMN AS 'Hyresgäst',
|
||||||
|
OBJ.OBJ_GYTA AS 'Yta kvm',
|
||||||
|
AVR.AVR_NORMALHYRAMAN AS 'Årshyra',
|
||||||
|
AVR.AVR_FOMDAT AS 'Avtal startdatum',
|
||||||
|
AVR.AVR_TOMDAT AS 'Avtal t o m',
|
||||||
|
AVR.AVR_KONTRAKTSLUT AS 'Kontraktslut',
|
||||||
|
AVR.AVR_AVRFRL AS 'Förlängningstid',
|
||||||
|
AVR.AVR_UPSTID AS 'Uppsägningstid'
|
||||||
|
FROM
|
||||||
|
AVR
|
||||||
|
INNER JOIN OBJ ON AVR.AVR_OBJNR = OBJ.OBJ_OBJNR
|
||||||
|
INNER JOIN OBT ON OBJ.OBJ_OBOTYP = OBT.OBT_OBOTYP
|
||||||
|
AND OBJ.OBJ_OBJTYP = OBT.OBT_OBJTYP
|
||||||
|
INNER JOIN OBO ON OBJ.OBJ_OBOTYP = OBO.OBO_OBOTYP
|
||||||
|
INNER JOIN BG ON OBJ.OBJ_BYGNR = BG.BG_BYGNR
|
||||||
|
AND OBJ.OBJ_FASTNR = BG.BG_FASTNR
|
||||||
|
INNER JOIN FT ON BG.BG_FASTNR = FT.FT_FASTNR
|
||||||
|
LEFT OUTER JOIN PKU ON AVR.AVR_KUNDNRINFLYTT = PKU.PKU_KUNDNR
|
||||||
|
LEFT OUTER JOIN PKU PKU_A ON AVR.AVR_KUNDNRHG2INFLYTT = PKU_A.PKU_KUNDNR
|
||||||
|
WHERE
|
||||||
|
(
|
||||||
|
AVR.AVR_OBJNR > ''
|
||||||
|
AND (AVR.AVR_OBJNR) IS NOT NULL
|
||||||
|
)
|
||||||
|
AND AVR.AVR_KORR = 'N'
|
||||||
|
AND FT.FT_BESK LIKE 'Niten 11'
|
||||||
|
AND OBJ.OBJ_OBOTYP LIKE 'L%'
|
||||||
|
AND PKU.PKU_HNAMN != 'HG AVIDENTIFIERAD'
|
||||||
|
AND AVR.AVR_TOMDAT = 'TV'
|
||||||
|
ORDER BY
|
||||||
|
Objektsnr ASC
|
3
mssql/check_xp_cmdshell.sql
Normal file
3
mssql/check_xp_cmdshell.sql
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
SELECT CONVERT(INT, ISNULL(value, value_in_use)) AS config_value
|
||||||
|
FROM sys.configurations
|
||||||
|
WHERE name = 'xp_cmdshell' ;
|
25
mssql/clean_numbers.sql
Normal file
25
mssql/clean_numbers.sql
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
Hur man tar bort alla andra tecken förutom siffror i en query.
|
||||||
|
*/
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
CAST(
|
||||||
|
CAST(
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
SUBSTRING(PKU_TFNOVR, Number, 1)
|
||||||
|
FROM
|
||||||
|
master..spt_values
|
||||||
|
WHERE
|
||||||
|
Type = 'p'
|
||||||
|
AND Number <= LEN(PKU_TFNOVR)
|
||||||
|
AND SUBSTRING(PKU_TFNOVR, Number, 1) LIKE '[0-9]' FOR XML PATH('')
|
||||||
|
) AS xml
|
||||||
|
) AS VARCHAR(MAX)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
FROM
|
||||||
|
PKU
|
||||||
|
)
|
20
mssql/datatypes.sql
Normal file
20
mssql/datatypes.sql
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
SELECT
|
||||||
|
[Name] = c.[name]
|
||||||
|
, [Type] =
|
||||||
|
CASE
|
||||||
|
WHEN tp.[name] IN ('varchar', 'char', 'varbinary') THEN tp.[name] + '(' + IIF(c.max_length = -1, 'max', CAST(c.max_length AS VARCHAR(25))) + ')'
|
||||||
|
WHEN tp.[name] IN ('nvarchar','nchar') THEN tp.[name] + '(' + IIF(c.max_length = -1, 'max', CAST(c.max_length / 2 AS VARCHAR(25)))+ ')'
|
||||||
|
WHEN tp.[name] IN ('decimal', 'numeric') THEN tp.[name] + '(' + CAST(c.[precision] AS VARCHAR(25)) + ', ' + CAST(c.[scale] AS VARCHAR(25)) + ')'
|
||||||
|
WHEN tp.[name] IN ('datetime2') THEN tp.[name] + '(' + CAST(c.[scale] AS VARCHAR(25)) + ')'
|
||||||
|
ELSE tp.[name]
|
||||||
|
END
|
||||||
|
, [RawType] = tp.[name]
|
||||||
|
, [MaxLength] = c.max_length
|
||||||
|
, [Precision] = c.[precision]
|
||||||
|
, [Scale] = c.scale
|
||||||
|
, [IsNullable] = c.is_nullable
|
||||||
|
FROM sys.tables t
|
||||||
|
JOIN sys.schemas s ON t.schema_id = s.schema_id
|
||||||
|
JOIN sys.columns c ON t.object_id = c.object_id
|
||||||
|
JOIN sys.types tp ON c.user_type_id = tp.user_type_id
|
||||||
|
WHERE s.[name] = 'dbo' AND t.[name] = 'FN'
|
22
mssql/duplicate_values.sql
Normal file
22
mssql/duplicate_values.sql
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
USE FAST2;
|
||||||
|
|
||||||
|
--real_estate:
|
||||||
|
SELECT ft_fastnr,
|
||||||
|
COUNT(*)
|
||||||
|
FROM ft
|
||||||
|
GROUP BY ft_fastnr
|
||||||
|
HAVING COUNT(*) > 1
|
||||||
|
|
||||||
|
--building:
|
||||||
|
SELECT bg_bygnr,
|
||||||
|
COUNT(*)
|
||||||
|
FROM bg
|
||||||
|
GROUP BY bg_bygnr
|
||||||
|
HAVING COUNT(*) > 1
|
||||||
|
|
||||||
|
--object:
|
||||||
|
SELECT obj_objnr,
|
||||||
|
COUNT(*)
|
||||||
|
FROM obj
|
||||||
|
GROUP BY obj_objnr
|
||||||
|
HAVING COUNT(*) > 1
|
30
mssql/kopoang.sql
Normal file
30
mssql/kopoang.sql
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
KÖTID FRÅN BOKÖ TILLS MAN SKRIVIT AVTAL. EJ INFLYTTNING!
|
||||||
|
VILKEN SORTERING/GRUPPERING SKALL DET VARA?
|
||||||
|
VILKA PARAMETRAR SKALL SÄTTAS UPP?
|
||||||
|
VEM FIXAR LAYOUTEN?
|
||||||
|
*/
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
OBJ.OBJ_OBOTYP,
|
||||||
|
OBJ.OBJ_OBJNR,
|
||||||
|
OBJ.OBJ_BOSOK1_OMR_BCD,
|
||||||
|
CAST(LEFT(RIGHT(SPIN_TEXT, LEN(SPIN_TEXT) - CHARINDEX('inflyttning: ', SPIN_TEXT, 1) - 12),8) AS DATE) AS 'Ködatum',
|
||||||
|
CAST(SPIN_DATESTAMP_NY AS DATE) AS 'Borttagen',
|
||||||
|
DATEDIFF(dd,CAST(LEFT(RIGHT(SPIN_TEXT, LEN(SPIN_TEXT) - CHARINDEX('inflyttning: ', SPIN_TEXT, 1) - 12), 8) AS DATE),CAST(SPIN_DATESTAMP_NY AS DATE)) AS dagar
|
||||||
|
--AVG(DATEDIFF(dd,CAST(LEFT(RIGHT(SPIN_TEXT, LEN(SPIN_TEXT) - CHARINDEX('inflyttning: ', SPIN_TEXT, 1) - 12), 8) AS DATE),CAST(SPIN_DATESTAMP_NY AS DATE))) AS 'snitt'
|
||||||
|
FROM
|
||||||
|
SPIN
|
||||||
|
INNER JOIN PKU ON SPIN.SPIN_PARENT_KEY = PKU_KUNDNRINTERN
|
||||||
|
INNER JOIN OBJ ON PKU.PKU_KUNDNR = OBJ.OBJ_KUNDNR
|
||||||
|
WHERE
|
||||||
|
SPIN_SOKNAMN LIKE 'Borttagen%'
|
||||||
|
AND SPIN_TEXT LIKE '%Köplats%borttagen%inflyttning%'
|
||||||
|
AND SPIN_TYP = 'BOKO'
|
||||||
|
AND YEAR(SPIN_DATESTAMP_NY) >= '2022'
|
||||||
|
AND OBJ.OBJ_OBJTYP LIKE 'B%'
|
||||||
|
--AND SPIN_TEXT LIKE '%intern:62120%' -- Alex interna kundnr
|
||||||
|
|
||||||
|
SELECT TOP 1 * FROM SPIN WHERE SPIN_TYP = 'BOKO' AND SPIN_SOKNAMN LIKE 'Borttagen%'
|
||||||
|
|
||||||
|
SELECT * FROM SPIN WHERE SPIN_PARENT_KEY = '62120'
|
46
mssql/moms_koll.sql
Normal file
46
mssql/moms_koll.sql
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
USE FAST2;
|
||||||
|
|
||||||
|
-- Företag som parameter?
|
||||||
|
|
||||||
|
SELECT DISTINCT o.OBJ_OBJNR,
|
||||||
|
o.OBJ_OBJTYP,
|
||||||
|
o.OBJ_ADR,
|
||||||
|
o.OBJ_HNAMN,
|
||||||
|
o.OBJ_MOMSMARK,
|
||||||
|
r.AVR_MOMSPL,
|
||||||
|
p.PKO_PKT_MOMSKOD
|
||||||
|
FROM OBJ o
|
||||||
|
INNER JOIN AVT h ON o.OBJ_AVTNR = h.AVT_AVTNR
|
||||||
|
INNER JOIN AVR r ON h.AVT_AVTNR = r.AVR_AVTNR
|
||||||
|
INNER JOIN PKO p ON o.OBJ_OBJNR = p.PKO_OBJNR
|
||||||
|
WHERE o.OBJ_OBOTYP NOT LIKE 'P%'
|
||||||
|
AND o.OBJ_HNAMN NOT IN ('PROJEKT', 'RENOVERING')
|
||||||
|
--AND o.OBJ_FTGNR = 'EHB'
|
||||||
|
AND o.OBJ_OBOTYP NOT LIKE 'G%'
|
||||||
|
AND o.OBJ_AVTNR != '999999999'
|
||||||
|
AND p.PKO_PKTYP NOT IN ('3614', 'VVMJUST', 'KVMJUST', 'ELBJUST', 'VVMSCHAB', 'KVMSCHAB', 'TFVATT', 'T880')
|
||||||
|
AND p.PKO_PKTYP NOT LIKE 'HBO%'
|
||||||
|
AND p.PKO_HTYP = 'HYRA'
|
||||||
|
AND (p.PKO_TOMDAT >= CONVERT(VARCHAR(8), GETDATE(), 112) OR p.PKO_TOMDAT = 'TV')
|
||||||
|
AND o.OBJ_OBJNR = r.AVR_OBJNR
|
||||||
|
AND NOT (o.OBJ_MOMSMARK = 'N' AND r.AVR_MOMSPL = 'N' AND (p.PKO_PKT_MOMSKOD = '0' OR p.PKO_PKT_MOMSKOD = 'MOMSFR'))
|
||||||
|
AND NOT (o.OBJ_MOMSMARK = 'J' AND r.AVR_MOMSPL = 'J' AND p.PKO_PKT_MOMSKOD = 'FULLMO')
|
||||||
|
AND (
|
||||||
|
OBJ_IAKTDAT IS NULL
|
||||||
|
OR OBJ_IAKTDAT = ''
|
||||||
|
OR OBJ_IAKTDAT >= CONVERT(
|
||||||
|
VARCHAR(8),
|
||||||
|
GETDATE(),
|
||||||
|
112
|
||||||
|
)
|
||||||
|
)
|
||||||
|
AND (
|
||||||
|
OBJ_FORSALJDATUM IS NULL
|
||||||
|
OR OBJ_FORSALJDATUM = ''
|
||||||
|
OR OBJ_FORSALJDATUM >= CONVERT(
|
||||||
|
VARCHAR(8),
|
||||||
|
GETDATE(),
|
||||||
|
112
|
||||||
|
)
|
||||||
|
)
|
||||||
|
ORDER BY o.OBJ_OBJNR
|
6
mssql/search_for_columns.sql
Normal file
6
mssql/search_for_columns.sql
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
SELECT c.name AS ColName,
|
||||||
|
t.name AS TableName
|
||||||
|
FROM sys.columns c
|
||||||
|
JOIN sys.tables t
|
||||||
|
ON c.object_id = t.object_id
|
||||||
|
WHERE c.name LIKE '%FU_STATUS%'
|
18
mssql/tmp_tbl.sql
Normal file
18
mssql/tmp_tbl.sql
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
/*
|
||||||
|
Hur man skapar en temptabell i minnet på databasen.
|
||||||
|
*/
|
||||||
|
|
||||||
|
--visible only to me, in memory (SQL 2000 and above only)
|
||||||
|
declare @test table (
|
||||||
|
FOL_RSN bigint,
|
||||||
|
FOL_ID bigint,
|
||||||
|
FOL_BESK VARCHAR(50),
|
||||||
|
FOL_VISAS CHAR(1)
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO @test (FOL_RSN, FOL_ID, FOL_BESK, FOL_VISAS) --VALUES (1,1,'asdf',1)
|
||||||
|
|
||||||
|
SELECT * FROM FU_ORIGIN_LIST AS a
|
||||||
|
|
||||||
|
|
||||||
|
SELECT * FROM @test
|
17
mssql/ue_ao_dump.sql
Normal file
17
mssql/ue_ao_dump.sql
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
USE FAST2;
|
||||||
|
|
||||||
|
SELECT f.FU_FELRADNR AS 'ao_nr',
|
||||||
|
f.FU_REGDAT AS 'reg_datum',
|
||||||
|
s.SPIN_SOKNAMN AS 'spin_rubrik',
|
||||||
|
s.SPIN_DATESTAMP_NY AS 'spin_tid',
|
||||||
|
s.SPIN_IDSTAMP_NY AS 'spin_id',
|
||||||
|
REPLACE(REPLACE(s.SPIN_TEXT, CHAR(13), ''), CHAR(10), '') AS 'spin_text',
|
||||||
|
FROM FU f
|
||||||
|
INNER JOIN SPIN s ON f.FU_FELRADNR = s.SPIN_PARENT_KEY
|
||||||
|
WHERE f.FU_RESURS = 'BUNECO'
|
||||||
|
AND f.FU_REGDAT BETWEEN '20230401' AND '20240111'
|
||||||
|
AND s.SPIN_TYP NOT IN ('AOEPOSTPKU', 'AOSMSPKU', 'AOSENT')
|
||||||
|
AND s.SPIN_TEXT NOT IN ('Registrerad')
|
||||||
|
AND s.SPIN_TEXT NOT LIKE '%Föregående utförare: %'
|
||||||
|
AND s.SPIN_TEXT NOT LIKE '%Ny utförare: %'
|
||||||
|
ORDER BY ao_nr ASC
|
19
nvim/ExportMarkdownToPDF.vim
Normal file
19
nvim/ExportMarkdownToPDF.vim
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
function! ExportMarkdownToPDF()
|
||||||
|
let l:input_file = expand('%') " Hämtar det aktuella filnamnet
|
||||||
|
let l:output_file = input('Ange filnamn för PDF: ', expand('%:r') . '.pdf', 'file')
|
||||||
|
if l:output_file == ''
|
||||||
|
echo 'Inget filnamn angivet. Export avbruten.'
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
let l:command = 'python3 /path/to/your/script/md_to_pdf.py ' . shellescape(l:input_file, 1) . ' ' . shellescape(l:output_file, 1)
|
||||||
|
execute '!' . l:command
|
||||||
|
echo 'PDF genererad: ' . l:output_file
|
||||||
|
" Lägg till ett kommando för att öppna PDF med Zathura
|
||||||
|
if filereadable(l:output_file)
|
||||||
|
silent execute '!zathura ' . shellescape(l:output_file, 1) . ' &'
|
||||||
|
redraw!
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
command! ExportToPDF call ExportMarkdownToPDF()
|
||||||
|
nnoremap <F7> :ExportToPDF<CR>
|
2
nvim/PythonCodeInNvim.vim
Normal file
2
nvim/PythonCodeInNvim.vim
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
autocmd FileType python map <buffer> <F9> :w<CR>:exec '!python3' shellescape(@%, 1)<CR>
|
||||||
|
autocmd FileType python imap <buffer> <F9> <esc>:w<CR>:exec '!python3' shellescape(@%, 1)<CR>
|
5
powershell/jasper-kontroll.ps1
Normal file
5
powershell/jasper-kontroll.ps1
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
$datum = Get-Date -Format "yyyy-MM-dd"; $path = "C:\din\mapp\sökväg"; $outputFile = "C:\sökväg\till\jasper-resultat-$datum.md"; "Filename | Last Modified Time", "-------- | -----------------" | Set-Content $outputFile; Get-ChildItem -Path $path -Filter *.jasper | Sort-Object LastWriteTime -Descending | ForEach-Object { "$($_.Name) | $($_.LastWriteTime)" | Add-Content $outputFile }
|
||||||
|
|
||||||
|
$datum = Get-Date -Format "yyyy-MM-dd"; $path = "C:\din\mapp\sökväg"; $outputFile = "C:\sökväg\till\jasper-resultat-$datum.md"; "| Filename | Last Modified Time |", "| -------- | ----------------- |" | Set-Content $outputFile; Get-ChildItem -Path $path -Filter *.jasper | Sort-Object LastWriteTime -Descending | ForEach-Object { "| $($_.Name) | $($_.LastWriteTime) |" | Add-Content $outputFile }
|
||||||
|
|
||||||
|
Compare-Object (Get-Content "C:\sökväg\till\fil1.md") (Get-Content "C:\sökväg\till\fil2.md") | Where-Object { $_.SideIndicator -ne '==' } | ForEach-Object { if ($_.SideIndicator -eq '<=') {"File1: $($_.InputObject)"} else {"File2: $($_.InputObject)"} } | Set-Content "C:\sökväg\till\diffresultat.md"
|
5
powershell/jasper-rapporter.ps1
Normal file
5
powershell/jasper-rapporter.ps1
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# Production-server:
|
||||||
|
$datum = Get-Date -Format "yyyy-MM-dd"; $path = "\\appsrv31\Rapport"; $outputFile = "C:\Users\patsto\Desktop\produktions-jasper-$datum.md"; "| Filename | Last Modified Time |", "| --- | --- |" | Set-Content $outputFile; Get-ChildItem -Path $path -Filter *.jasper | Sort-Object LastWriteTime -Descending | ForEach-Object { "| $($_.Name) | $($_.LastWriteTime) |" | Add-Content $outputFile }
|
||||||
|
|
||||||
|
# Testing-server:
|
||||||
|
$datum = Get-Date -Format "yyyy-MM-dd"; $path = "\\tst-appsrv31\Rapport"; $outputFile = "C:\Users\patsto\Desktop\produktions-jasper-$datum.md"; "| Filename | Last Modified Time |", "| --- | --- |" | Set-Content $outputFile; Get-ChildItem -Path $path -Filter *.jasper | Sort-Object LastWriteTime -Descending | ForEach-Object { "| $($_.Name) | $($_.LastWriteTime) |" | Add-Content $outputFile }
|
124
python/md_to_pdf.py
Normal file
124
python/md_to_pdf.py
Normal file
|
@ -0,0 +1,124 @@
|
||||||
|
import markdown
|
||||||
|
from weasyprint import HTML, CSS
|
||||||
|
import sys
|
||||||
|
import re
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
def extract_date(markdown_text):
|
||||||
|
# Försök att hitta ett datum i formatet "Datum: YYYY-MM-DD"
|
||||||
|
match = re.search(r'\*\*Datum\*\*:\s*(\d{4}-\d{2}-\d{2})', markdown_text)
|
||||||
|
return match.group(1) if match else datetime.now().strftime('%Y-%m-%d')
|
||||||
|
|
||||||
|
def markdown_to_pdf(input_file, output_file):
|
||||||
|
# Läs markdown från fil
|
||||||
|
with open(input_file, 'r', encoding='utf-8') as file:
|
||||||
|
markdown_text = file.read()
|
||||||
|
|
||||||
|
# Extrahera datumet
|
||||||
|
date = extract_date(markdown_text)
|
||||||
|
|
||||||
|
# Konvertera markdown till HTML
|
||||||
|
html_text = markdown.markdown(markdown_text, extensions=['tables'])
|
||||||
|
|
||||||
|
# HTML-mall med anpassad teckenstorlek
|
||||||
|
html_template = f"""
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
@page {{
|
||||||
|
size: A4;
|
||||||
|
margin: 30mm 20mm 30mm 20mm; /* Top, Right, Bottom, Left margins */
|
||||||
|
}}
|
||||||
|
body {{
|
||||||
|
font-family: 'Arial';
|
||||||
|
padding: 13.2px;
|
||||||
|
font-size: 11px; /* Standardstorlek för brödtext */
|
||||||
|
}}
|
||||||
|
h1 {{
|
||||||
|
font-size: 24px; /* Storlek för H1 rubriker */
|
||||||
|
color: #e47203;
|
||||||
|
}}
|
||||||
|
h2 {{
|
||||||
|
font-size: 20px; /* Storlek för H2 rubriker */
|
||||||
|
color: #2b979f;
|
||||||
|
}}
|
||||||
|
h3 {{
|
||||||
|
font-size: 16px; /* Storlek för H3 rubriker */
|
||||||
|
color: #000000;
|
||||||
|
}}
|
||||||
|
#header {{
|
||||||
|
position: fixed;
|
||||||
|
left: -10mm;
|
||||||
|
top: -20mm;
|
||||||
|
text-align: left;
|
||||||
|
}}
|
||||||
|
#header img {{
|
||||||
|
width: 52.5mm;
|
||||||
|
height: auto;
|
||||||
|
opacity: 0.5;
|
||||||
|
}}
|
||||||
|
#date {{
|
||||||
|
position: fixed;
|
||||||
|
right: -10mm;
|
||||||
|
top: -20mm;
|
||||||
|
font-size: 7px;
|
||||||
|
opacity: 0.5;
|
||||||
|
}}
|
||||||
|
#date .label {{
|
||||||
|
color: orange;
|
||||||
|
}}
|
||||||
|
#date .value {{
|
||||||
|
color: black;
|
||||||
|
}}
|
||||||
|
ul, ol {{
|
||||||
|
padding-left: 20px; /* Justera detta värde för att kontrollera indraget för hela listan */
|
||||||
|
}}
|
||||||
|
ul ul, ol ol {{
|
||||||
|
padding-left: 10px; /* Justera detta värde för att kontrollera indraget för nestlade listor */
|
||||||
|
}}
|
||||||
|
li {{
|
||||||
|
margin-bottom: 3px; /* Ger ett litet mellanrum mellan listpunkter */
|
||||||
|
}}
|
||||||
|
}}
|
||||||
|
table {{
|
||||||
|
border-collapse: collapse;
|
||||||
|
width: 100%;
|
||||||
|
margin-bottom: 20px; /* Lägg till utrymme under tabellerna */
|
||||||
|
}}
|
||||||
|
th, td {{
|
||||||
|
border: 1px solid #ddd; /* Lätt grå kantlinje */
|
||||||
|
padding: 8px; /* Tillräckligt med utrymme för cellinnehållet */
|
||||||
|
text-align: left; /* Vänsterjustera all text i cellerna */
|
||||||
|
}}
|
||||||
|
th {{
|
||||||
|
background-color: #f2f2f2; /* Ljusgrå bakgrundsfärg för rubriker */
|
||||||
|
font-weight: bold;
|
||||||
|
}}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id='header'>
|
||||||
|
<img src='https://www.kfast.se/wp-content/themes/kfast-theme%201.0.1.3.6/images/KFast_Logotype_webb@2x.png'>
|
||||||
|
</div>
|
||||||
|
<div id='date'>
|
||||||
|
{f'<span class="label">DATUM:</span> <span class="value">{date}</span>' if date else ""} <br>
|
||||||
|
Eskilstuna Kommunfastigheter AB
|
||||||
|
</div>
|
||||||
|
{html_text}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Generera PDF
|
||||||
|
html = HTML(string=html_template)
|
||||||
|
html.write_pdf(output_file)
|
||||||
|
|
||||||
|
print(f"PDF-filen {output_file} har skapats.")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
if len(sys.argv) != 3:
|
||||||
|
print("Användning: python script.py input.md output.pdf")
|
||||||
|
else:
|
||||||
|
input_filepath = sys.argv[1]
|
||||||
|
output_filepath = sys.argv[2]
|
||||||
|
markdown_to_pdf(input_filepath, output_filepath)
|
33
python/ssh_honeypot.py
Normal file
33
python/ssh_honeypot.py
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import socket
|
||||||
|
import paramiko
|
||||||
|
import threading
|
||||||
|
|
||||||
|
class SSHServer(paramiko.ServerInterface):
|
||||||
|
|
||||||
|
def check_auth_password(self, username: str, password: str) -> int:
|
||||||
|
print(f'{username}:{password}')
|
||||||
|
return paramiko.AUTH_FAILED
|
||||||
|
|
||||||
|
def handle_connection(client_sock):
|
||||||
|
transport = paramiko.Transport(client_sock)
|
||||||
|
server_key = paramiko.RSAKey.from_private_key_file('key')
|
||||||
|
transport.add_server_key(server_key)
|
||||||
|
ssh = SSHServer()
|
||||||
|
transport.start_server(server=ssh)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
server_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
server_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
|
server_sock.bind(('', 2222))
|
||||||
|
server_sock.listen(100)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
client_sock, client_addr = server_sock.accept()
|
||||||
|
print(f'Connection from {client_addr[0]}:{client_addr[1]}')
|
||||||
|
t = threading.Thread(target=handle_connection, args=(client_sock,))
|
||||||
|
t.start()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
51
python/taskwarrior-task2cal.py
Normal file
51
python/taskwarrior-task2cal.py
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from tasklib import TaskWarrior
|
||||||
|
import sys
|
||||||
|
|
||||||
|
tw = TaskWarrior('~/.local/share/task/')
|
||||||
|
|
||||||
|
# Parse appointments
|
||||||
|
apts = tw.tasks.filter('(status:pending or status:waiting or status:completed)', type='cal')
|
||||||
|
for apt in apts:
|
||||||
|
start = apt['scheduled']
|
||||||
|
if start is None:
|
||||||
|
sys.stderr.write(f"Apt '{apt}' has no sched date!\n")
|
||||||
|
continue
|
||||||
|
|
||||||
|
summary = str(apt)
|
||||||
|
|
||||||
|
if start.hour == 0 and start.minute == 0:
|
||||||
|
start_fmt = start.strftime("%m/%d/%Y")
|
||||||
|
print(f"{start_fmt} [1] {summary}")
|
||||||
|
else:
|
||||||
|
start_fmt = start.strftime("%m/%d/%Y @ %H:%M")
|
||||||
|
|
||||||
|
if apt['due']:
|
||||||
|
end_fmt = apt['due'].strftime("%m/%d/%Y @ %H:%M")
|
||||||
|
else:
|
||||||
|
end_fmt = strt_fmt
|
||||||
|
|
||||||
|
print(f"{start_fmt} -> {end_fmt}|{summary}")
|
||||||
|
|
||||||
|
# Parse due dates for next actions and projects
|
||||||
|
tasks = tw.tasks.filter('(status:pending or status:waiting) and (type:next or type:objective or type:standby)')
|
||||||
|
|
||||||
|
for task in tasks:
|
||||||
|
for date_type, label in [('due', "Slutdatum: "),
|
||||||
|
('scheduled', "Startdatum: ")]:
|
||||||
|
if not task[date_type]: # Skip tasks with no date
|
||||||
|
continue
|
||||||
|
start = task[date_type]
|
||||||
|
|
||||||
|
proj = "Project: " if task['type'] == "objective" else ""
|
||||||
|
|
||||||
|
summary = label + proj + str(task)
|
||||||
|
|
||||||
|
if start.hour == 0 and start.minute == 0:
|
||||||
|
start_fmt = start.strftime("%m/%d/%Y")
|
||||||
|
print(f"{start_fmt} [1] {summary}")
|
||||||
|
else:
|
||||||
|
start_fmt = start.strftime("%m/%d/%Y @ %H:%M")
|
||||||
|
end_fmt = start_fmt
|
||||||
|
print(f"{start_fmt} -> {end_fmt}|{summary}")
|
4
sqlite3/newsboat-reset.sql
Normal file
4
sqlite3/newsboat-reset.sql
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
-- Reset entire rss-feed
|
||||||
|
UPDATE rss_item
|
||||||
|
SET unread = 1
|
||||||
|
WHERE feedurl = '' -- get from urls file
|
Loading…
Reference in a new issue