Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew H Schwartz ozydingo

View GitHub Profile
@ozydingo
ozydingo / .gitbranch
Last active Aug 15, 2020
Display your git branch and status in your terminal
View .gitbranch
# To use gitbranch to set your prompt to include a colored git branch label:
# bash:
# source .gitbranch
# bash_colors
# PS1='[\[$(git_branch_color)\]$(parse_git_branch)\[${NORMAL}\]] '"$PS1"
# zsh:
# source .gitbranch
# zsh_colors
# setopt PROMPT_SUBST
# export PROMPT='[%F{$(git_branch_color)}$(parse_git_branch)%f] %B%F{240}%~%f %# '
@ozydingo
ozydingo / colors.sh
Created Jan 16, 2020
Git branch parsing and terminal prompt color setting
View colors.sh
bash_colors() {
export BLACK=$(tput setaf 0)
export RED=$(tput setaf 1)
export GREEN=$(tput setaf 2)
export YELLOW=$(tput setaf 3)
export BLUE=$(tput setaf 4)
export MAGENTA=$(tput setaf 5)
export CYAN=$(tput setaf 6)
export WHITE=$(tput setaf 7)
export NORMAL=$(tput sgr0)
@ozydingo
ozydingo / inspections_controller.rb
Created Mar 27, 2019
Rails controller to see your request
View inspections_controller.rb
class InpsectionsController < ApplicationController
def index
log
head :ok
end
def create
log
head :ok
end
@ozydingo
ozydingo / sagemaker_demo.py
Last active Feb 15, 2019
SageMaker getting started tutorial
View sagemaker_demo.py
#!/usr/bin/env python
# coding: utf-8
# In[1]:
# import libraries
import boto3, re, sys, math, json, os, sagemaker, urllib.request
from sagemaker import get_execution_role
import numpy as np
@ozydingo
ozydingo / keyscroller.js
Created Feb 2, 2019
a/z key scrolling to scroll-disabled web content
View keyscroller.js
function KeyPress(e) {
var evtobj = window.event? event : e
if (evtobj.keyCode == 90) {
window.scrollBy(0, 100)
}
if (evtobj.keyCode == 65) {
window.scrollBy(0, -100)
}
}
@ozydingo
ozydingo / .bashrc
Last active Feb 2, 2019
Git Branch Prompt
View .bashrc
source colors.sh
bash_colors
source gitbranch.sh
PS1='[\[$(git_branch_color)\]$(parse_git_branch)\[${NORMAL}\]] '"$PS1"
@ozydingo
ozydingo / graph2.js
Last active Feb 3, 2018
Barebones js x,y graph using canvas element
View graph2.js
function Graph2(canvas) {
if (canvas.tagName !== 'CANVAS') { throw 'Graph2 requires a canvas element'; }
this.canvas = canvas;
this.cursor = canvas.getContext("2d");
this.axes = {
display: false,
xlim: [-1, 1],
ylim: [-1, 1],
}
@ozydingo
ozydingo / current-dir-in-iterm-tab-title.sh
Last active Jun 12, 2018 — forked from phette23/current-dir-in-iterm-tab-title.sh
Set the iTerm tab title to the current directory, not full path.
View current-dir-in-iterm-tab-title.sh
# Ensure that you have your iTerm configured to allow the shell to modify the window / tab title.
# In iTerm 3.1.2 this is a checkbox located in Settings > Profile > Terminal: "Terminal may set tab/window title"
# Then, put this in your .bash_profile
if [ $ITERM_SESSION_ID ]; then
export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007"; ':"$PROMPT_COMMAND";
fi
# Piece-by-Piece Explanation:
# the if condition makes sure we only screw with $PROMPT_COMMAND if we're in an iTerm environment
# iTerm happens to give each session a unique $ITERM_SESSION_ID we can use, $ITERM_PROFILE is an option too
View gist:717d6b108e10235f33cf70fe486095cb
--
Introduction:
This coding challenge is designed for you to show off your skills to the 3Play Media Developer team. You
should have the following challenge completed by the time you come in for your in-person interview so we
can take a look at it together. While all of the basic requirements of this project should be met, you're
encouraged to make this project your own and implement any additional features that you see fit.
Feel free to ask whatever questions, use whatever resources and provide whatever documentation
you'd like during the completion of this project.
@ozydingo
ozydingo / caputre_stdout.rb
Created Jun 9, 2016
Ruby class for capturing puts / stdout buffer
View caputre_stdout.rb
require 'stringio'
class CaptureStdout
def initialize(&blk)
@handler = blk
end
def capture
StringIO.open do |io|
stash = $stdout