Skip to content

Instantly share code, notes, and snippets.

Alex Matchneer machty

Block or report user

Report or block machty

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
@machty
machty / angular-question.md
Created Apr 29, 2014
Angular question about mixing in directive behaviors
View angular-question.md

Let's say I've declared three class-restricted directives "am-wat", "am-foo", and "am-bar", that each augment the attached element with some behavior, e.g.:

<div am-wat="some data" am-foo="other data" am-bar="lol">
  Yadda yadda yadda
</div>

Is there a way to write a directive that mixes in the behavior of the three directives, e.g.:

@machty
machty / qp-limitation.md
Last active Aug 29, 2015
Basic/obvious QP limitation
View qp-limitation.md

Limitation regarding hrefs on non-route-driven controllers

TL;DR: lack of information about default values on non-route-driven controllers might force us to make href's overly verbose in some cases, or possible make us punt on non-route-driven-controller query params.

Scenario:

Router.map ->
  this.route('about')

// application.hbs
@machty
machty / qp-thoughts.md
Last active Aug 29, 2015
query params HOME STRETCH
View qp-thoughts.md

Aside from the few bugs that I know I need to fix about query params, there are a few remaining issues that I need help with, driven by real legit use cases from folk I've been talking to.

Also, if you haven't been keeping up, I have a PR in that added the model-dependent state stuff I talked about at EmberConf to query params, which impacts the way query params are reset/restored between changing routes/models.

View zany-changelist-idea.md

TL;DR generate changelists of app state mutations that can be used in cases where it's necessary to be able to predict what will happen when some action is invoked, e.g. linking into another route.

I've had this zany idea floating around that I just wanted to share that's probably extremely over-engineered to over-solve problems in the routing domain, but I figured I'd share it and see if any lightbulbs go off.

So in routing land, one of the harder things to calculate is a link's href; we have have to use the provided destination rout and the contexts to provide to basically ask "if this transition were to take place, what URL would you end up with?". This has led to some interesting code with query params, particularly with model dep state, where we have to say "given this destination route, these contexts, this list of explicitly provided query params, please fill sensible default values for unspecified query params and tell me what the final URL is going to be".

Particularly in nailing down these last

@machty
machty / gist:ec52161e47424dd138d2
Created Jun 2, 2014
possible query-params helper enhancements
View gist:ec52161e47424dd138d2
  • (query-params)
    • Basic form
      • e.g. (query-params page=nextPage)
      • set page to nextPage
      • any other QPs on target route get automatically filled in based on model-dependent state
      • active state: route considered inactive unless supplied params match
    • PROPOSAL: Specify params to reset
      • e.g. (query-params '-sortOrder' page=nextPage)
      • Like above, sets page to nextPage, but resets the
@machty
machty / idea.js
Created Jul 19, 2014
this is a backwards compatible approach to namespace-less nested routes.
View idea.js
Router.map(function(root) {
// this === root
this.route("articles", function(scope) {
// this === scope, hence making `scope` an optional
// arg unless you have some reason to use it within callbacks below
// these two are identical and generate a route
// named "articles.show"
this.route("show");
//scope.route("show");
View embertest.js
test("customers can use a forgot password link", function() {
ajax('/setup_test_env/signup/preexisting-users').then(function() {
visit(...);
fillIn(...);
click(...);
andThen(function() {
equal(find('.errors p').text(), "E-mail taken");
});
});
View embedded-template.js
import FooComponent from 'foo';
function funHelper(value, options) {
return value + "!!!";
}
var foo = "yes";
export default Ember.Component.extend({
bar: 123,
@machty
machty / index.html.slim
Created Apr 7, 2012
An attempt at Slim/Haml helpers for handlebars
View index.html.slim
= handlebars_template_named "edit-field" do
= hb %{ if isEditing } do
= hb %{ view BD.TextField valueBinding="value" }
= hb_else
= hb %{ if value } do
= hbb %{ value }
= hb_else
span.no-name empty
/ Outputs
@machty
machty / gist:2931511
Created Jun 14, 2012
async queue download
View gist:2931511
ownloadQueue = async.queue (photo, callback) ->
# Here we define the task handled by this concurrency-limiting queue.
downloadfile = photo.url
host = url.parse(downloadfile).hostname
filename = url.parse(downloadfile).pathname.split("/").pop()
filename = "./public/downloads/#{filename}"
photo.localFilename = filename
console.log "set photo.localFilename to #{photo.localFilename}"
theurl = http.createClient(80, host)
requestUrl = downloadfile
You can’t perform that action at this time.