Skip to content

Instantly share code, notes, and snippets.

View knoxilla's full-sized avatar
🤔
Well That's Fun!

Thomas Knox knoxilla

🤔
Well That's Fun!
View GitHub Profile
"""How many pizzas do we need?"""
import math
import sys
if len(sys.argv) > 1:
people = int(sys.argv[1])
else:
people = int(raw_input("How many RSVPs? "))
@knoxilla
knoxilla / gitconfig-and-you.md
Last active September 25, 2023 14:31
'git' is not a git-command. See 'git --help'.

Make git do stuff

Let's get some help from the shell.

$ cat >> ~/.bash_aliases
alias get = 'git'
alias gi = 'git'
alias got = 'git'
alias gti = 'git'
@knoxilla
knoxilla / humanize_sqlplus.md
Last active January 21, 2021 18:50
How to make sqlplus more pleasant with rlwrap and a nice prompt

Humanizing sqlplus

It's always been frustrating to me that sqlplus does not have REPL behavior, so you can't arrow-up through your history, etc. In addition, the default SQL prompt is not very informative. Since I often work on prod and dev databases at the same time, it is important to me that I know where I am when I am executing disastrous SQL.

Well, rlwrap to the rescue! Plus, a handy login.sql script to customize your sqlplus prompt. The package was available by default in RHEL6 and on OSX El Capitan. YMMV...

Three Parts

You'll need to do three small things, and you are good to go,

@knoxilla
knoxilla / aws-resource-exists.bash
Last active September 23, 2020 21:20
Useful AWS bash function - resource_exists() - for pre-checking and avoiding collisions
#!/bin/bash
# written and explained by others!
# https://blogs.aws.amazon.com/cli/post/Tx93V7O09I96SO/AWS-re-Invent-2015-and-more
# https://github.com/awslabs/awscli-reinvent2015-examples/blob/master/scripts/setup-dev-ec2-instance
# Note: you need "jp" installed
# to run this command. You can
# brew tap jmespath/jmespath && brew install jp
# to install on a Mac.
@knoxilla
knoxilla / github label automation notes.md
Last active August 27, 2016 21:43
Github custom label automation

Label Automation

Possible Schema 1

pri: blocker
pri: critical
pri: important
pri: normal
pri: low

Keybase proof

I hereby claim:

  • I am knoxilla on github.
  • I am thomasknox (https://keybase.io/thomasknox) on keybase.
  • I have a public key whose fingerprint is 0D91 30B1 E21B AC8C 4634 D30C B6A6 580E FD35 8A62

To claim this, I am signing this object:

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.
@knoxilla
knoxilla / expected_conditions_example.py
Created April 11, 2018 14:22 — forked from easonhan007/expected_conditions_example.py
python selenium expected_conditions examples
#encoding:utf-8
# example of how to use https://github.com/SeleniumHQ/selenium/blob/master/py/selenium/webdriver/support/expected_conditions.py
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
import unittest
@knoxilla
knoxilla / Makefile
Created June 21, 2018 21:23 — forked from ryu1kn/Makefile
Encrypt/decrypt with AWS KMS using AWS cli
# How to encrypt/decrypt your text/blob secret with AWS KMS with AWS cli
KEY_ID=alias/my-key
SECRET_BLOB_PATH=fileb://my-secret-blob
SECRET_TEXT="my secret text"
ENCRYPTED_SECRET_AS_BLOB=encrypted_secret_blob
DECRYPTED_SECRET_AS_BLOB=decrypted_secret_blob # Result of decrypt-blob target
encrypt-text:
@knoxilla
knoxilla / bookmarklet.js
Created August 2, 2021 18:37
Show Alt Text Bookmarklet for Twitter
javascript:(function()%7Bvar a%3Ddocument.createElement(%27style%27),b%3Bdocument.head.appendChild(a)%3Bb%3Da.sheet%3Bb.insertRule(%27a%5Brole%3Dlink%5D div%5Baria-label%5D::after,div%5Baria-label%5D%5Bdata-testid%3DpreviewInterstitial%5D::after%7Bcontent:attr(aria-label)%3Bdisplay:block%3Bbackground-color:rgba(0,0,0,.8)%3Bcolor:%23ff0%3Bfont-family:%5C%27Segoe UI%5C%27,-apple-system,BlinkMacSystemFont,Roboto,Oxygen-Sans,Ubuntu,Cantarell,%5C%27Helvetica Neue%5C%27,sans-serif%3Bpadding:1em%3Bposition:absolute%3Btop:0%3Bleft:0%3Bright:0%3Bz-index:1%7D%27,0)%3Bb.insertRule(%27%5Bdir%3Dauto%5D>svg%7Bdisplay:none%7D%27,0)%3Bb.insertRule(%27a%5Brole%3Dlink%5D div%5Baria-label%5D%7Bdisplay:contents%3Bmargin-top:unset !important%3Bmargin-bottom:unset !important%7D%27,0)%3B%7D)()%3B
// I can't remember where I got this. So helpful! Sorry about lack of attribution. :(