diff --git a/dotfiles/emacs.d b/dotfiles/emacs.d
index a7d48a26..d56004fd 160000
--- a/dotfiles/emacs.d
+++ b/dotfiles/emacs.d
@@ -1 +1 @@
-Subproject commit a7d48a261318561bf2df61f1a90d8998246d0e60
+Subproject commit d56004fd91e63328e62d944b02564c5646579394
diff --git a/dotfiles/lib/shellrc.sh b/dotfiles/lib/shellrc.sh
index 9da12c9b..f2b2bbfd 100644
--- a/dotfiles/lib/shellrc.sh
+++ b/dotfiles/lib/shellrc.sh
@@ -24,6 +24,7 @@ if is_osx; then
hash brew 2> /dev/null && export MANPATH="$(brew --prefix)/opt/coreutils/libexec/gnuman:$MANPATH"
else
export JAVA_HOME="$(update-alternatives --config java | get_cols ' -1' | head -n 1)"
+ is_osx && export VISUAL="which emacsclient -c -n"
fi
add_to_front_of_path "$JAVA_HOME/bin"
diff --git a/dotfiles/lib/shellrc/emacs.sh b/dotfiles/lib/shellrc/emacs.sh
index 75f54456..fd49c618 100644
--- a/dotfiles/lib/shellrc/emacs.sh
+++ b/dotfiles/lib/shellrc/emacs.sh
@@ -4,8 +4,7 @@ alias temacs='_emacs -t'
alias ec='_emacs -n '
function _emacs {
- local directory="$(git rev-parse --show-toplevel 2> /dev/null || pwd)"
- local server_name="$(_dot_directory $directory)"
+ local server_name="$(_current_dot_directory)"
if ! _emacs_daemon_exists "$server_name"; then
echo "Starting emacs with server name '$server_name'"
\emacs --daemon="$server_name"
@@ -20,3 +19,8 @@ function _emacs_daemon_exists {
function _dot_directory {
echo $1 | sed "s:/:.:g"
}
+
+function _current_dot_directory {
+ local directory="$(git rev-parse --show-toplevel 2> /dev/null || pwd)"
+ _dot_directory $directory
+}
diff --git a/dotfiles/lib/shellrc/exports.sh b/dotfiles/lib/shellrc/exports.sh
index d3d613ab..0e23ad55 100644
--- a/dotfiles/lib/shellrc/exports.sh
+++ b/dotfiles/lib/shellrc/exports.sh
@@ -4,9 +4,9 @@ elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM=xterm-256color
fi
# Make emacs the default editor.
-export EDITOR="emacsclient -cn"
+export EDITOR="$(which emacsclient) -t"
export ALTERNATE_EDITOR=""
-export VISUAL="emacsclient"
+export VISUAL="$EDITOR"
# Larger bash history (allow 32³ entries; default is 500)
export HISTSIZE=32768
@@ -24,3 +24,7 @@ export LESS_TERMCAP_md="$ORANGE"
# Don’t clear the screen after quitting a manual page
export MANPAGER="less -X"
+
+dircolors_file="$HOME/.dircolors"
+
+[ ! -z "$SHELL" ] && test -r $dircolors_files && eval "$(dircolors $dircolors_file)"
diff --git a/dotfiles/lib/shellrc/functions.sh b/dotfiles/lib/shellrc/functions.sh
index 79cf9a99..ab442f75 100644
--- a/dotfiles/lib/shellrc/functions.sh
+++ b/dotfiles/lib/shellrc/functions.sh
@@ -2,7 +2,6 @@ function dotfiles_directory() {
echo $(dirname `readlink -f ~/.zshrc | xargs dirname`)
}
-
function go2dotfiles() {
cd $(dotfiles_directory)
}
@@ -207,12 +206,6 @@ function pip_package_location() {
pip show $1 | grep Location | get_cols 2
}
-function set_modifier_keys_for_vendor_product_id() {
- local mapping="HIDKeyboardModifierMappingDst$3HIDKeyboardModifierMappingSrc$2"
- echo $mapping
- defaults -currentHost write -g com.apple.keyboard.modifiermapping.$1-0 -array-add "$mapping"
-}
-
function set_modifier_keys_on_all_keyboards() {
for vendor_product_id in $(get_keyboard_vendor_id_product_id_pairs | tr " " "-"); do
set_modifier_keys_for_vendor_product_id $vendor_product_id 0 2; echo $vendor_product_id;
@@ -223,25 +216,10 @@ function get_keyboard_vendor_id_product_id_pairs() {
ioreg -n IOHIDKeyboard -r | grep -e 'class IOHIDKeyboard' -e VendorID\" -e Product | gawk 'BEGIN { RS = "class IOHIDKeyboard" } match($0, /VendorID. = ([0-9]*)/, arr) { printf arr[1]} match($0, /ProductID. = ([0-9]*)/, arr) { printf " %s\n", arr[1]} '
}
-function ss() {
- osascript -e "tell application \"/System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app\" to activate"
-}
-
function git_config_string() {
git config -f $1 --list | xargs -I kv printf '-c \"%s\" ' kv
}
-function brew_for_multiple_users() {
- sudo chgrp -R admin /usr/local
- sudo chmod -R g+w /usr/local
- sudo chgrp -R admin /Library/Caches/Homebrew
- sudo chmod -R g+w /Library/Caches/Homebrew
-}
-
-function swap_audio() {
- test -z $(SwitchAudioSource -c | grep HDMI) && SwitchAudioSource -s HDMI || SwitchAudioSource -s "Built-in Output"
-}
-
function talk_dirty_to_me() {
python - <(cat) | say; done
}
-
-function as_user {
- local user="$1"
- local user_pid=$(ps -axj | awk "/^$user / {print \$2;exit}")
- local command="sudo /bin/launchctl bsexec $user_pid sudo -u '$user' $2"
- echo "Running:"
- echo "$command"
- eval $command
-}
-
-function as_current_user {
- as_user "$(whoami)" "$*"
-}
-
-function reload_user_agent {
- as_current_user /bin/launchctl unload "$1"
- as_current_user /bin/launchctl load "$1"
-}
-
-
-function reload_root_agent {
- as_user 'root' "/bin/launchctl unload '$1'"
- as_user 'root' "/bin/launchctl load '$1'"
-}
-
-function enable_access_for_assistive_devices {
- local bundle_identifier=$(/usr/libexec/PlistBuddy -c 'Print CFBundleIdentifier' "$1/Contents/Info.plist")
- local where_clause="where service='kTCCServiceAccessibility' and client='$bundle_identifier'"
- local search_string="SELECT * from access ${where_clause};"
- local values_string="VALUES('kTCCServiceAccessibility','$bundle_identifier',0,1,1,NULL)"
- if test -z $(sudo sqlite3 '/Library/Application Support/com.apple.TCC/TCC.db' $search_string);
- then
- local sql_string="INSERT INTO access $values_string;"
- else
- local sql_string="UPDATE access set allowed = 1 ${where_clause};"
- fi
- echo $sql_string
- sudo sqlite3 '/Library/Application Support/com.apple.TCC/TCC.db' $sql_string
-}
diff --git a/dotfiles/lib/shellrc/remote_clipboard.sh b/dotfiles/lib/shellrc/remote_clipboard.sh
index 23d9ec00..3f2b48e1 100644
--- a/dotfiles/lib/shellrc/remote_clipboard.sh
+++ b/dotfiles/lib/shellrc/remote_clipboard.sh
@@ -1,6 +1,6 @@
REMOTE_CLIPBOARD_PORT='1234'
-alias rc_ssh="ssh -R 1234:localhost:1234"
+alias rc_ssh="ssh -R 1234:localhost:1234 "
function remote_clipboard_server() {
while [ 1 ]
diff --git a/resources/python/but_one.py b/resources/python/but_one.py
new file mode 100644
index 00000000..8bda321f
--- /dev/null
+++ b/resources/python/but_one.py
@@ -0,0 +1,20 @@
+def left_partials(incoming):
+ product = 1
+ for i in incoming:
+ product *= i
+ yield product
+
+
+def but_one(incoming):
+ lpartials = list(left_partials(incoming))
+ rproduct = 1
+ result = [None]*len(incoming)
+ for i in range(len(incoming)):
+ back_index = len(incoming) - i - 1
+ if back_index > 0:
+ result[back_index] = rproduct * lpartials[back_index-1]
+ if back_index < len(incoming):
+ rproduct *= incoming[back_index]
+ else:
+ result[back_index] = rproduct
+ return result