Skip to content

Instantly share code, notes, and snippets.

View tsdeng's full-sized avatar

Tianshuo Deng tsdeng

View GitHub Profile
@tsdeng
tsdeng / install_tensorflow_macos.sh
Last active July 7, 2023 05:29
Install tensorflow, tensorflow-text and tensorflow-models on MacOS. The major PITA is tensorflow-text which does not release a wheel for apple silicon. So the script build the wheel from source.
function usage() {
cat <<EOF
Usage: $(basename $0) [-h|--help]
Description:
Install tensorflow, tensorflow-text and tf-models-official on macos.
Notice tensorflow-addon is deprecated: https://github.com/tensorflow/addons/issues/2807
-h Show help.
-v Show tf versions.
EOF
}
@tsdeng
tsdeng / repeat-other-window.el
Created February 21, 2016 03:17
make other-window command in emacs repeatable, this may save your pinky a bit
(require 'repeat)
(defun make-repeatable-command (cmd)
"Returns a new command that is a repeatable version of CMD.
The new command is named CMD-repeat. CMD should be a quoted
command.
This allows you to bind the command to a compound keystroke and
repeat it with just the final key. For example:
(global-set-key (kbd \"C-c a\") (make-repeatable-command 'foo))
@tsdeng
tsdeng / emacs_scala.md
Last active June 26, 2018 16:43
Configure Emacs for Scala

Basic Support

  1. Install ctags-exuberant
  2. Install gnu global
    • brew install global --with-exuberant-ctags
    • add following line in bash export GTAGSCONF=/usr/local/share/gtags/gtags.conf
    • edit gtags.conf, in the exuberant-ctags section, add following line :langmap=Scala:.scala:\
@tsdeng
tsdeng / .ctags
Created January 16, 2014 06:43
scala emacs
--langdef=Scala
--langmap=Scala:.scala
--regex-Scala=/^[ \t]*class[ \t]*([a-zA-Z0-9_]+)/class \1/c,classes/
--regex-Scala=/^[ \t]*object[ \t]*([a-zA-Z0-9_]+)/object \1/o,objects/
--regex-scala=/^[ \t]*trait[ \t]*([a-zA-Z0-9_]+)/trait \1/t,traits/
--regex-Scala=/^[ \t]*case[ \t]*class[ \t]*([a-zA-Z0-9_]+)/case class \1/m,case-classes/
--regex-Scala=/^[ \t]*abstract[ \t]*class[ \t]*([a-zA-Z0-9_]+)/abstact class \1/a,abstract-classes/
--regex-Scala=/^[^\*\/]*def[ \t]*([a-zA-Z0-9_]+)[ \t]*.*[:=]/f \1/f,functions/
#--regex-Scala=/^[^\*\/]*val[ \t]*([a-zA-Z0-9_]+)[ \t]*[:=]/\1/V,values/
#--regex-Scala=/^[^\*\/]*var[ \t]*([a-zA-Z0-9_]+)[ \t]*[:=]/\1/v,variables/
@tsdeng
tsdeng / gist:7819812
Created December 6, 2013 07:15
scifi mode
(setq scifi-font-lock-keywords
'(
("library(name\\(\s?\\)=\\(\s?\\)['\"]\\([^']+\\)" (3 font-lock-keyword-face)) ;target name
("pants('\\([^']*\\)'" (1 font-lock-keyword-face t))
)
)
(defvar scifi-mode-hook nil "* pants mode.")
(defun scifi-mode () "scifi"
(interactive)
@tsdeng
tsdeng / gist:7478579
Last active June 26, 2018 15:14
let speed bar recognize scala file perfectly
1. create ~/.ctags as follows(notice for regexps I used ^[ \t] to excactly match):
--langdef=Scala
--langmap=Scala:.scala
--regex-Scala=/^[ \t]*class[ \t]*([a-zA-Z0-9_]+)/class \1/c,classes/
--regex-Scala=/^[ \t]*object[ \t]*([a-zA-Z0-9_]+)/object \1/o,objects/
--regex-scala=/^[ \t]*trait[ \t]*([a-zA-Z0-9_]+)/trait \1/t,traits/
--regex-Scala=/^[ \t]*case[ \t]*class[ \t]*([a-zA-Z0-9_]+)/case class \1/m,case-classes/
--regex-Scala=/^[ \t]*abstract[ \t]*class[ \t]*([a-zA-Z0-9_]+)/abstract class \1/a,abstract-classes/
--regex-Scala=/^[^\*\/]*def[ \t]*([a-zA-Z0-9_]+)[ \t]*.*[:=]/f \1/f,functions/
#--regex-Scala=/^[^\*\/]*val[ \t]*([a-zA-Z0-9_]+)[ \t]*[:=]/\1/V,values/
@tsdeng
tsdeng / speedbar-smart-jump
Created November 14, 2013 22:47
jump to speed bar and expand the current buffer, hopefully you will see an outline of methods defined in current buffer
(defun go-to-speedbar ()
(interactive)
(let ((f-name (buffer-name)))
(sr-speedbar-open)
(sr-speedbar-select-window)
(goto-line 1)
(search-forward-regexp (concat f-name "$"))
(speedbar-expand-line)
))
(global-set-key "\C-cs" 'go-to-speedbar)