Difference between revisions of "Troubleshooting"

From Jesse's Wiki
Jump to navigation Jump to search
Line 5: Line 5:
=== GitHub ===
=== GitHub ===
To delete a release, do not click on "Edit", instead click the release title name. Then the "Delete" button will be available.
To delete a release, do not click on "Edit", instead click the release title name. Then the "Delete" button will be available.
to ignore without using gitignore, open .git and edit the 'exclude' file.


=== Citrix ===
=== Citrix ===

Revision as of 09:16, 26 June 2022

This page aims to record the solutions to obscure problems.

See Installation for all MediaWiki related Troubleshooting

GitHub

To delete a release, do not click on "Edit", instead click the release title name. Then the "Delete" button will be available.

to ignore without using gitignore, open .git and edit the 'exclude' file.

Citrix

Use the web version when possible. To download a file, use the "download" icon which should appear. It may not be possible to use the Windows Explorer interface anymore.

Cryptography

Windows has RijndaelManaged (AES) built in. For some reason I thought it would be my first attempt on learning encrypting/decrypting The method needs an Initial Vector (IV) and a random key. Both of these are generated and used to encrypt. They must be saved with the encrypted data or else it cannot be decrypted. The IV isn't important and can be public. The key should not be public. This is similar to Public-Key cryptography but not the same.

For my purposes I'm just encrypting a password on a local machine

https://crypto.stackexchange.com/questions/3965/what-is-the-main-difference-between-a-key-an-iv-and-a-nonce

https://www.titanwolf.org/Network/q/cc102a94-8ad9-4d8e-8da4-379b6fb92dad/y

https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.rijndaelmanaged?view=net-5.0

Simultaneously I'm learning how to use ADODB stream object for the first time

objStream.Type = 1 'adTypeBinary
	objStream.Open
	objStream.Write(mykey)	
	objStream.savetofile "key"

Make sure the type is set to 1 and Write is used. Both are for binary which is what the AES IV and KEY are.

There is no equivalent function in javascript to find the length of a binary variable like vbscript's Lenb() but I can use ADODB stream to open and write binary and then use the Size method to get the size. The binary length is needed for the TransformFinalBlock method of AES.

HTA

When using HTA to open a vbscipt with cscript.exe, you can communicate directly with the script using the Stdout property. So long as the script was launched using shell.exec method. shell.run method is acceptable but it only returns an error level.

exec method to work needs to have the shell set to an object. blah = shell.exec ( blah blah). Then use blah.Stdout.ReadLine() or ReadAll().

This seems most useful for quick scripts where I want to return a single value. I can't seem to get live updates synchronously with the script as described here

It would be better to have live read outs update to the HTA so the console screen can be avoided entirely, giving the HTA a more "program" feel.


This explains when you want the window to stay open, e.g. use pause for the "press any key to continue" or just keep it alive until they click on the x.


Okay apparently using setInterval in the HTA will allow me to read the Stdout without locking the application...

       setInterval(function(){ document.getElementById(6).innerHTML = blah.StdOut.ReadLine(); }, 1000);

MSDN


But now I can't run the shell minimized or stop it from taking focus.

Run vs Exec comparison [1]

Shell.run needs path in quotes for folders and file names with spaces. FSO requires the path to not have quotes at all.

javascript (and vbscript) is synchronous. Therefore I need to use a web api function to act asynchronously https://www.freecodecamp.org/news/thrown-for-a-loop-understanding-for-loops-and-timeouts-in-javascript-558d8255d8a4/#:~:text=Every%20time%20we%20loop%2C%20setTimeout%20%28%29%20is%20passed,loop%2C%20followed%20by%20console.log%20%28%E2%80%98The%20loop%20is%20done%21%E2%80%99%29.

CScript

Needs to run Win64 version to avoid the error. The wrong version will run if mshta.exe itself is also wrong. Investigate which one is running with task manager. Still cannot force either or to run by default, but a shortcut can be made which specifies the System32 path instead of syswow64

ADODB.Connection: Provider cannot be found. It may not be properly installed.

Bash Shell

Here's me trying to rename tv shows...

https://wiki.bash-hackers.org/syntax/pattern

for file in *.mp4; do echo mv "$file" "${file//./ }"; done

for file in *.mp4; do echo mv "$file" "${file//.[!.mp4]/ }"; done

for file in *.mp4; do echo mv "$file" "${file[^.mp4]}"; done

