From cedee0b6782d63068a8e7ea7be1c152241e24090 Mon Sep 17 00:00:00 2001 From: Artem Sapegin Date: Sun, 10 Feb 2013 12:27:40 +0400 Subject: [PATCH 01/11] Setup: SSD tweaks script. --- setup/ssd.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 setup/ssd.sh diff --git a/setup/ssd.sh b/setup/ssd.sh new file mode 100755 index 0000000..66b666a --- /dev/null +++ b/setup/ssd.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# Some tweaks for SSD drives +# Details: http://blog.alutam.com/2012/04/01/optimizing-macos-x-lion-for-ssd/ + +# Ask for the administrator password upfront +sudo -v + +# Turn off local Time Machine snapshots [laptops only] +sudo tmutil disablelocal + +# Turn off hibernation [laptops only] +sudo pmset -a hibernatemode 0 +sudo command rm /var/vm/sleepimage + +# Turn off sudden motion sensor [no HDD only] +sudo pmset -a sms 0 + +# Disable records last access time for every file +echo ' + + + + Label + com.nullvision.noatime + ProgramArguments + + mount + -vuwo + noatime + / + + RunAtLoad + + +' | sudo tee /Library/LaunchDaemons/com.nullvision.noatime.plist +sudo chown root:wheel /Library/LaunchDaemons/com.nullvision.noatime.plist + +# Delay (180 minutes) hard drive sleep [no HDD only] +sudo pmset -b disksleep 180 # Battery +sudo pmset -c disksleep 180 # Power adapter + + +echo +echo "You need to restart your computer for the changes to take effect." \ No newline at end of file From 4d46755ae2f9327009bd119da031cb043a99f0ac Mon Sep 17 00:00:00 2001 From: Artem Sapegin Date: Sun, 10 Feb 2013 12:27:51 +0400 Subject: [PATCH 02/11] OSX: Few tweaks. --- setup/osx.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/setup/osx.sh b/setup/osx.sh index 4cc1df9..0d3b3bc 100755 --- a/setup/osx.sh +++ b/setup/osx.sh @@ -317,17 +317,18 @@ defaults write com.apple.dock expose-group-by-app -bool false # Don’t show Dashboard as a Space defaults write com.apple.dock dashboard-in-overlay -bool true -# Remove the auto-hiding Dock delay -defaults write com.apple.Dock autohide-delay -float 0 -# Remove the animation when hiding/showing the Dock -defaults write com.apple.dock autohide-time-modifier -float 0 - # Enable the 2D Dock defaults write com.apple.dock no-glass -bool true # Automatically hide and show the Dock defaults write com.apple.dock autohide -bool true +# Remove the Delay when Showing and Hiding the Dock +defaults write com.apple.dock autohide-delay -float 0 + +# Remove the animation when hiding/showing the Dock +defaults write com.apple.dock autohide-time-modifier -float 0 + # Make Dock icons of hidden applications translucent #defaults write com.apple.dock showhidden -bool true @@ -337,6 +338,9 @@ defaults write com.apple.dock no-bouncing -bool true # Disable Space switching on Command-Tab defaults write com.apple.dock workspaces-auto-swoosh -bool false +# Show only active applications +defaults write com.apple.dock static-only -bool TRUE + # Reset Launchpad find ~/Library/Application\ Support/Dock -name "*.db" -maxdepth 1 -delete @@ -377,6 +381,9 @@ defaults write -g WebContinuousSpellCheckingEnabled -boolean true /usr/libexec/PlistBuddy "$HOME/Library/Preferences/com.apple.symbolichotkeys.plist" -c 'Delete AppleSymbolicHotKeys:65' > /dev/null 2>&1 /usr/libexec/PlistBuddy "$HOME/Library/Preferences/com.apple.symbolichotkeys.plist" -c 'Add AppleSymbolicHotKeys:65:enabled bool false' +# Remove Spotlight from menu bar +sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search + ############################################################################### # Safari & WebKit # ############################################################################### From b9a475fc4f2b836a82025b2a61760c8a17dc2562 Mon Sep 17 00:00:00 2001 From: Artem Sapegin Date: Mon, 11 Feb 2013 00:14:12 +0400 Subject: [PATCH 03/11] Bash: tweak and rename ssh-add-host alias. --- includes/bash_functions.bash | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/bash_functions.bash b/includes/bash_functions.bash index cf97ac5..4e24a51 100644 --- a/includes/bash_functions.bash +++ b/includes/bash_functions.bash @@ -111,14 +111,15 @@ ssh-key() { # Create an SSH key and uploads it to the given host # Based on https://gist.github.com/1761938 -add-ssh-host() { +ssh-add-host() { username=$1 hostname=$2 identifier=$3 if [[ "$identifier" == "" ]] || [[ "$username" == "" ]] || [[ "$hostname" == "" ]]; then - echo "Usage: configure_ssh_host " + echo "Usage: ssh-add-host " else + header "Generating key..." if [ ! -f "$HOME/.ssh/$identifier.id_rsa" ]; then ssh-keygen -f ~/.ssh/$identifier.id_rsa -C "$USER $(date +'%Y/%m%/%d %H:%M:%S')" fi @@ -127,6 +128,7 @@ add-ssh-host() { echo -e "Host $identifier\n\tHostName $hostname\n\tUser $username\n\tIdentityFile ~/.ssh/$identifier.id_rsa" >> ~/.ssh/config fi + header "Uploading key..." ssh $identifier 'mkdir -p .ssh && cat >> ~/.ssh/authorized_keys' < ~/.ssh/$identifier.id_rsa.pub tput bold; ssh -o PasswordAuthentication=no $identifier true && { tput setaf 2; echo "SSH key added."; } || { tput setaf 1; echo "Failure"; }; tput sgr0 From c7333efbb5ce506da1c806221dafda745f461ab3 Mon Sep 17 00:00:00 2001 From: Artem Sapegin Date: Mon, 11 Feb 2013 00:14:30 +0400 Subject: [PATCH 04/11] Bash: add note to Notes.app alias. --- includes/bash_functions.bash | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/includes/bash_functions.bash b/includes/bash_functions.bash index 4e24a51..67fa197 100644 --- a/includes/bash_functions.bash +++ b/includes/bash_functions.bash @@ -242,6 +242,27 @@ function rasterize() { fi } +# Add note to Notes.app (OS X 10.8) +# Usage: note "foo" or echo "foo" | note +function note() { + local text + if [ -t 0 ]; then # Argument + text="$1" + else # Pipe + text=$(cat) + fi + body=$(echo "$text" | sed -E 's|$|
|g') + osascript >/dev/null < Date: Mon, 11 Feb 2013 00:14:51 +0400 Subject: [PATCH 05/11] Python. --- setup/stuff.sh | 1 + tilde/bash_profile.bash | 1 + 2 files changed, 2 insertions(+) diff --git a/setup/stuff.sh b/setup/stuff.sh index 56f27c6..6593d05 100755 --- a/setup/stuff.sh +++ b/setup/stuff.sh @@ -64,6 +64,7 @@ npm install -g jshint npm install -g bower # Python +brew install python sudo pip install fabric # Remove outdated versions from the cellar diff --git a/tilde/bash_profile.bash b/tilde/bash_profile.bash index dbf2414..1cae8bb 100644 --- a/tilde/bash_profile.bash +++ b/tilde/bash_profile.bash @@ -40,6 +40,7 @@ function _prepend_path() { # Extend $PATH [ -d /usr/local/bin ] && _prepend_path "/usr/local/bin" +[ -d /usr/local/share/python ] && _prepend_path "/usr/local/share/python" [ -d /usr/local/share/npm/bin ] && _prepend_path "/usr/local/share/npm/bin" command -v brew >/dev/null 2>&1 && _prepend_path "$(brew --prefix coreutils)/libexec/gnubin" [ -d ~/dotfiles/bin ] && _prepend_path "$HOME/dotfiles/bin" From 060cc46a9652995358bb8f9eabbe894c10969664 Mon Sep 17 00:00:00 2001 From: Artem Sapegin Date: Tue, 12 Feb 2013 00:21:36 +0400 Subject: [PATCH 06/11] Any to Mobi: convert to old MOBI format to force left text alignment. --- bin/anytomobi | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) mode change 100644 => 100755 bin/anytomobi diff --git a/bin/anytomobi b/bin/anytomobi old mode 100644 new mode 100755 index 08c57aa..65a73d9 --- a/bin/anytomobi +++ b/bin/anytomobi @@ -22,22 +22,16 @@ function convert_file() { local infilename=$(basename "$1") local outfilename="${infilename%.*}.mobi" - if [[ "$intype" == "mobi" || "$intype" == "pdf" ]]; then - # Just copy MOBI and PDF files to destination directory + if [[ "$intype" == "pdf" ]]; then + # Just copy PDF files to destination directory if [[ "$outdir" != "." ]]; then cp "$infile" "$outdir/" fi return - elif [[ "$intype" == "epub" ]]; then - kindlegen "$infile" -o "$outfilename" - # kindlegen can’t save file to other directory, so we should move it - if [[ "$outdir" != "." ]]; then - mv "${infile%.*}.mobi" "$outdir/" - fi else - ebook-convert "$infile" "$outdir/$outfilename" --output-profile=kindle_pw --mobi-file-type=new \ - --mobi-ignore-margins --mobi-keep-original-images \ - --no-inline-toc --no-inline-fb2-toc --remove-paragraph-spacing \ + # Convert any other format (MOBI too) to old MOBI format to force left text alignment + ebook-convert "$infile" "$outdir/$outfilename" --output-profile=kindle_pw --mobi-file-type=old \ + --mobi-ignore-margins --mobi-keep-original-images --no-inline-toc --remove-paragraph-spacing \ --change-justification=left --keep-ligatures --smarten-punctuation --pretty-print fi @@ -64,6 +58,6 @@ if [[ -f "$1" ]]; then elif [[ -d "$1" ]]; then convert_dir "$1" else - echo "Usage: anytomobi [destination folder]" + echo "Usage: `basename $0` [destination folder]" exit 1 fi From 85229709439f8303bb4904dea1365d49482fe9db Mon Sep 17 00:00:00 2001 From: Artem Sapegin Date: Tue, 12 Feb 2013 00:21:51 +0400 Subject: [PATCH 07/11] Ack. --- includes/bash_aliases.bash | 1 + setup/stuff.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/includes/bash_aliases.bash b/includes/bash_aliases.bash index e9e2e2e..297dff4 100644 --- a/includes/bash_aliases.bash +++ b/includes/bash_aliases.bash @@ -17,6 +17,7 @@ alias oo="open ." alias e="subl" alias gh="github" alias +x="chmod +x" +alias g="ack -ri" # Detect which `ls` flavor is in use if ls --color > /dev/null 2>&1; then # GNU `ls` diff --git a/setup/stuff.sh b/setup/stuff.sh index 6593d05..ff85dbf 100755 --- a/setup/stuff.sh +++ b/setup/stuff.sh @@ -55,6 +55,7 @@ cd - # Everything else brew install unrar +brew install ack # Node.js brew install node From dbbd24e1c541fcf75502f9cd725292c8d19be15a Mon Sep 17 00:00:00 2001 From: Artem Sapegin Date: Tue, 12 Feb 2013 00:22:00 +0400 Subject: [PATCH 08/11] Setup: grunt-init. --- setup/stuff.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/setup/stuff.sh b/setup/stuff.sh index ff85dbf..a75607e 100755 --- a/setup/stuff.sh +++ b/setup/stuff.sh @@ -61,6 +61,7 @@ brew install ack brew install node brew install casperjs npm install -g grunt-cli +npm install -g grunt-init npm install -g jshint npm install -g bower From 92a3c0c8d93401fb00f44a7d7702fd33504ef268 Mon Sep 17 00:00:00 2001 From: Artem Sapegin Date: Tue, 12 Feb 2013 00:26:42 +0400 Subject: [PATCH 09/11] Any to Mobi: remove link to Kinglegen. --- bin/anytomobi | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/anytomobi b/bin/anytomobi index 65a73d9..0f660bd 100755 --- a/bin/anytomobi +++ b/bin/anytomobi @@ -7,7 +7,6 @@ # Author: Artem Sapegin, sapegin.me # # Require: -# - KindleGen - http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211 # - Calibre - http://calibre-ebook.com/download # # Manuals: From 4de42d8e06664e6fac01871313dc6f65b54d064c Mon Sep 17 00:00:00 2001 From: Artem Sapegin Date: Tue, 12 Feb 2013 00:27:49 +0400 Subject: [PATCH 10/11] Any to Mobi: clarify readme. --- bin/anytomobi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/anytomobi b/bin/anytomobi index 0f660bd..adf27f4 100755 --- a/bin/anytomobi +++ b/bin/anytomobi @@ -7,7 +7,7 @@ # Author: Artem Sapegin, sapegin.me # # Require: -# - Calibre - http://calibre-ebook.com/download +# - Calibre - http://calibre-ebook.com/download (install command line tools from Calibre’s settings) # # Manuals: # - http://manual.calibre-ebook.com/cli/ebook-convert.html From a9e4a065d31ec9a4b23eb9da63cfed110b7f73c7 Mon Sep 17 00:00:00 2001 From: Artem Sapegin Date: Tue, 12 Feb 2013 00:53:38 +0400 Subject: [PATCH 11/11] Any to Mobi: remove text color. --- bin/anytomobi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/anytomobi b/bin/anytomobi index adf27f4..edb90c2 100755 --- a/bin/anytomobi +++ b/bin/anytomobi @@ -31,7 +31,7 @@ function convert_file() { # Convert any other format (MOBI too) to old MOBI format to force left text alignment ebook-convert "$infile" "$outdir/$outfilename" --output-profile=kindle_pw --mobi-file-type=old \ --mobi-ignore-margins --mobi-keep-original-images --no-inline-toc --remove-paragraph-spacing \ - --change-justification=left --keep-ligatures --smarten-punctuation --pretty-print + --change-justification=left --keep-ligatures --smarten-punctuation --pretty-print --filter-css=color fi echo