Skip to content

Instantly share code, notes, and snippets.

View w1shen's full-sized avatar

Walter Shen w1shen

  • LinkedIn
  • San Francisco
View GitHub Profile
@w1shen
w1shen / controllers.application.js
Last active January 15, 2019 06:25
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Component.extend({
});
@w1shen
w1shen / tests.helpers.destroy-app.js
Last active October 14, 2019 05:25
New Twiddle
import { run } from '@ember/runloop';
export default function destroyApp(application) {
run(application, 'destroy');
}
@w1shen
w1shen / tests.helpers.destroy-app.js
Last active October 18, 2019 00:05
New Twiddle
import { run } from '@ember/runloop';
export default function destroyApp(application) {
run(application, 'destroy');
}
import { run } from '@ember/runloop';
export default function destroyApp(application) {
run(application, 'destroy');
}
import $ from 'jquery';
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { settled } from '@ember/test-helpers';
import { later } from '@ember/runloop';
import { registerWaiter } from '@ember/test';
import Pretender from 'pretender';
const DELAY = 2000;
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('my-component', 'Block', {
integration: true
});
test('Block form', function(assert) {
for (let i = 0; i < 65535; i++) {
this.render(hbs`<div id="test">{{#if true}}Hello{{/if}}</div>`);
@w1shen
w1shen / gist:ed7b2f939030a8a74d96
Last active August 29, 2015 14:03
Lift Session-and-Request

http://exploring.liftweb.net/master/index-3.html#sec:Session-and-Request

One important thing to note is that the injector variable is called in the scope of the following request. This means that if you want the value returned by the function at the point where you call the link or redirectTo, you’ll need to capture it in a val. Otherwise, the function will be called after the redirect or link, which may result in a different value than you expect. As you can see in Listing 3.11↑, we set up an acct val in our doSave method prior to redirecting. If we tried to do something like

S.redirectTo("/view", () => currentAccountVar(currentAccountVar.is))

@w1shen
w1shen / dispatch.scala
Last active April 18, 2017 03:40
Post JSON by Dispatch
val req = url("localhost").POST
.as_!("username", "password")
.setBody("body")
.setContentType("application/json", "UTF-8")
val future = Http(req OK as.String)
val rep = Await.result(future, 5.seconds)