Skip to content

Instantly share code, notes, and snippets.

View jackcviers's full-sized avatar

Jack Viers jackcviers

View GitHub Profile
@jackcviers
jackcviers / gitbashcompletion
Created December 21, 2011 18:18
Git bash status completion
#Git status completion add to your bash profile#
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
export PS1='\u@\h \[\033[1;33m\]\w\[\033[0m\]$(parse_git_branch)$ '
@jackcviers
jackcviers / .ctags
Created March 19, 2012 23:12
.ctags description for JavaScript and Coffeescript
--langdef=js
--langmap=js:.js
--regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\{/\1/,object/
--regex-js=/([A-Za-z0-9._$()]+)[ \t]*[:=][ \t]*function[ \t]*\(/\1/,function/
--regex-js=/function[ \t]+([A-Za-z0-9._$]+)[ \t]*\(([^)])\)/\1/,function/
--regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\[/\1/,array/
--regex-js=/([^= ]+)[ \t]*=[ \t]*[^"]'[^']*/\1/,string/
--regex-js=/([^= ]+)[ \t]*=[ \t]*[^']"[^"]*/\1/,string/
--langdef=coffee
--langmap=coffee:.coffee
@jackcviers
jackcviers / jquery_transport_selection.js
Created February 12, 2013 17:24
jQuery, like many other "ajax" frameworks, presents a common interface for asynchronous requests, and delegates to the underlying "real" request mechanism under the hood. In this way, all types of requests use the same semantics, while the jQuery authors are allowed to switch implementations under the hood. The convention is to select the transp…
// Base inspection function for prefilters and transports
function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
var inspected = {},
seekingTransport = ( structure === transports );
function inspect( dataType ) {
var selected;
inspected[ dataType ] = true;
jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
// Wrap the whole thing in domready and an anonymous function.
// This prevents anything inside of it from being clobbered
// in the global namespace and from clobbering anything
// in the global namespace.
// This is instead of defining the function globally and passing
// it to domready, like you did before:'
// $(function(){showLocation()});
$(function(){
// Take advantage of the fact that variables declared outside
// of a function are available inside any function declared
@jackcviers
jackcviers / ac-modes-example
Created May 9, 2013 03:58
ac-modes-example
(add-to-list 'ac-modes 'coffee-mode)
(add-to-list 'ac-modes 'js-mode)
(add-to-list 'ac-modes 'handlebars-mode)
@jackcviers
jackcviers / kill-line-yank-newline.el
Last active December 17, 2015 10:38
kill-line-yank-newline copies the current line and inserts a duplicate of that line after the current line, with the parts of the import expression after the cursor deleted.. Useful for adding additional imports of the same package in languages such as java and scala.
;; Copyright (C) 2013 Jack Viers
;; Author: Jack Viers <jackcviers@gmail.com>
;; This file is not part of GNU Emacs.
(defun kill-line-yank-newline ()
(interactive)
(let ((beg (line-beginning-position)) (end (line-end-position)) (name (buffer-name)) (col (current-column)))
(end-of-line)
(newline)
new_row.append $('<td>').text(media.name),
$('<td>').text media.creator
$('<td>').text media.media_type
$("document").openPopup
url: 'test'
doOnContentLoad: -> console.log 'doOnContentLoad'
@jackcviers
jackcviers / Article.txt
Last active December 21, 2015 15:29
Make Promises. Even the ones you can't keep.
In "Make No Promises" David Nolen asserts that promises don't eliminate callback hell[1]. This is not true. Take a situation where a program makes several asynchronous calls and aggregates the results in some processing step. Each call may fail. If any one of the calls fails the program cannot continue processing and must report the error.
It would be possible to write the program in a traditional callback style, and make the code easy to understand and follow. I can think of two ways to do this.
The first is to make each call and define a success handler that added the results to a shared array, and an error handler that reported each error. Then pass the success and error handler to each call. This leads to a possible outcome where the resulting aggregation may be partially complete. The program must keep track of how many of the requests have completed. The program must check the length of the results on each completion and error to see if processing can continue. I dislike this approach, because the re
@jackcviers
jackcviers / gist:9944686
Last active August 29, 2015 13:58 — forked from pbrit/gist:9713531
patch ruby for gem compile on osx mavericks
82c82
< CONFIG["LIBRUBY_DLDFLAGS"] = "-undefineddynamic_lookup -multiply_definedsuppress -install_name $(libdir)/$(LIBRUBY_SO) -current_version $(MAJOR).$(MINOR).$(TEENY) -compatibility_version $(ruby_version) $(XLDFLAGS)"
---
> CONFIG["LIBRUBY_DLDFLAGS"] = "-undefineddynamic_lookup -multiply_defined suppress -install_name $(libdir)/$(LIBRUBY_SO) -current_version $(MAJOR).$(MINOR).$(TEENY) -compatibility_version $(ruby_version) $(XLDFLAGS)"
125c125
< CONFIG["DLDFLAGS"] = "-undefineddynamic_lookup -multiply_definedsuppress"
---
> CONFIG["DLDFLAGS"] = "-undefineddynamic_lookup -multiply_defined suppress"