Skip to content

Instantly share code, notes, and snippets.

View MilesDowe's full-sized avatar

Miles Dowe MilesDowe

View GitHub Profile
@MilesDowe
MilesDowe / slice_wav_in_memory.py
Created February 1, 2018 22:00
One way to slice a wav file in memory and supply to scipy wavreader
from pydub import AudioSegment
from io import BytesIO
from scipy.io import wavfile
# get file
audio_file = AudioSegment.from_wav("some.wav")
# create output, supply to AudioSegment
audio_sample = BytesIO()
audio_file[2000:5000].export(audio_sample, format='wav')
@MilesDowe
MilesDowe / migrate-git-template.sh
Last active March 14, 2018 00:12
Migrate Git repos between sources
#Tweaked from https://blogs.s-osg.org/retain-history-moving-files-git-repositories/
# Pull your new location
git clone <your new repo>
cd /path/to/new/repo
# Link to old location and crate a branch off it
git remote add old-location ssh://git@github.com/organization/repo.git # or HTTPS
git fetch old-location
@MilesDowe
MilesDowe / find-unclosed-queries-osql.sql
Last active July 30, 2019 01:04
Find unclosed Oracle SQL connections
-- A way to find un-closed Oracle SQL queries
-- Taken from https://srivenukadiyala.wordpress.com/2011/02/15/one-way-to-detect-jdbc-connection-leaks/
-- Get a count of sessions per machine:
select machine, count(*)
from v$session
where username = 'user name'
and machine like 'machine name'
and program = 'JDBC Thin Client'
group by machine
  1. Evaluate query: EXPLAIN PLAN FOR <sql query as usual>;
  2. View evaluation: SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY());
@MilesDowe
MilesDowe / add-cert-to-jvm.sh
Last active February 1, 2019 17:40
Add a cert to JVM keystore + `keytool` cheatsheet
#!/bin/sh
# Taken from StackOverflow and modified lightly.
#
# For general keytool tips, this site is useful:
# https://www.sslshopper.com/article-most-common-java-keytool-keystore-commands.html
#
# Also, if you goof, can remove simply using:
# keytool -delete -alias ourdomain -keystore pc.keystore
# Also also: If you are given a PEM file, you can try the following instead:
@MilesDowe
MilesDowe / did-file-rc.sh
Created July 16, 2018 15:27
A simple way of opening a file for daily tracking of tasks. Personally helpful to me to know how to invoke Vim commands upon start up.
# Taken from https://theptrk.com/2018/07/11/did-txt-file/
vim +'normal Go' +'r!date' +'normal o' ~/Desktop/did.txt
@MilesDowe
MilesDowe / reset-weblogic-creds.md
Last active August 2, 2018 20:03
Steps to reset the admin credentials for a Weblogic admin server

Resetting the Admin Credentials in WebLogic

Note: Taken from this website

export MW_HOME=<location of your weblogic directory>
export DOMAIN_HOME=$MW_HOME/user_projects/domains/<domain_name>
export CLASSPATH=$CLASSPATH:$MW_HOME/wlserver_10.3/server/lib/weblogic.jar
. $DOMAIN_HOME/bin/setDomainEnv.sh
@MilesDowe
MilesDowe / create-ticket-notes.sh
Last active August 2, 2018 22:26
RC function for creating work ticket notes
# Add to .bashrc or similar runcommand file
function ticket() {
FILE=${1}.txt
FILE_LOC=~/Desktop/${1}.txt
# Check if file exists
stat ${FILE_LOC} > /dev/null 2>&1
EXISTS=$?
@MilesDowe
MilesDowe / js-in-ant-build.xml
Last active August 8, 2018 22:31
An example of using Javascript in Apache Ant build files.
<target name="example">
<script language="javascript">
// JS can be written here:
var example = function(a,b) {
print(b + " " + a);
};
example("test", "hi");
</script>
</target>
@MilesDowe
MilesDowe / oracle_view_active_queries.sql
Created October 2, 2018 15:25
General OracleSQL query to check active queries
select S.USERNAME, s.sid, s.serial#, s.osuser, t.sql_id, sql_text
from v$sqltext_with_newlines t,V$SESSION s
where t.address =s.sql_address
and t.hash_value = s.sql_hash_value
and s.status = 'ACTIVE'
and s.username <> 'SYSTEM'
order by s.sid,t.piece
;