Skip to content

Instantly share code, notes, and snippets.

View dyoung522's full-sized avatar

Donovan C. Young dyoung522

View GitHub Profile
@dyoung522
dyoung522 / State.rb
Created November 9, 2012 18:12
Ruby on Rails 3 model to serve US States without a database
class State
include ActiveModel::Conversion
extend ActiveModel::Naming
attr_reader :all
US_STATES = {
AL: "Alabama",
AK: "Alaska",
AZ: "Arizona",
@dyoung522
dyoung522 / boxen-setup.sh
Last active December 23, 2015 08:59
Boxen configuration setup
#!/bin/sh
fail() {
echo "Whoops... $*"
exit 1
}
if [ ! -d /opt/boxen ] ; then
sudo mkdir -p /opt/boxen && sudo chown ${USER}:staff /opt/boxen
fi || fail "could not create /opt/boxen"
@dyoung522
dyoung522 / pathmunge.sh
Last active November 22, 2015 10:32
pathmunge() bash function to add to PATH without duplication
pathmunge () {
if [ "$2" = "force" ] || ! echo $PATH | $(which egrep) -q "(^|:)$1($|:)"
then
if [ "$2" = "after" ]
then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
export PATH
@dyoung522
dyoung522 / add_static_route.sh
Created January 8, 2015 19:01
Add a permanent static route to OS X 10.10
#!/bin/bash
sudo /sbin/route add -net x.x.x.0/24 xxx.xxx.xxx.xxx
# Save this file somewhere and make it executable (chmod a+x <file>)
# Then run 'sudo defaults write com.apple.loginwindow LoginHook /Path/To/Your/Script'
@dyoung522
dyoung522 / options.rb
Created May 11, 2015 21:00
Ruby OptParse
require 'optparse'
require 'ostruct'
class OptParse
#
# Return a structure describing the options.
#
def self.parse(args)
# The options specified on the command line will be collected in *options*.
# We set default values here.
@dyoung522
dyoung522 / tech-questions.md
Last active September 12, 2016 17:50
Technical Interview Questions

Technical Interview Questions

General

  • In as much detail as you like, explain what happens when I type "google.com" into my browser's address bar and press enter.
  • Explain the difference between dynamic vs. static programming languages? What are the advantages/disadvantages of each?
  • What's something you love/hate about your favorite programming language?
  • What tools do you use for your day to day work? Language, IDEs/editors, version control, build systems, provisioning, etc.?
  • What's the difference between an class vs. an object?
  • What is inheritance? What are some alternate ways to reuse logic without using it? What are some downsides to it?
@dyoung522
dyoung522 / get_params_from_url.js
Last active February 15, 2016 21:04
JS: Retrieve params from the calling URL
export default {
getParams() {
const scripts = document.getElementsByTagName('script'),
myScript = scripts[scripts.length - 1],
query = myScript.src.replace(/^[^\?]+\??/, '');
let Params = {};
if ( !query ) { return Params } // return empty object
@dyoung522
dyoung522 / README.md
Created June 23, 2016 20:07 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@dyoung522
dyoung522 / getopt.sh
Last active August 22, 2016 16:59
Bash GetOpt example
#!/bin/bash
PROGRAM=$(basename $0)
VERSION="0.0.1"
OPT_VERBOSE=0
OPT_FORCE=0
OPT_CLEAN=0
OPT_TEST=0
# Verbose modes
@dyoung522
dyoung522 / kafka-oracle-vm-config.md
Last active July 15, 2024 06:25 — forked from vipmax/kafka install systemd.md
kafka installation with systemd
  1. Install Kafka

    cd /opt
    curl -O http://www.gtlib.gatech.edu/pub/apache/kafka/0.11.0.0/kafka_2.11-0.11.0.0.tgz
    tar xvzf kafka_2.11-0.11.0.0.tgz
    ln -s kafka_2.11-0.11.0.0/ kafka
  2. Edit /usr/lib/systemd/system/kafka-zookeeper.service