Skip to content

Instantly share code, notes, and snippets.

Mars Hall mars

Block or report user

Report or block mars

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
mars / wrap-promise.js
Last active Aug 29, 2015
wrap a Promise with Ruby-esque block behavior; ES6/ES2015
View wrap-promise.js
Insert a Promise into a pre-defined Promise chain.
@param promiseBlock [Function] takes a Promise
parameter & returns the continuation of that parameter.
@return [Promise] the fullfilled Promise chain
function wrapPromise(promiseBlock) {
if (typeof promiseBlock !== 'function') {
throw new Error('promiseBlock must be a Function');
mars / karma-ci.config.js
Last active Aug 29, 2015
example Webpack configs: React runtime & Karma tests
View karma-ci.config.js
var webpackModule = require('./webpack.module.js');
var webpackResolve = require('./webpack.resolve.js');
var Webpack = require('webpack');
var RewirePlugin = require("rewire-webpack");
module.exports = function(config) {
// frameworks to use
// available frameworks:
mars / rewire-module.js
Last active Sep 15, 2016
Manually mock React components; Jasmine helper to stub & teardown a bunch of a module's dependencies with Rewire. How-to:
View rewire-module.js
Jasmine helper to stub & teardown a bunch of a module's dependencies.
describe("SomeModule", function() {
var SomeModule = rewire("some-module");
rewireModule(SomeComponent, {
ItsComponent: React.createFactory('div'),
AnotherComponent: React.createFactory('div')
mars / json_api_base_serializer.rb
Last active Apr 8, 2016
ActiveModel Serializers for JSON-API (with association sideloading)
View json_api_base_serializer.rb
# Ancestor for JSON-API serializers, implements
# "application/vnd.api+json" media type conventions.
# See:
class JsonApiSerializer < ActiveModel::Serializer
# Always make pluralized root JSON property.
def self.inherited(subclass)
mars / capybara_reset_patch.rb
Created Aug 13, 2014
Capybara patch to avoid `'about:blank')` which hangs sometimes.
View capybara_reset_patch.rb
# Monkey-patch on Capybara!!!
class Capybara::Selenium::Driver < Capybara::Driver::Base
# Patch to avoid `'about:blank')` which hangs sometimes.
def reset!
# Use instance variable directly so we avoid starting the browser just to reset the session
if @browser
begin @browser.manage.delete_all_cookies

Keybase proof

I hereby claim:

  • I am mars on github.
  • I am marsi ( on keybase.
  • I have a public key whose fingerprint is DFC9 5BAD 42CF D15F 589A 9436 7F70 7FA1 F236 B857

To claim this, I am signing this object:

mars / register_chrome_with_window_size.rb
Created Oct 13, 2013
Set window size for Capybara/Selenium/chromedriver
View register_chrome_with_window_size.rb
Capybara.register_driver :chrome do |app|,
browser: :chrome,
desired_capabilities: {
"chromeOptions" => {
"args" => %w{ window-size=1024,768 }
mars / foo-app-test.js
Last active Dec 20, 2015
ember-testing: multiple app compatibility
View foo-app-test.js
// give each tested app its own DOM element
document.write('<div class="ember-testing-container"><div id="foo-app-testing"></div></div>');
FooApp.rootElement = '#foo-app-testing';
// defer readiness
module("Foo App", {
setup: function() {
// last step, before each test begins, clears the container and advances readiness
mars / gist:6086194
Last active Dec 20, 2015
DEPRECATED see comments: ember-testing: select an option (helper)
View gist:6086194
function(app, selector, value, description) {
// choose an option
// trigger the change
// assert the selected option
equal(find(selector+" option:selected").val(), value, description||"makes the selection");
// promise
return wait();
mars / ember-data-global-ajax-params.js
Last active Dec 16, 2015
Add params to Ember Data's RESTAdapter AJAX requests.
View ember-data-global-ajax-params.js
App.accountId = 'asdf';
App.RESTAdapter = DS.RESTAdapter.extend({
// Scope all ajax calls.
ajax: function(url, type, hash) {
if (Ember.isEmpty(hash)) hash = {};
if (Ember.isEmpty( = {}; = App.accountId;
this._super(url, type, hash);
You can’t perform that action at this time.