Skip to content

Instantly share code, notes, and snippets.

Jack Viers jackcviers

Block or report user

Report or block jackcviers

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View MonadErrorExample.scala
import cats.MonadError
import cats.instances.either._
import cats.instances.future._
import cats.instances.try_._
import cats.syntax.applicativeError._
import cats.syntax.flatMap._
import scala.concurrent.duration._
import scala.concurrent.{Await, Future}
jackcviers / gist:9944686
Last active Aug 29, 2015 — forked from pbrit/gist:9713531
patch ruby for gem compile on osx mavericks
View gist:9944686
< 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)"
< CONFIG["DLDFLAGS"] = "-undefineddynamic_lookup -multiply_definedsuppress"
> CONFIG["DLDFLAGS"] = "-undefineddynamic_lookup -multiply_defined suppress"
jackcviers / Article.txt
Last active Dec 21, 2015
Make Promises. Even the ones you can't keep.
View Article.txt
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
View openpopup
url: 'test'
doOnContentLoad: -> console.log 'doOnContentLoad'
new_row.append $('<td>').text(,
$('<td>').text media.creator
$('<td>').text media.media_type
jackcviers / kill-line-yank-newline.el
Last active Dec 17, 2015
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.
View kill-line-yank-newline.el
;; Copyright (C) 2013 Jack Viers
;; Author: Jack Viers <>
;; This file is not part of GNU Emacs.
(defun kill-line-yank-newline ()
(let ((beg (line-beginning-position)) (end (line-end-position)) (name (buffer-name)) (col (current-column)))
View ac-modes-example
(add-to-list 'ac-modes 'coffee-mode)
(add-to-list 'ac-modes 'js-mode)
(add-to-list 'ac-modes 'handlebars-mode)
View Show Location
// 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()});
// Take advantage of the fact that variables declared outside
// of a function are available inside any function declared
jackcviers / jquery_transport_selection.js
Created Feb 12, 2013
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…
View jquery_transport_selection.js
// 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 ) {
jackcviers / .ctags
Created Mar 19, 2012
.ctags description for JavaScript and Coffeescript
View .ctags
--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/
You can’t perform that action at this time.