Skip to content

Instantly share code, notes, and snippets.

View ryanthames's full-sized avatar

Ryan Thames ryanthames

  • Spring Solutions
  • Fort Worth, Texas
View GitHub Profile
@ryanthames
ryanthames / ms_conversion.sql
Created October 28, 2020 13:28
Convert milliseconds to timestamp in oracle
select to_char(to_date('1970-01-01 00', 'yyyy-mm-dd hh24') + (1601921560000)/1000/60/60/24, 'YYYY-MM-DD HH12:MI:SS am') datestr from dual;
@ryanthames
ryanthames / Git Linux Prompt.sh
Created May 7, 2020 16:26
Add git branch to Ubuntu prompt
# Add to ~/.bashrc
git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] \[\033[00;32m\]\$(git_branch)\[\033[00m\]\$ "
# After saving, run this
source ~/.bashrc
@ryanthames
ryanthames / cockroach_start.sh
Last active June 4, 2020 14:17
Run cockroach in single node "cluster"
# Starts a single node instance of cockroach on localhost
cockroach start-single-node --insecure --listen-addr=localhost --http-addr=localhost:PORT_NUM
# example of how to connect sql prompt to "cluster"
cockroach sql --insecure --database=database_name
# Create a database, user, grant permissions
create database if not exists database_name;
create user if not exists admin_user;
create user if not exists normal_user;
@ryanthames
ryanthames / wsl_setup.sh
Last active May 5, 2020 23:24
WSL Setup
# create /data location as a "mount" for apps to hit and for application installs
mkdir -p /mnt/c/data/apps
sudo ln -s /mnt/c/data /data
# mount your code directory to /code
sudo ln -z /mnt/c/Users/[USER_NAME]/code /code
@ryanthames
ryanthames / graceful_undeploy.jbosscli
Created September 13, 2018 15:57
Undeploy an app from wildfly/jboss. If the app isn't already deployed, then ignore
if (outcome == success) of /deployment=my-deployment.war:read-attribute(name=status)
echo app is deployed, undeploying...
undeploy my-deployment.war
end-if
(def order-details
{:name "Mitchard Blimmons"
:email "mitchard.blimmonsgmail.com"})
(def order-details-validations
{:name
["Please enter a name" not-empty]
:email
["Please enter an email address" not-empty
@ryanthames
ryanthames / rpi_remote_server_ip_change.sh
Last active January 7, 2018 22:32
Stuff to do when moving remote print server (raspberry pi) to a new IP
# ssh into your pi, most likely the "default" login (user: pi, password: raspberry)
ssh pi@raspberrypi
# find new ip address
ifconfig | grep inet
# update cupsd.conf (you may have to sudo)
cp /etc/cups/cupsd.conf /etc/cups/cupsd.conf.backup
vi /etc/cups/cupsd.conf
[{kernel,
[{distributed, [{chucky, 5000, [a@Ryans-MBP, {b@Ryans-MBP, c@Ryans-MBP}]}]},
{sync_nodes_mandatory, [b@Ryans-MBP, c@Ryans-MBP]},
{sync_nodes_timeout, 30000}
]}].
select ix.owner, ix.index_name, ix.table_name,
ix.distinct_keys, ix.leaf_blocks,
s.blocks as segment_blocks,
s.bytes / 1048576 as size_in_mb,
to_char(ix.last_analyzed, 'YYYY-MM-DD HH24:MI') as last_analyzed
from all_indexes ix, dba_segments s
where ix.owner = s.owner and ix.index_name = s.segment_name
order by ix.table_name, ix.index_name;
select column_name, avg_col_len, num_distinct, num_nulls
from all_tab_columns
where table_name = '<<table name>>'
order by column_id desc;