Skip to content

Instantly share code, notes, and snippets.

Avatar

Martin Muñoz mmun

View GitHub Profile
View composing_abort_controllers.js
/*
This is an example of how you would compose two APIs that use AbortController.
The function `getLocalShops` first gets the user's geolocation coordinates
and then makes a fetch using these coordinates. Both of these operations could be expensive,
so we want to abort them as soon as the outer getLocalShops call is aborted.
*/
View components.bar-column.js
import Ember from 'ember';
export default Ember.Component.extend({
didRender() {
console.log("bar-column#didRender");
}
});
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
init() {
this._super(...arguments);
// Simulate loading data in a route
this.store.push({
data: [
{ type: 'user', id: '1', attributes: { name: 'mmun' } },
View adapters.cat.js
import DS from 'ember-data';
export default DS.JSONAPIAdapter;
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
View wutwut.cpp
struct activity {
long s, e, h;
bool operator<(const activity& other) const {
return e < other.e;
}
};
// code snippet
upper_bound(activities.begin(), activities.end(), {0, x, 0}) - a.begin();
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
names: ['martin', 'ricardo', 'spencer']
});
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
person: { name: "" }
});
View soln.sh
#!/bin/bash
function soln() {
if [ -z $1 ]; then
echo "Usage: soln <name>"
return
fi
solution_dir="$DMOJ_SOLUTIONS/$1"
template_dir="$DMOJ_SOLUTIONS/__template__"
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appNameKey: 'appName',
appName: 'Ember Twiddle'
});