diff --git a/aws/cloudsearch/clone_fieldConf.sh b/aws/cloudsearch/clone_fieldConf.sh new file mode 100644 index 0000000..2ede2ce --- /dev/null +++ b/aws/cloudsearch/clone_fieldConf.sh @@ -0,0 +1,107 @@ +#!/bin/bash +#### USAGE: + +## cs_cloner.sh + +## Requires the AWS CLI to be configured, as it will make calls using the CLI itself. + +srcdomain=$1 +destdomain=$2 +region=$3 + +src_qry="aws cloudsearch describe-index-fields --domain-name $srcdomain --output json" + +if [[ $region && ${region-x} ]]; then + src_qry=$src_qry" --region $region" +fi + +fields=`eval $src_qry | jq .IndexFields` + +num_fields=`echo $fields | jq '. | length'` + +i=0 +until [ $i == $num_fields ]; do + field=`echo $fields | jq ".[$i]"` + field_name=`echo $field | jq -r '.Options.IndexFieldName'` + field_type=`echo $field | jq -r '.Options.IndexFieldType'` + case "$field_type" in + text) + opts=TextOptions + ;; + text-array) + opts=TextArrayOptions + ;; + date) + opts=DateOptions + ;; + date-array) + opts=DateArrayOptions + ;; + double) + opts=DoubleOptions + ;; + double-array) + opts=DoubleArrayOptions + ;; + literal) + opts=LiteralOptions + ;; + literal-array) + opts=LiteralArrayOptions + ;; + int) + opts=IntOptions + ;; + int-array) + opts=IntArrayOptions + ;; + latlon) + opts=LatLonOptions + ;; + esac + + field_sort=`echo $field | jq -r ".Options.$opts.SortEnabled"` + field_facet=`echo $field | jq -r ".Options.$opts.FacetEnabled"` + field_search=`echo $field | jq -r ".Options.$opts.SearchEnabled"` + field_return=`echo $field | jq -r ".Options.$opts.ReturnEnabled"` + field_highlight=`echo $field | jq -r ".Options.$opts.HighlightEnabled"` + field_scheme=`echo $field | jq -r ".Options.$opts.AnalysisScheme"` + field_default_value=`echo $field | jq -r ".Options.$opts.DefaultValue"` + + str="aws cloudsearch define-index-field --domain-name $destdomain --name $field_name --type $field_type" + + if [ $field_sort != 'null' ]; then + str=$str" --sort-enabled $field_sort" + fi + + if [ $field_facet != 'null' ]; then + str=$str" --facet-enabled $field_facet" + fi + + if [ $field_search != 'null' ]; then + str=$str" --search-enabled $field_search" + fi + + if [ $field_return != 'null' ]; then + str=$str" --return-enabled $field_return" + fi + + if [ $field_highlight != 'null' ]; then + str=$str" --highlight-enabled $field_highlight" + fi + + if [ $field_scheme != 'null' ]; then + str=$str" --analysis-scheme $field_scheme" + fi + + if [ $field_default_value != 'null' ]; then + str=$str" --default-value $field_default_value" + fi + + if [[ $region && ${region-x} ]]; then + str=$str" --region $region" + fi + + eval $str + let i+=1 +done diff --git a/workstation/bootstrap/boot_strappy_486.sh b/workstation/bootstrap/boot_strappy_486.sh new file mode 100644 index 0000000..e682341 --- /dev/null +++ b/workstation/bootstrap/boot_strappy_486.sh @@ -0,0 +1,243 @@ +#!/bin/bash +set -ex + +install_jupyter=false + +# get input parameters +while [ $# -gt 0 ]; do + case "$1" in + --jupyter) + install_jupyter=true + ;; + -*) + error_msg "unrecognized option: $1" + ;; + *) + break; + ;; + esac + shift +done + +platform=`uname` +s3_utils='https://s3.amazonaws.com/ty-emr/XRR/utils' +build_vim=false + +if [ "$USER" == "root" ]; then + util_path="/root/.utils" + home="/root" +else + if [ "$platform" == "Darwin" ]; then + users_dir="Users" + fi + if [ "$platform" == "Linux" ]; then + users_dir="home" + fi + util_path="/$users_dir/$USER/.utils" +fi +vim_check=`vim --version` +if [[ $vim_check != *"+lua"* ]]; then + build_vim=true +fi +mkdir -p $util_path + +release=`cat /etc/*release* | tr '[:upper:]' '[:lower:]'` +if [[ $release != *"smartos"* ]]; then + if [[ $release == *"red hat"* ]]; then + sudo yum groupinstall -y "Development Tools" + sudo yum install -y \ + tmux \ + htop \ + mlocate \ + git \ + rake \ + zsh \ + jq \ + at \ + bind-utils \ + strace \ + lua \ + lua-devel \ + ncurses \ + ncurses-devel \ + gmp \ + gmp-devel \ + ctags \ + tcl-devel \ + perl \ + perl-devel \ + perl-ExtUtils-ParseXS \ + perl-ExtUtils-CBuilder \ + perl-ExtUtils-Embed + + sudo chkconfig atd on + sudo service atd start + + if [[ $build_vim == true ]]; then + cd /tmp + git clone http://luajit.org/git/luajit-2.0.git + cd luajit-2.0 + make + sudo make install + + cd /tmp + git clone https://github.com/vim/vim.git + cd vim + ./configure \ + --with-features=huge \ + --enable-cscope \ + --enable-pythoninterp \ + --enable-luainterp \ + --enable-multibyte \ + --enable-fontset \ + --disable-gui \ + --without-x \ + --disable-netbeans \ + --enable-largefile + make + sudo make install + + sudo rm /usr/bin/vi + sudo ln -s /usr/local/bin/vim /usr/bin/vi + rm -rf /tmp/vim + fi + fi + if [[ $release == *"debian"* ]]; then + sudo apt-get update + sudo apt-get install -y \ + tmux \ + htop \ + mlocate \ + git \ + rake \ + zsh \ + jq \ + at \ + dnsutils \ + strace \ + libncurses5-dev \ + libncursesw5-dev \ + python-dev \ + ruby-dev \ + lua5.1 \ + lua5.1-dev \ + luajit \ + libluajit-5.1 \ + libperl-dev \ + build-essential + + if [[ $build_vim == true ]]; then + sudo ln -sf /usr/include/lua5.1 /usr/include/lua5.1/include + sudo ln -sf /usr/lib/x86_64-linux-gnu/liblua5.1.so /usr/local/lib/liblua.so + cd /tmp + git clone https://github.com/vim/vim.git + cd vim + ./configure \ + --with-features=huge \ + --enable-cscope \ + --enable-pythoninterp=yes \ + --enable-rubyinterp=yes \ + --with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu \ + --enable-multibyte \ + --enable-fontset \ + --disable-gui \ + --disable-netbeans \ + --enable-luainterp=yes \ + --with-luajit \ + --with-lua-prefix=/usr/include/lua5.1 \ + --enable-largefile + + make + sudo make install + + sudo rm /usr/bin/vi + sudo ln -s /usr/local/bin/vim /usr/bin/vi + rm -rf /tmp/vim + fi + fi + + curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | sudo python2.7 + sudo pip install awscli + sh -c "`curl -fksSL https://raw.githubusercontent.com/o0beaner/dotfiles/master/install.sh`" + sudo chmod 644 /usr/bin/chsh + sudo chmod +x /usr/bin/chsh + sudo /usr/bin/chsh -s /bin/zsh $USER + sudo updatedb + cd $util_path + wget --no-check-certificate $s3_utils/suntracker.sh + chmod +x $util_path/suntracker.sh + (crontab -l ; echo "0 3 * * * $util_path/suntracker.sh") | crontab - + $util_path/suntracker.sh +else + BOOTSTRAP_TAR="bootstrap-2017Q1-x86_64.tar.gz" + curl -Ok https://pkgsrc.joyent.com/packages/SmartOS/bootstrap/${BOOTSTRAP_TAR} + tar -zxpf ${BOOTSTRAP_TAR} -C / + rm -f boots* + PATH=/opt/local/sbin:/opt/local/bin:$PATH + MANPATH=/opt/local/man:$MANPATH + pkgin -y in jq tmux git ruby22-rake zsh at || true + mkdir /usbkey/root + mv /root/.[!.]* /usbkey/root + cd / + rm -rf /root + ln -s /usbkey/root /root + sh -c "`curl -fksSL https://raw.githubusercontent.com/o0beaner/dotfiles/smartos/install.sh`" + echo 'if [ -n "$BASH_EXECUTION_STRING" ]; then' >> ~/.bashrc + echo ' export SHELL=/opt/local/bin/zsh' >> ~/.bashrc + echo ' exec "$SHELL" -c "$BASH_EXECUTION_STRING"' >> ~/.bashrc + echo 'fi' >> ~/.bashrc + echo 'SHELL=/opt/local/bin/zsh; exec "$SHELL"' >> ~/.bashrc +fi + +# AWS Instance customization +if [ -e /usr/bin/cloud-init ]; then + + # Install SSM Agent + cd /tmp + sudo yum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm + + # Am I running EMR? + instance=`aws ec2 describe-instances --instance-ids $(curl -s 169.254.169.254/latest/meta-data/instance-id)` + tags=`echo $instance | jq -r '.Reservations[0].Instances[0].Tags[]'` + cluster_id=`echo $tags | jq -r '. | select(.Key=="aws:elasticmapreduce:job-flow-id") | .Value'` + if [ -n "$cluster_id" ]; then + echo "$cluster_id" > ~/.cluster_id + role=`echo $tags | jq -r '. | select(.Key=="aws:elasticmapreduce:instance-group-role") | .Value'` + + if [ "$role" == "MASTER" ]; then + # ToDo: Incorporate Hue? + + cd $util_path + wget --no-check-certificate $s3_utils/configure_zeppelin_s3.sh + chmod +x $util_path/configure_zeppelin_s3.sh + aws emr add-steps --cluster-id $cluster_id --steps Type=CUSTOM_JAR,Name="Configure Zeppelin for S3",Jar="command-runner.jar",Args=[$util_path/configure_zeppelin_s3.sh] + fi + + # install jupyter + if [ $install_jupyter == true ]; then + cd $util_path + wget --no-check-certificate https://s3.amazonaws.com/aws-bigdata-blog/artifacts/aws-blog-emr-jupyter/install-jupyter-emr5.sh + chmod +x $util_path/install-jupyter-emr5.sh + $util_path/install-jupyter-emr5.sh \ + --r \ + --julia \ + --toree \ + --torch \ + --ruby \ + --ds-packages \ + --ml-packages \ + --python-packages ggplot nilearn \ + --port 8002 \ + --password jupyter \ + --jupyterhub \ + --jupyterhub-port 8001 \ + --cached-install \ + --notebook-dir s3://ty-emr/XRR/jupyter/notebooks/ \ + --copy-samples \ + --s3fs + fi + fi +fi + +touch ~/.zsh.prompts +echo "prompt agnoster" > ~/.zsh.after/prompt.zsh diff --git a/workstation/karabiner-elements/karabiner.json b/workstation/karabiner-elements/karabiner.json new file mode 100644 index 0000000..0d332ad --- /dev/null +++ b/workstation/karabiner-elements/karabiner.json @@ -0,0 +1,275 @@ +{ + "global": { + "check_for_updates_on_startup": true, + "show_in_menu_bar": true, + "show_profile_name_in_menu_bar": false + }, + "profiles": [ + { + "complex_modifications": { + "parameters": { + "basic.to_delayed_action_delay_milliseconds": 500, + "basic.to_if_alone_timeout_milliseconds": 1000, + "basic.to_if_held_down_threshold_milliseconds": 500 + }, + "rules": [] + }, + "devices": [], + "fn_function_keys": [ + { + "from": { + "key_code": "f1" + }, + "to": { + "key_code": "display_brightness_decrement" + } + }, + { + "from": { + "key_code": "f2" + }, + "to": { + "key_code": "display_brightness_increment" + } + }, + { + "from": { + "key_code": "f3" + }, + "to": { + "key_code": "mission_control" + } + }, + { + "from": { + "key_code": "f4" + }, + "to": { + "key_code": "launchpad" + } + }, + { + "from": { + "key_code": "f5" + }, + "to": { + "key_code": "illumination_decrement" + } + }, + { + "from": { + "key_code": "f6" + }, + "to": { + "key_code": "illumination_increment" + } + }, + { + "from": { + "key_code": "f7" + }, + "to": { + "key_code": "rewind" + } + }, + { + "from": { + "key_code": "f8" + }, + "to": { + "key_code": "play_or_pause" + } + }, + { + "from": { + "key_code": "f9" + }, + "to": { + "key_code": "fastforward" + } + }, + { + "from": { + "key_code": "f10" + }, + "to": { + "key_code": "mute" + } + }, + { + "from": { + "key_code": "f11" + }, + "to": { + "key_code": "volume_decrement" + } + }, + { + "from": { + "key_code": "f12" + }, + "to": { + "key_code": "volume_increment" + } + } + ], + "name": "Internal", + "selected": true, + "simple_modifications": [ + { + "from": { + "key_code": "caps_lock" + }, + "to": { + "key_code": "f18" + } + } + ], + "virtual_hid_keyboard": { + "caps_lock_delay_milliseconds": 0, + "keyboard_type": "ansi" + } + }, + { + "complex_modifications": { + "parameters": { + "basic.to_delayed_action_delay_milliseconds": 500, + "basic.to_if_alone_timeout_milliseconds": 1000, + "basic.to_if_held_down_threshold_milliseconds": 500 + }, + "rules": [] + }, + "devices": [], + "fn_function_keys": [ + { + "from": { + "key_code": "f1" + }, + "to": { + "key_code": "display_brightness_decrement" + } + }, + { + "from": { + "key_code": "f2" + }, + "to": { + "key_code": "display_brightness_increment" + } + }, + { + "from": { + "key_code": "f3" + }, + "to": { + "key_code": "mission_control" + } + }, + { + "from": { + "key_code": "f4" + }, + "to": { + "key_code": "launchpad" + } + }, + { + "from": { + "key_code": "f5" + }, + "to": { + "key_code": "illumination_decrement" + } + }, + { + "from": { + "key_code": "f6" + }, + "to": { + "key_code": "illumination_increment" + } + }, + { + "from": { + "key_code": "f7" + }, + "to": { + "key_code": "rewind" + } + }, + { + "from": { + "key_code": "f8" + }, + "to": { + "key_code": "play_or_pause" + } + }, + { + "from": { + "key_code": "f9" + }, + "to": { + "key_code": "fastforward" + } + }, + { + "from": { + "key_code": "f10" + }, + "to": { + "key_code": "mute" + } + }, + { + "from": { + "key_code": "f11" + }, + "to": { + "key_code": "volume_decrement" + } + }, + { + "from": { + "key_code": "f12" + }, + "to": { + "key_code": "volume_increment" + } + } + ], + "name": "External", + "selected": false, + "simple_modifications": [ + { + "from": { + "key_code": "caps_lock" + }, + "to": { + "key_code": "f18" + } + }, + { + "from": { + "key_code": "left_command" + }, + "to": { + "key_code": "left_option" + } + }, + { + "from": { + "key_code": "left_option" + }, + "to": { + "key_code": "left_command" + } + } + ], + "virtual_hid_keyboard": { + "caps_lock_delay_milliseconds": 0, + "keyboard_type": "ansi" + } + } + ] +} diff --git a/workstation/suntracker/suntracker.sh b/workstation/suntracker/suntracker.sh new file mode 100644 index 0000000..5718b76 --- /dev/null +++ b/workstation/suntracker/suntracker.sh @@ -0,0 +1,76 @@ +# ~/.utils/suntracker.sh + +#!/bin/bash +platform=`uname` + +begin_day='Mar 12' +end_day='Nov 11' +mycity=dallas + +# begin date/time checks +times=`curl -s "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22nome%2C%20$mycity%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys" | jq -r '.query.results[].astronomy'` +sunrise=`echo $times | jq -r '.sunrise'` +sunrise_hour=`echo $sunrise | awk '{print $1}' | tr ':' ' ' | awk '{print $1}'` +sunrise_minute=`echo $sunrise | awk '{print $1}' | tr ':' ' ' | awk '{print $2}'` +sunset=`echo $times | jq -r '.sunset'` +sunset_hour=`echo $sunset | awk '{print $1}' | tr ':' ' ' | awk '{print $1}'` +sunset_minute=`echo $sunset | awk '{print $1}' | tr ':' ' ' | awk '{print $2}'` +current_year=`date +%Y` +current_month=`date +%b` +current_day=`date +%d` +offset_setting=`date +%z | cut -c3` +sunrise_day=$current_day +sunset_day=$current_day +current_epoch=`date +%s` +begin_date=$begin_day +end_date=$end_day + +# retrieve epoch for daylight savings +if [ "$platform" == "Darwin" ]; then + begin_epoch=`date -jf "%b %d %Y" "$begin_date" +%s` + end_epoch=`date -jf "%b %d %Y" "$end_date" +%s` +fi +if [ $platform == "Linux" ]; then + begin_epoch=`date --date="$begin_date" +%s` + end_epoch=`date --date="$end_date" +%s` +fi + +if [ "$current_epoch" -ge "$begin_epoch" -a "$current_epoch" -le "$end_epoch" ]; then + offset=5 +else + offset=6 +fi +((offset=offset-offset_setting)) +((sunrise_hour_adj=sunrise_hour+offset+1)) +((sunset_hour_adj=sunset_hour+offset+11)) +if [ "$sunset_hour_adj" -gt 23 ]; then + ((sunset_hour_adj=sunset_hour_adj-24)) + ((sunset_day=current_day+1)) +fi + +sunrise_str=$sunrise_hour_adj':'$sunrise_minute' '$current_month' '$sunrise_day +sunset_str=$sunset_hour_adj':'$sunset_minute' '$current_month' '$sunset_day + +echo "sed -i -- 's/dark/light/g' ~/.yadr/vim/settings/yadr-appearance.vim" | at $sunrise_str +echo "sed -i -- 's/light/dark/g' ~/.yadr/vim/settings/yadr-appearance.vim" | at $sunset_str + +if [ "$?" != 0 ]; then + sed -i -- 's/light/dark/g' ~/.yadr/vim/settings/yadr-appearance.vim +fi + +if [ ! -e ~/.suntracker ]; then + touch ~/.suntracker + if [ "$platform" == "Darwin" ]; then + sunrise_epoch=`date -jf "%H:%M %b %d" "$sunrise_str" +%s` + sunset_epoch=`date -jf "%H:%M %b %d" "$sunset_str" +%s` + fi + if [ "$platform" == "Linux" ]; then + sunrise_epoch=`date --date="$sunrise_str" +%s` + sunset_epoch=`date --date="$sunset_str" +%s` + fi + if [ "$current_epoch" -ge "$sunrise_epoch" -a "$current_epoch" -le "$sunset_epoch" ]; then + sed -i -- 's/dark/light/g' ~/.yadr/vim/settings/yadr-appearance.vim + else + sed -i -- 's/light/dark/g' ~/.yadr/vim/settings/yadr-appearance.vim + fi +fi