for file in *.mp4; do echo mv "$file" "${file/*.S??E*/ }"; done




for file in *.mp4; do echo mv "$file" "${file/.S??E??*}"; done

for file in *.mp4; do echo mv "$file" "${file/.S??E??*/${file%S??E??}}"; done

for file in *.mp4; do echo mv "$file" "${file%%.S??E??*}"; done

for file in *.mp4; do echo mv "$file" "${file%%\?*}"; done

.HTACCESS

https://httpd.apache.org/docs/current/mod/mod_rewrite.html

not for redirecting, but for changing the appearance of URLs. My website has the format jjjp.ca/1/22/whatever, where the 1/22 is accepted as a valid URL by the HTACCESS RewriteRule. The actual redirect is done by the php file.

In reality my website's url is jjjp.ca/single.php?post=22. The RewriteRule translates it for the outside. Internally the php sees the real url.


So when trying to import my old website, I thought I could just use my index.php to send the old urls to the single.php. What I now have figured out is that it's index.php's job to do the entire redirect. So jjjp.ca/?p=blablah is received by index.php which performs the redirect to jjjp.ca/0/blablah. It's HTACCES's job to register that as a valid url and to translate it internally as jjjp.ca/single.php?oldwebsitepost=blablah.


In order for that to work I had to adjust the RewriteRule to include any character between the two forward slashes, otherwise it wouldn't recognize a URL more than 4 characters between the slashes, like the RewriteRule for my current website's posts.

RewriteRule   "^0/(.*)(/.+)?$"   "/single.php?oldwebsitepost=$1" [NC,L]

SQL

Joins sql.png

Joins are confusing. Examples needed.attempting to do math on a query, the DATEDIFF of the previous row

use subquery and ROW_NUMBER()

https://sqltheater.com/blog/cant-use-row-number-where/

https://www.sqlservertutorial.net/sql-server-window-functions/sql-server-row_number-function/

https://stackoverflow.com/questions/17587708/select-difference-between-two-dates-and-sum

https://www.sqlservertutorial.net/sql-server-date-functions/sql-server-datediff-function/

https://www.py4u.net/discuss/843201

--acc_amp_event
SELECT event_date, acc_id
DATEDIFF(second,)
FROM
acc_amp_event
WHERE
personnel_id=455

acc_amp_event_id

SELECT event_date, acc_id, 
       event_date - lag(event_date) over (order by date_time) as difference
FROM acc_amp_event
WHERE personnel_id=455


--works but because acc amp event id is not sequential the math is off
--attempt to make a subquery where my own id is sequency but got kicked off server
--realized my mistake of using the wrong personnel_id 445 instead of 455 (me)
SELECT TOP 100 t1.acc_amp_event_id, t1.acc_id, t1.event_date, DATEDIFF(minute,t1.event_date, t2.event_date)
FROM acc_amp_event AS t1
LEFT JOIN acc_amp_event AS t2 ON t1.acc_amp_event_id = t2.acc_amp_event_id - 1
WHERE t1.personnel_id=455
ORDER BY t1.event_date DESC

SELECT TOP 100 ROW_NUMBER() OVER (ORDER BY acc_amp_event_id)
, acc_id, event_date
FROM acc_amp_event
WHERE personnel_id=445

SELECT rn, acc_amp_event_id, event_date
FROM
(SELECT ROW_NUMBER() OVER(ORDER BY event_date) AS rn, acc_amp_event_id, event_date, personnel_id
FROM acc_amp_event
) AS t
WHERE personnel_id=445


SELECT ROW_NUMBER() OVER (ORDER BY event_date), acc_amp_event_id, event_date
FROM
(SELECT TOP 100 acc_amp_event_id, event_date, personnel_id FROM acc_amp_event WHERE personnel_id=455)

Aggregate function

"An aggregate function performs a calculation on a set of values, and returns a single value. Except for COUNT(*), aggregate functions ignore null values. Aggregate functions are often used with the GROUP BY clause of the SELECT statement" Aggregate Functions (Transact-SQL) - SQL Server | Microsoft Docs "column X is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."

When using "GROUP BY" the columns need to be referenced in the SELECT clause and GROUP BY clause

SELECT tmplt_profile_id, id, sql_operation
FROM acc_specimen_audit
GROUP BY tmplt_profile_id, sql_operation, id
HAVING sql_operation='U'