Skip to content

Instantly share code, notes, and snippets.

View afternoon's full-sized avatar

Ben Godfrey afternoon

View GitHub Profile
@afternoon
afternoon / clone_definitelytyped.sh
Created February 15, 2014 18:03
Clone DefinitelyTyped
git clone [email protected]:borisyankov/DefinitelyTyped.git references
@afternoon
afternoon / install_typescript.sh
Created February 15, 2014 18:03
Install TypeScript
npm install --global typescript
@afternoon
afternoon / .vimrc
Created February 15, 2014 18:01
Line bubble mappings with indent repair
if has("gui_macvim")
" move lines up and down and reindent correctly (clashes with quickfix menu
" mappings in runtime/menu.vim, so we remove those mappings first)
macm Tools.Older\ List key=<nop>
macm Tools.Newer\ List key=<nop>
nnoremap <D-C-Up> ddkPV=<Esc>
nnoremap <D-C-Down> ddpgV=<Esc>
vnoremap <D-C-Up> :move '<-2<CR>gv=gv
vnoremap <D-C-Down> :move '>+1<CR>gv=gv
endif
@afternoon
afternoon / .vimrc
Created February 15, 2014 18:00
Line bubble mappings with MacVim boilerplate
if has("gui_macvim")
" move lines up and down and reindent correctly (clashes with quickfix menu
" mappings in runtime/menu.vim, so we remove those mappings first)
macm Tools.Older\ List key=<nop>
macm Tools.Newer\ List key=<nop>
nnoremap <D-C-Up> V:move '<-2<CR><Esc>
nnoremap <D-C-Down> V:move '>+1<CR><Esc>
vnoremap <D-C-Up> :move '<-2<CR>gv
vnoremap <D-C-Down> :move '>+1<CR>gv
endif
@afternoon
afternoon / .vimrc
Created February 15, 2014 17:59
Improved line bubble mappings
nnoremap <D-C-Up> V:move '<-2<CR><Esc>
nnoremap <D-C-Down> V:move '>+1<CR><Esc>
vnoremap <D-C-Up> :move '<-2<CR>gv
vnoremap <D-C-Down> :move '>+1<CR>gv
@afternoon
afternoon / .vimrc
Created February 15, 2014 17:58
Naive line bubble mappings
nnoremap <D-C-Up> ddkP
nnoremap <D-C-Down> ddp
@afternoon
afternoon / vimtips.mkd
Last active December 29, 2015 02:08
Vim tips

Vim Tips

Some Vim commands available in my config.

Built-in

  • Fix indentation: = (visual), `== (normal)
  • Thesaurus: ctrl-x ctrl-t
@afternoon
afternoon / online.js
Created September 12, 2013 09:06
Detect if browser is online in Trigger Forge and standard browser env
function online() {
// detect forge
if (typeof forge !== "undefined" && forge !== null) {
return forge.is.connection.connected();
}
else if {
return navigator.onLine;
}
else {
return true;
@afternoon
afternoon / StaticScalatraServlet.scala
Created May 1, 2013 12:36
Example Scalatra servlet that serves static content. You probably don't want to use Scalatra to serve static HTML unless you're also doing something dynamic like authentication, but here's the example anyway. Note that Jetty will serve directory indexes by default.
import java.io.File
import org.scalatra.{InternalServerError, NotFound, ScalatraServlet}
class StaticScalatraServlet extends ScalatraServlet {
def html(path: String) = {
contentType = "text/html"
new File(getServletContext.getResource(path).getFile)
}
notFound {
@afternoon
afternoon / gist:5481037
Created April 29, 2013 11:23
Non-functional setup, config and convenience methods for a Scalatra-powered JSON API.
import org.joda.time.DateTime
import org.json4s.ext.JodaTimeSerializers
import org.json4s.{Serializer, DefaultFormats, Formats, JValue}
import org.scalatra._
import org.scalatra.json._
import org.scalatra.util.conversion.BigDecimalImplicitConversions._
import org.slf4j.LoggerFactory
trait ApiStack
extends ScalatraServlet