Skip to content

Instantly share code, notes, and snippets.

View timrchavez's full-sized avatar

Timothy R. Chavez timrchavez

  • Seattle, WA
View GitHub Profile
@timrchavez
timrchavez / example.js
Created March 9, 2012 00:32 — forked from addyosmani/example.js
Mediator pattern
// Example 1
mediator.name = 'Doug';
mediator.subscribe('nameChange', function(arg){
console.log(this.name);
this.name = arg;
console.log(this.name);
});
mediator.publish('nameChange', 'Jorn');
@timrchavez
timrchavez / gist:2014084
Created March 10, 2012 23:54
Make backbone.js inhertance work for you! (or make view inheritance work in general)
/**
* Give backbone an easier way to access super properties and methods.
*/
Backbone.View.prototype.parent = Backbone.Model.prototype.parent = Backbone.Collection.prototype.parent = function(attribute, options) {
/**
* Call this inside of the child initialize method. If it's a view, it will extend events also.
* this.parent('inherit', this.options); <- A views params get set to this.options
*/
if(attribute == "inherit") {
@timrchavez
timrchavez / pubsub.md
Created March 11, 2012 16:42 — forked from addyosmani/pubsub.md
Four ways to do Pub/Sub with jQuery 1.7 and jQuery UI (in the future)

#Four Ways To Do Pub/Sub With jQuery 1.7 and jQuery UI (in the future)

Between jQuery 1.7 and some of work going into future versions of jQuery UI, there are a ton of hot new ways for you to get your publish/subscribe on. Here are just four of them, three of which are new.

(PS: If you're unfamiliar with pub/sub, read the guide to it that Julian Aubourg and I wrote here http://msdn.microsoft.com/en-us/scriptjunkie/hh201955.aspx)

##Option 1: Using jQuery 1.7's $.Callbacks() feature:

$.Callbacks are a multi-purpose callbacks list object which can be used as a base layer to build new functionality including simple publish/subscribe systems. We haven't yet released the API documentation for this feature just yet, but for more information on it (including lots of examples), see my post on $.Callbacks() here:

#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@timrchavez
timrchavez / github.js
Created December 3, 2012 04:28
Throw away the first two components, leaving the rest of the path as the branch "name"
diff --git a/github.js b/github.js
index cd1cf38..01c01db 100644
--- a/github.js
+++ b/github.js
@@ -199,7 +199,7 @@
this.listBranches = function(cb) {
_request("GET", repoPath + "/git/refs/heads", null, function(err, heads) {
if (err) return cb(err);
- cb(null, _.map(heads, function(head) { return _.last(head.ref.split('/')); }));
+ cb(null, _.map(heads, function(head) { return _.rest(head.ref.split('/'), 2).join('/'); }));
@timrchavez
timrchavez / switch-cloud
Last active October 13, 2015 04:24
Switch Openstack clouds in your shell using os-client-config config -- I almost feel bad about this one ;-) To use: $(switch-cloud foo)
alias switch-cloud='python -c "from __future__ import print_function;import os_client_config as c, sys; [print(\"export OS_%s=%s\" % (a.upper(), b)) for (a,b) in c.OpenStackConfig().get_one_cloud(sys.argv[1]).auth.iteritems()]"'

Keybase proof

I hereby claim:

  • I am timrchavez on github.
  • I am timrchavez (https://keybase.io/timrchavez) on keybase.
  • I have a public key whose fingerprint is 6742 99E7 750E B749 DBBD 951F AA32 2C51 CD1D 1885

To claim this, I am signing this object:

!/bin/bash
CLUSTERS_PATH=${CLUSTERS_PATH:-"$(dirname \"$0\")/../clusters"}
CLUSTER_NAME=${CLUSTER_NAME:-"na"}
get_concourse_version() {
node=$1
ssh -M $node "sudo /opt/concourse/bin/concourse --version"
}
...............................I, [2017-10-16T21:35:53.403421 #9567] INFO -- : puffing-billy: Proxy listening on http://localhost:42269
I, [2017-10-16T21:35:53.736285 #9567] INFO -- : puffing-billy: STUB GET for 'https://test.example.com:443/repos/jtarchie/test/pulls?direction=asc&per_page=100&sort=updated&state=open'
.I, [2017-10-16T21:35:53.741308 #9567] INFO -- : puffing-billy: Proxy listening on http://localhost:33449
fatal: Not a git repository (or any of the parent directories): .git
FI, [2017-10-16T21:35:53.790151 #9567] INFO -- : puffing-billy: Proxy listening on http://localhost:37315
F
Failures:
1) get for every PR that is checked out checks out the pull request to dest_dir