Skip to content

Instantly share code, notes, and snippets.

@davidimoore
davidimoore / list_indexes_in_rails_console.rb
Created January 4, 2024 22:56 — forked from davygora/list_indexes_in_rails_console.rb
Get list of all indexes in rails console.
# rails console
ActiveRecord::Base.connection.tables.each do |table|
indexes = ActiveRecord::Base.connection.indexes(table)
if indexes.length > 0
puts "====> #{table} <===="
indexes.each do |index|
puts "----> #{index.name}"
end
puts "====> #{table} <===="
@davidimoore
davidimoore / traceback_exc.py
Created November 1, 2023 22:12 — forked from rpdelaney/traceback_exc.py
Serialize python exceptions into dictionaries
import traceback
from typing import Dict, Union, List
def traceback_exc(exc: Exception) -> Dict[str, Union[str, List[str]]]:
tb = traceback.TracebackException.from_exception(
exc, capture_locals=True
)
return {
"title": type(exc).__name__,
@davidimoore
davidimoore / _aws.graphql
Last active December 16, 2023 00:19 — forked from sc0ttdav3y/_aws.graphql
AWS AppSync GraphQL scalars and directives to support type completion and error checking in Webstorm IDEs
# These are here to help the IDE recognise AWS types.
#
# Place this file outside the 'schema' directory so are not pushed to AWS,
# but are still picked up by PhpStorm's GraphQL plugin to help
# validate schemas.
#
# https://docs.aws.amazon.com/appsync/latest/devguide/scalars.html
#
scalar AWSDateTime
scalar AWSDate
#!/bin/bash
function git_delete_local_remote_branches() {
branches=($1)
for i in "${branches[@]}"; do
git_delete_local_remote_branch $i
done
}
@davidimoore
davidimoore / force push with lease
Last active June 1, 2020 19:18
"Safely" force push to remote origin branch.
function git_force_push_w_lease() {
if [[ -z "$1" ]]; then
BRANCH=$(git symbolic-ref --short -q HEAD)
elif [[ "$1" == "master" ]] || [[ $BRANCH == "master" ]] || [[ $BRANCH == "production" ]]; then
echo "Attempted to force push to a restricted branch. Not allowed! Exiting"
return
else
BRANCH="$1"
fi
echo "Pushing to $BRANCH"
@davidimoore
davidimoore / keybase.md
Last active November 3, 2019 05:49
keybase.md

Keybase proof

I hereby claim:

  • I am davidimoore on github.
  • I am davidimoore (https://keybase.io/davidimoore) on keybase.
  • I have a public key ASCWvLcB3xX_QkWwI1rF_HzN3DItt_IKyHoI-Ny1plS98go

To claim this, I am signing this object:

#!/bin/bash
function bundle_rspec {
bundle exec rspec $1
}
function rails_update_gems {
echo "Running bundle install"
bundle install
}
{
"league": {
"id": "4353138d-4c22-4396-95d8-5f587d2df25c",
"name": "NBA",
"alias": "NBA"
},
"season": {
"id": "3652b3d6-55f7-44f5-b69d-7c607b9be26b",
"year": 2017,
"type": "SIM"
@davidimoore
davidimoore / nbasimulated-schedule.json
Created December 14, 2018 19:28
nba-simulated-schedule
{
"league": {
"id": "4353138d-4c22-4396-95d8-5f587d2df25c",
"name": "NBA",
"alias": "NBA"
},
"season": {
"id": "3652b3d6-55f7-44f5-b69d-7c607b9be26b",
"year": 2017,
"type": "SIM"
@davidimoore
davidimoore / nbagamesummary.json
Created December 13, 2018 22:54
nba game summary
{
"id": "bbbc557d-3ff5-44cb-a48c-f3033740ddf7",
"status": "closed",
"coverage": "full",
"neutral_site": false,
"scheduled": "2018-12-13T03:30:00+00:00",
"duration": "2:08",
"attendance": 19596,
"lead_changes": 4,
"times_tied": 1,