Skip to content

Instantly share code, notes, and snippets.

@aaronsaunders
Last active December 26, 2015 13:49
Show Gist options
  • Select an option

  • Save aaronsaunders/7161117 to your computer and use it in GitHub Desktop.

Select an option

Save aaronsaunders/7161117 to your computer and use it in GitHub Desktop.

Revisions

  1. aaronsaunders revised this gist Oct 25, 2013. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion .Rprofile
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    # from https://gist.github.com/stephenturner/5700920
    # http://inundata.org/2011/09/29/customizing-your-rprofile/

    ## Returns names(df) in single column, numbered matrix format.
    .env$n <- function(df) matrix(names(df))

    @@ -21,4 +23,4 @@ library(plyr)
    .First <- function() {
    # library(ggplot2)
    cat("\nSuccessfully loaded .Rprofile at", date(), "\n")
    }
    }
  2. aaronsaunders renamed this gist Oct 25, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. aaronsaunders revised this gist Oct 25, 2013. No changes.
  4. aaronsaunders created this gist Oct 25, 2013.
    24 changes: 24 additions & 0 deletions .Rprofile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    # from https://gist.github.com/stephenturner/5700920
    ## Returns names(df) in single column, numbered matrix format.
    .env$n <- function(df) matrix(names(df))

    # Shorten S3 methods so s(obj) instead of summary(obj)
    s <- base::summary;
    h <- utils::head;
    n <- base::names;

    ## ht==headtail, i.e., show the first and last 10 items of an object
    .env$ht <- function(d) rbind(head(d,10),tail(d,10))

    ## Show the first 5 rows and first 5 columns of a data frame or matrix
    .env$hh <- function(d) if(class(d)=="matrix"|class(d)=="data.frame") d[1:5,1:5

    library(ggplot2)
    library(plyr)

    ## .First() run at the start of every R session.
    ## Use to load commonly used packages?
    .First <- function() {
    # library(ggplot2)
    cat("\nSuccessfully loaded .Rprofile at", date(), "\n")
    }
    122 changes: 122 additions & 0 deletions .bashrc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,122 @@
    # ~/.bashrc: executed by bash(1) for non-login shells.
    # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
    # for examples

    # If not running interactively, don't do anything
    case $- in
    *i*) ;;
    *) return;;
    esac

    # don't put duplicate lines or lines starting with space in the history.
    # See bash(1) for more options
    HISTCONTROL=ignoreboth

    # append to the history file, don't overwrite it
    shopt -s histappend

    # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
    HISTSIZE=1000
    HISTFILESIZE=2000

    # check the window size after each command and, if necessary,
    # update the values of LINES and COLUMNS.
    shopt -s checkwinsize

    # If set, the pattern "**" used in a pathname expansion context will
    # match all files and zero or more directories and subdirectories.
    #shopt -s globstar

    # make less more friendly for non-text input files, see lesspipe(1)
    [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

    # set variable identifying the chroot you work in (used in the prompt below)
    if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
    fi

    # set a fancy prompt (non-color, unless we know we "want" color)
    case "$TERM" in
    xterm-color) color_prompt=yes;;
    esac

    # uncomment for a colored prompt, if the terminal has the capability; turned
    # off by default to not distract the user: the focus in a terminal window
    # should be on the output of commands, not on the prompt
    #force_color_prompt=yes

    if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
    # We have color support; assume it's compliant with Ecma-48
    # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
    # a case would tend to support setf rather than setaf.)
    color_prompt=yes
    else
    color_prompt=
    fi
    fi

    if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
    fi
    unset color_prompt force_color_prompt

    # If this is an xterm set the title to user@host:dir
    case "$TERM" in
    xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
    *)
    ;;
    esac

    # enable color support of ls and also add handy aliases
    if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
    fi


    # Add an "alert" alias for long running commands. Use like so:
    # sleep 10; alert
    alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

    # Alias definitions.
    # You may want to put all your additions into a separate file like
    # ~/.bash_aliases, instead of adding them here directly.
    # See /usr/share/doc/bash-doc/examples in the bash-doc package.

    if [ -f ~/.bash_aliases ]; then
    . ~/Dropbox/.bash_aliases
    fi

    # enable programmable completion features (you don't need to enable
    # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
    # sources /etc/bash.bashrc).
    if ! shopt -oq posix; then
    if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
    elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
    fi
    fi

    ###########################################################
    # ams custom

    export PATH=$PATH:"~/opt/todo.txt-cli-2.9/"
    alias t="todo.sh -d ~/opt/todo.txt-cli-2.9/todo.cfg"
    export TODOTXT_DEFAULT_ACTION=ls

    # added by Anaconda 1.6.1 installer
    export PATH="/opt/anaconda/bin:$PATH"

    export EDITOR='emacsclient'
    166 changes: 166 additions & 0 deletions .emacs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,166 @@
    (setq user-full-name "Aaron Saunders"
    user-mail-address "[email protected]")
    ;; Start page
    (server-start)

    ;; PARAMETERS
    ;; set $PATH variable in emacs to match .bashrc
    ;; http://samrelton.wordpress.com/2013/09/26/emacs-and-anaconda-python/
    (defun set-exec-path-from-shell-PATH ()
    (interactive)
    (let ((path-from-shell (replace-regexp-in-string "^.*\n.*shell\n" "" (shell-command-to-string "$SHELL --login -i -c 'echo $PATH'"))))
    (setenv "PATH" path-from-shell)
    (setq exec-path (split-string path-from-shell path-separator))))
    (set-exec-path-from-shell-PATH)

    (setq inhibit-startup-message t
    inhibit-startup-echo-area-message t)
    ;; disable that minize window thing
    (global-unset-key "\C-x\C-z")
    ;; require final new line
    (setq require-final-newline t)
    ;; display time
    (setq display-time-24hr-format t)
    (display-time)
    ;; global indent new line
    (define-key global-map (kbd "RET") 'newline-and-indent)
    (custom-set-variables
    ;; custom-set-variables was added by Custom.
    ;; If you edit it by hand, you could mess it up, so be careful.
    ;; Your init file should contain only one such instance.
    ;; If there is more than one, they won't work right.
    '(browse-url-browser-function (quote browse-url-generic))
    '(browse-url-generic-program "google-chrome")
    '(display-time-mode t)
    '(org-agenda-files (quote ("~/Dropbox/todo/todo.org" "~/Dropbox/todo/core-paper.org" "~/Dropbox/todo/experiments.org")))
    '(org-file-apps (quote ((auto-mode . emacs) ("\\.mm\\'" . default) ("\\.x?html?\\'" . default) ("\\.pdf\\'" . default) (directory . default) ("\\.ods\\'" . default) ("\\.csv\\'" . default) ("\\.tab\\'" . "gnumeric %s") ("\\.tsv\\'" . "gnumeric %s"))))
    '(show-paren-mode t)
    '(tool-bar-mode nil))
    (custom-set-faces
    ;; custom-set-faces was added by Custom.
    ;; If you edit it by hand, you could mess it up, so be careful.
    ;; Your init file should contain only one such instance.
    ;; If there is more than one, they won't work right.
    '(default ((t (:inherit nil :stipple nil :background "#141414" :foreground "#F8F8F8" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 98 :width normal :foundry "unknown" :family "DejaVu Sans Mono")))))


    ;; SHORTCUTS & key Mappings
    ;; y & n for yes and no
    (fset 'yes-or-no-p 'y-or-n-p)
    (tool-bar-mode -1)

    (defun insert-date ()
    (interactive)
    (insert (format-time-string "%Y-%m-%d")))
    (defun insert-timestamp ()
    (interactive)
    (insert (format-time-string "%Y-%m-%d %H:%M")))

    (global-set-key (kbd "C-c d") 'insert-date)
    (global-set-key (kbd "C-c t") 'insert-timestamp)

    ;; goto-line meta g
    (global-set-key "\M-g" 'goto-line)
    ;; disable ctrl Z
    (global-unset-key "\^z")

    (setq tetris-score-file
    "~/.emacs.d/tetris-scores")

    ;; MODES
    ;; set load path
    (add-to-list 'load-path "~/.emacs.d/")

    ;; Package management
    (require 'package)
    ;; Any add to list for package-archives (to add marmalade or melpa) goes here
    (add-to-list 'package-archives
    '("marmalade" .
    "http://marmalade-repo.org/packages/"))
    (add-to-list 'package-archives
    '("melpa" . "http://melpa.milkbox.net/packages/") t)
    (when (< emacs-major-version 24)
    (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
    (package-initialize)

    (require 'better-defaults)

    ;; org mode http://orgmode.org/
    (add-to-list 'load-path "~/.emacs.d/org-8.1.1/lisp")
    (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
    (global-set-key "\C-cl" 'org-store-link)
    (global-set-key "\C-cc" 'org-capture)
    (global-set-key "\C-ca" 'org-agenda)
    (global-set-key "\C-cb" 'org-iswitchb)
    (require 'org-journal)
    (setq org-journal-dir "/home/ams/Dropbox/docs/work-journal")

    ;; Markdown mode
    ;; http://jblevins.org/projects/maRkdown-Mode/
    (autoload 'markdown-mode "markdown-mode"
    "Major mode for editing Markdown files" t)
    (add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
    (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
    (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))

    ;; Color Theme Mode
    (require 'color-theme)
    (color-theme-initialize)
    (add-to-list 'load-path "~/.emacs.d/emacs-color-theme-solarized-master")
    (require 'color-theme-solarized)
    ;(load-file "~/.emacs.d/color-theme-subdued.el")

    ;; ##########
    ;; PYTHON

    ;; python-mode
    (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
    (add-to-list 'interpreter-mode-alist '("ipython" . python-mode))
    (setq py-install-directory "~/.emacs.d/python-mode.el-6.1.2")
    (add-to-list 'load-path py-install-directory)
    (load "~/.emacs.d/python-mode.el-6.1.2/python-mode.el")

    ;; Make IPython the default shell
    ;;(require 'ipython)
    (defvar py-mode-map python-mode-map)
    (setq
    python-shell-interpreter "ipython"
    python-shell-interpreter-args ""
    python-shell-prompt-regexp "In \\[[0-9]+\\]: "
    python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: "
    python-shell-completion-setup-code
    "from IPython.core.completerlib import module_completion"
    python-shell-completion-module-string-code
    "';'.join(module_completion('''%s'''))\n"
    python-shell-completion-string-code
    "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
    ;; IPython command line args
    ;; use –colors=LightBG if you have a white background
    ;; –pylab automatically imports all pylab functions
    (add-hook 'python-mode-hook
    (lambda ()
    (setq py-python-command-args (quote ("–colors=Linux" "-i" "–pylab")))))
    ;; Custom Keybinds
    (add-hook 'python-mode-hook
    (lambda ()
    (local-set-key (kbd "C-c p") 'pylint)
    (local-set-key (kbd "C-c o") 'pep8)
    (local-set-key (kbd "C-c i") 'ipython)
    ))

    ; use the wx backend, for both mayavi and matplotlib
    (setq py-python-command-args
    '("--gui=wx" "--pylab=wx" "-colors" "Linux"))
    (setq py-force-py-shell-name-p t)

    ; switch to the interpreter after executing code
    (setq py-shell-switch-buffers-on-execute-p t)
    (setq py-switch-buffers-on-execute-p t)
    ; don't split windows
    (setq py-split-windows-on-execute-p t)
    ; try to automagically figure out indentation
    (setq py-smart-indentation t)


    (put 'dired-find-alternate-file 'disabled nil)