Bump .emacs.d. move functions around.
This commit is contained in:
parent
abd4b70a7f
commit
b5f1542f9b
@ -1 +1 @@
|
||||
Subproject commit a7d48a261318561bf2df61f1a90d8998246d0e60
|
||||
Subproject commit d56004fd91e63328e62d944b02564c5646579394
|
@ -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"
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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)"
|
||||
|
@ -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="<dict><key>HIDKeyboardModifierMappingDst</key><integer>$3</integer><key>HIDKeyboardModifierMappingSrc</key><integer>$2</integer></dict>"
|
||||
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 - <<EOF
|
||||
from random import randrange
|
||||
@ -265,42 +243,3 @@ EOF
|
||||
function dirty_talk() {
|
||||
while true; do talk_dirty_to_me | tee >(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
|
||||
}
|
||||
|
@ -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 ]
|
||||
|
20
resources/python/but_one.py
Normal file
20
resources/python/but_one.py
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user