Skip to content

Instantly share code, notes, and snippets.

@latentflip
latentflip / gf.md
Last active April 14, 2021 03:29
vim, gf, and node

Vim, gf and node.

So, I just learned that gf exists. If your cursor is over a path in vim, and you type gf, it'll open that file/dir in a new buffer. You can also open in a new window/tab as detailed here.

In node, it'd be great if you could jump to a required file, huh? Trouble is, typically you don't put the .js on your require('./path/to/a/js/file'). No matter, vim has your back, just add set suffixesadd+=.js to your .vimrc and vim will try adding .js and see if it can find that file instead.

If you do a lot of spelunking in node_modules, it'd be great if you could jump to the directory of a required npm module too, right? A la, require('my-awesome-module'). Well, you can add set path+=$PWD/node_modules to your .vimrc too, and vim will add node_modules to the path, and jump to it's directory in node_modules (caveat: you must have opened vim from your project root for this too work).

For your cmd+c convenience:

@latentflip
latentflip / 1-description.md
Created April 27, 2012 10:27
Fancy split navigation with vim and tmux
  • In vim I have split navigation mapped to ctrl+h/j/k/l.
  • In tmux I navigate splits with prefix + ctrl+h/j/k/l.
  • Ideally I would be able to navigate between vim and tmux splits transparently using only ctrl+h/j/k/l.
  • I haven't figured that out yet, but I have figured out how to jump out of vim into the next tmux split if I am at the boundary of vim and tmux, without having to prefix jump, which is pretty ace. ie:
    *=cursor position
    
    -----------            -----------            -----------                  -----------
@latentflip
latentflip / game_of_life.coffee
Created October 28, 2012 22:52 — forked from joejag/game_of_life.coffee
Conways Game of Life in CoffeeScript
# Utility methods
flatten_nested_array = (array) ->
[].concat array...
includes = (item, coll) ->
item = key_to_array(item)
for potential_match in coll
return true if item[0] == potential_match[0] && item[1] == potential_match[1]
false
<head>
<!-- this will run -->
<style nonce='1234'>
.a {
color: red;
}
</style>
<!-- this won't run -->
<style>

Keybase proof

I hereby claim:

  • I am latentflip on github.
  • I am latentflip (https://keybase.io/latentflip) on keybase.
  • I have a public key ASBI6Z-jWtGaqeuOQNOJzfjfMbDQQVl26r7h8JHSTm3_2wo

To claim this, I am signing this object:

@latentflip
latentflip / README.md
Created May 3, 2012 10:44
Loads a random mix from sonicrouter

Short for music? try a random sonicrouter mix

  • Stick sonicrouter.rb in your path, or curl https://raw.github.com/gist/2584960/7a8433fc0477ad388fc09af0b5ef6501d595c085/sonicrouter.rb > /somewhere/in/your/path/sonicrouter

  • Rename it sonicrouter (it's named .rb so gist syntax highlights it)

  • Type sonicrouter at a terminal.

  • Or if you are really lazy, just alias this command: curl https://raw.github.com/gist/2584960/7a8433fc0477ad388fc09af0b5ef6501d595c085/sonicrouter.rb | ruby

Bonus feature

@latentflip
latentflip / Instrumentor.coffee
Created October 27, 2012 12:21
Instrumentor
#depends on underscore
_.isConstructor = (thing) ->
if thing.name && thing.name[0].toUpperCase() == thing.name[0]
true
else
false
class Instrumentor
constructor: (namespace) ->
@latentflip
latentflip / notes.md
Created July 4, 2012 20:47
This is ridiculous, never ever do this.

So @MattWynne totally nerd-sniped me this evening, by asking this:

Is is possible to dynamically add ActiveModel::Naming compliance to an object at runtime? My meta-fu is letting me down.

As far as I can figure out, it's not doable, but I can get 'pretty' close, here's what I learned:

@latentflip
latentflip / 1-description.md
Last active August 1, 2017 01:12
easy clone github

A simple repo clone script for a less messy ~/projects dir

I always end up with a messy projects dir. @paddyforan suggested go's structure which is something like:

$GOPATH/src/github.com/{username}/{repo} 

I've gone for:

@latentflip
latentflip / Instrumentor.js
Created October 27, 2012 12:20
Instrumentor
#depends on underscore
_.isConstructor = (thing) ->
if thing.name && thing.name[0].toUpperCase() == thing.name[0]
true
else
false
class Instrumentor
constructor: (namespace) ->