Oracle SQL Utility Script for Unlock of All Accounts and Removal of Password Expiration

I’ve gotten tired of dealing with this on various development databases so I wrote a script to automagically remove password expiration and unlock all schema accounts.

Below is the script – verified working as of Oracle 12c

declare
sql_statement varchar2(4000);

BEGIN
  FOR profileObject IN (select DISTINCT profile from DBA_USERS)
  LOOP
    BEGIN
        sql_statement := ' alter profile ' || profileObject.PROFILE || ' limit password_life_time UNLIMITED';
        execute immediate sql_statement;
        dbms_output.put_line('SQL Statement Succeeded - ' || sql_statement);
    COMMIT;
    EXCEPTION
    when others then 
        dbms_output.put_line('SQL Statement Failed - ' || sql_statement);
    END;
  END LOOP;
  
  FOR sysUserObject IN (select * from sys.user$)
  LOOP
    BEGIN
        sql_statement := 'ALTER USER ' || sysUserObject.name ||' IDENTIFIED BY VALUES '''|| sysUserObject.spare4 ||';'|| sysUserObject.password || '''';
        execute immediate sql_statement;
        dbms_output.put_line('SQL Statement Succeeded - ' || sql_statement);
    COMMIT;
    EXCEPTION
    when others then 
        dbms_output.put_line('SQL Statement Failed - ' || sql_statement);
    END;
  END LOOP;
  
  FOR userObject IN (select DISTINCT USERNAME from DBA_USERS)
  LOOP
    BEGIN
        sql_statement := 'alter user ' || userObject.USERNAME || ' account unlock';
        execute immediate sql_statement;
        COMMIT;
        dbms_output.put_line('SQL Statement Succeeded - ' || sql_statement);
        EXCEPTION
        WHEN OTHERS THEN dbms_output.put_line('SQL Statement Failed - ' || sql_statement);
    END;
  END LOOP;
  COMMIT;
END;

Git Push Fails – fatal: The remote end hung up unexpectedly

Had this issue today and found the below solution.

Credit to Atlassian for documenting – I am reposting and archiving the fix for my own records.

https://confluence.atlassian.com/staskb/git-push-fails-fatal-the-remote-end-hung-up-unexpectedly-282988530.html

Symptoms

When users try to run “git push” the following error message is shown:

$ git push
Counting objects: 2332669, done.
Delta compression using up to 16 threads.
Compressing objects: 100% (360818/360818), done.
error: RPC failed; result=22, HTTP code = 411
fatal: The remote end hung up unexpectedly
Writing objects: 100% (2332669/2332669), 483.30 MiB | 114.26 MiB/s, done.
Total 2332669 (delta 1949888), reused 2330461 (delta 1949349)
fatal: The remote end hung up unexpectedly

Cause

The “Smart HTTP” protocol in Git uses “Transfer-Encoding: chunked” in POST requests when it contains packed objects greater than 1MB in size.

Some proxy servers, like Nginx, do not support this transfer encoding by default, and the requests will be rejected before they get to Stash. Because of this, the Stash logs will not show any extra information.

Workaround

  • When pushing a large amount of data (initial push of a big repository, change with very big file(s)) may require a higher http.postBuffer setting on your git client (not the server). From https://www.kernel.org/pub/software/scm/git/docs/git-config.htmlhttp.postBufferMaximum size in bytes of the buffer used by smart HTTP transports when POSTing data to the remote system. For requests larger than this buffer size, HTTP/1.1 and Transfer-Encoding: chunked is used to avoid creating a massive pack file locally. Default is 1 MiB, which is sufficient for most requests.
  • Configuration on your reverse proxy. Usually ngnix the parameter client_max_body_size is a blocker. The reverse proxy may also have a connection timeout that’s closing the connection (e.g. TimeOut or ProxyTimeout in apache, proxy_read_timeout in ngnix). Try bypassing the proxy by pushing directly to Stash IP:port. If this works, it’s highly likely that the proxy server is causing the early disconnect and needs to be tuned.
  • User is using an outbound proxy on his machine that is causing the issue.

Resolution

Finding the Process that has a Lock on a File when you don’t have Administrator

Most of the time Microsoft Windows experts will immediately point you to Sysinternals Process Explorer. Unfortunately for a vast majority of us, this requires Administrator privileges on your machine and in today’s security conscious society, System Admin give this out less and less.

Enter this solution I found from Stack Overflow user Svish.

The following is a direct copy paste of the post that you can find at this link for citation purposes.

You can use the Resource Monitor for this which comes built-in with Windows 7, 8, and 10.

  1. Open Resource Monitor, which can be found
    • By searching for Resource Monitor or resmon.exe in the start menu, or
    • As a button on the Performance tab in your Task Manager
  2. Go to the CPU tab
  3. Use the search field in the Associated Handles section
    • See blue arrow in screen shot below

When you’ve found the handle, you can identify the process by looking at the Image and/or PID column.

You can then try to close the application as you normally would, or, if that’s not possible, just right-click the handle and kill the process directly from there. Easy peasy!

Resource Monitor screenshot

Example for Sending Commands to a Currently Active Screen Session

If you are one of the people that use my Docker VPN Tunneling Tool this can be used to automate login by appending it to your portion of the script.

^M represents pressing enter if unfamiliar. I’ll probably forget, that’s why I’m creating this post.

#sh dockerVpnTool.sh $OPENCONNECT_VPN_ENDPOINT $LOCAL_DOCKER_ADDRESS $LOCAL_DOCKER_SSH_PORT $CONTAINER_NAME $IMAGE_NAME "$(declare -p DESTINATION_LIST)"

#Begin Customization
echo -e "\n\n1\n" | ./dockerVpnTool.sh $OPENCONNECT_VPN_ENDPOINT $LOCAL_DOCKER_ADDRESS $LOCAL_DOCKER_SSH_PORT $CONTAINER_NAME $IMAGE_NAME "$(declare -p DESTINATION_LIST)"

function connectToEndpoint()
{
    #Begin Endpoint Customization 
    COMMAND_TO_RUN="winpty docker exec $CONTAINER_NAME bash -c"
    COMMAND_TO_RUN_INTERACTIVE="winpty docker exec -it $CONTAINER_NAME bash -c"

    SESSION_NAME="session_vpnTool"
    USERNAME='username'
    PASSWORD='password'
    CONNECTION_PROFILE='connectionProfile'

    $COMMAND_TO_RUN "screen -d -m -S $SESSION_NAME openconnect $OPENCONNECT_VPN_ENDPOINT"
    $COMMAND_TO_RUN "screen -S $SESSION_NAME -p 0 -X stuff \"$CONNECTION_PROFILE^M\""
    $COMMAND_TO_RUN "screen -S $SESSION_NAME -p 0 -X stuff \"$USERNAME^M\""
    $COMMAND_TO_RUN "screen -S $SESSION_NAME -p 0 -X stuff \"$PASSWORD^M\""

    #If Debug is Needed
    #$COMMAND_TO_RUN_INTERACTIVE "screen -r"
}

connectToEndpoint

Understanding Question Mark and Colon Operators in Java Programming

Today I was having issues understanding syntactically how ? and : operators work in Java on some legacy code I was reading. The issue was that all definitions I found through google practically sucked until I found this one by “cricket_007” on StackOverflow.

Either way, I got it figured out and am documenting this and raising awareness for other developers in the future.

Thanks so much “cricket_007” and here is the link if anyone is interested:

Custom SendTo Execution Shortcuts – Windows

Start out with doing “Windows Key + R” and type “shell:sendto”

Next, this folder will pop up:

Create a new Batch File in this directory – I’ve called mine “Launch with Bash.bat” – below is some example code:

@ECHO OFF
SETLOCAL

SET filedrive=%~d1
SET filepath=%~p1
SET filedrive_and_filepath=%filedrive%%filepath%

SET filename=%~n1
SET fileextension=%~x1
SET filename_and_fileextension=%filename%%fileextension%

cd /d %filedrive_and_filepath%
"C:\Program Files\Git\bin\bash.exe" -c "sh ""%filename_and_fileextension%"" "

Note a few things – Batch files can take a starting argument like methods in programming so basically when you right click and do “SendTo” on Windows, it sends the filepath of what you are “Sending” to whatever the destination is.

In a batch file, these parameters are accessed through %1 %2 %3 etc for each positional parameter that is being passed to the “method”

This prewritten file will allow you to create a custom process that easily allows you to launch something with a programmatic process. AKA custom builds, processes, launch parameters, etc.