Skip to content

Instantly share code, notes, and snippets.

View baconpat's full-sized avatar

Patrick Bacon baconpat

View GitHub Profile
@baconpat
baconpat / RecycleViewMatcher.java
Created March 30, 2016 01:13
RecycleViewMatcher (updated for scrolling)
package com.foo.RecyclerViewMatcher;
import android.content.res.Resources;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
require 'erb'
class Context
attr_reader :properties,
:class_name,
:headers_str,
:enums_str
def initialize
@properties = []
@baconpat
baconpat / MyWidget.js
Created October 19, 2012 00:03
An example Ext widget for a unit test
Ext.define('MyApp.widget.MyWidget', {
extend: 'Ext.Component',
autoEl: {
html: "<span class='display'></span>"
},
afterRender: function () {
this.getEl().down(".display").dom.innerText = this.value;
}
});
@baconpat
baconpat / MyWidgetSpec.js
Created October 18, 2012 00:04
An example spec for use with Jasmine and Ext JS 4
Ext.require("MyApp.widget.MyWidget");
describe("MyApp.widget.MyWidget", function() {
var widget;
beforeEach(function() {
widget = Ext.create("MyApp.widget.MyWidget", {
renderTo: "test",
value: "Some Initial Value",
});
@baconpat
baconpat / SpecRunner.html
Created October 18, 2012 00:03
An example SpecRunner.html for a Jasmine test suite of an Ext JS 4 application
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Jasmine Spec Runner</title>
<link rel="shortcut icon" type="image/png" href="lib/jasmine-1.2.0/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.2.0/jasmine.css">
<script type="text/javascript" src="../js/ext-4.1.2a/ext-all-dev.js"></script>
shell_exec("DYLD_LIBRARY_PATH='' && rvm 1.8.7 exec bundle exec ruby script.rb");
@baconpat
baconpat / gist:1363930
Created November 14, 2011 13:17
Exec a ruby script and clear the DYLD_LIBRARY_PATH from PHP
shell_exec("DYLD_LIBRARY_PATH='' && rvm 1.8.7 exec bundle exec ruby script.rb");
@baconpat
baconpat / run_command.applescript
Created September 26, 2011 01:54
Vim functions and AppleScript for running tests in an external Terminal using MacVim
on appIsRunning(appName)
tell application "System Events" to (name of processes) contains appName
end appIsRunning
on execInItermTab(_terminal, _session, _command)
tell application "iTerm"
activate
set current terminal to _terminal
tell _session
select _session
@baconpat
baconpat / chainedGetJSON.js
Created August 24, 2011 16:08
JavaScript function for making sequential ajax requests.
// Makes sequential getJSON requests, passing the processed results from the
// previous request to the next request. seedData is optional.
var chainedGetJSON = function(requests, seedData) {
var seed = $.Deferred(),
finalPromise;
finalPromise = requests.reduce(function(promise, request) {
return promise.pipe(function(input) {
return $.getJSON(request.url(input)).pipe(function(json) {
return request.process(json, input);
var addToTheList = function($elem, value) {
var itemHtml = '<li>' + value + '</li>',
selector = ".list";
$elem.find(selector).andSelf().filter(selector).append(itemHtml);
};