Skip to content

Instantly share code, notes, and snippets.

@knubie
knubie / .tmux.conf
Last active September 13, 2017 10:12
Experimental zsh/tmux set up. Display CWD/vim file and git repo information in the tmux status bar.
# Update the status bar by fetching an environment variable set earlier by a shell script.
# Requires Thomas Adam's hook patch for tmux
# https://github.com/ThomasAdam/tmux/tree/ta/hooks
set-hook -g -n 'after-select-window' 'run "tmux set -q status-left \"`tmux show -environment TMUX_STATUS_#I | cut -c 15-`\""'
set-hook -g -n 'after-kill-window' 'run "tmux set -q status-left \"`tmux show -environment TMUX_STATUS_#I | cut -c 15-`\""'
Entity = function (name, stats) {
this.ui = {
healthBar: $('<div id="healthBar" class="progress-bar progress-bar-danger"></div>')
manaBar: $('<div id="healthBar" class="progress-bar progress-bar-danger"></div>')
};
// Append UI
$('body').append(this.ui.healthBar);
$('body').append(this.ui.manaBar);
do ->
cache = {}
viewKey = 'ttView'
methods =
initialize: (datasetDefs) ->
datasetDefs = utils.isArray(datasetDefs) ? datasetDefs : [datasetDefs]
if datasetDefs.length == 0
$.error('no datasets provided')
JSGame.game = function(options) {
JSGame.initKeyboard();
$(document).ready(function() {
var defaults = {
// default options
fps: 60,
fullscreen: false,
width: 800,
@update = (collection, query, field, update) ->
# Set up this object to pass in to the mongo update method.
$set = {}
# Create the $set object for mongo's update method by passing
# the doc's 'field' to the 'update' argument.
$set[field] = _.compose(update, _.reduce) field.split('.')
, (memo, accessor) -> memo[accessor] # Get field from the doc.
, collection.findOne(query)
this.update = function(collection, query, field, update) {
// Set up this object to pass in to the mongo update method.
$set = {};
// Create the $set object for mongo's update method by passing
// the doc's 'field' to the 'update' argument.
$set[field] = _.compose(update, _.reduce)(field.split('.')
, function(memo, accessor) {
return memo[accessor] // Get field from the doc.
}, collection.findOne(query));
ptext = ptext.replace(/`([^`]*)`/g, "<code>$1</code>")
.replace(/\*\*([^\*]*)\*\*/g, "<strong>$1</strong>")
.replace(/\*([^\*]*)\*/g, "<em>$1</em>")
.replace(/_([^_]*)_/g, '<span class="underline">$1</span>')
.replace(/#(\d*[a-zA-Z_]+)/g, '<a href="/channels/$1">#$1</a>')
regexps = [
regexp: /`([^`]*)`/g
flag: 'code'
,
regexp: /\*\*([^\*]*)\*\*/g
flag: 'bold'
,
regexp: /\*([^\*]*)\*/g
flag: 'em'
,
regexps =
code: regex.code
url: regex.url
channel: regex.channel
parse = (str) ->
strings = [{text: str}]
for name, regexp of regexps
for string, i in strings
if not string.token? and matches = string.text.match regexp
do -> do factorial = (n = 5) ->
if n <= 1 then 1 else n * factorial(n-1)