Skip to content

Instantly share code, notes, and snippets.

@wecc
wecc / gist:3d30c73b5bec4fe3d708
Created November 26, 2014 20:17
Use this method to restore the old Ember Data behavior where properties with missing keys in the payload gets cleared.
App.ApplicationSerializer = DS.RESTSerializer.extend({
normalizeAttributes: function(type, hash) {
this._super(type, hash);
type.eachAttribute(function(key) {
if (!hash.hasOwnProperty(key)) {
hash[key] = null;
}
}, this);
<?php /**
* @Route("/login/", name="login_route")
*/
public function loginAction(Request $request)
{
$authenticationUtils = $this->get('security.authentication_utils');
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
<?php /**
* @Route("/login/", name="login_route")
*/
public function loginAction(Request $request)
{
$authenticationUtils = $this->get('security.authentication_utils');
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
<?php /**
* @Route("/login/", name="login_route")
*/
public function loginAction(Request $request)
{
$authenticationUtils = $this->get('security.authentication_utils');
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
<?php
Database::beginTransaction();
if ($order = Order::create($data)) {
$items = $cart->getItems();
$orderLines = array();
foreach ($items as $item) {
$data = array(
'number' => $item->article->number,
'number_supplier' => $item->article->number_supplier,
<?php
Database::beginTransaction();
if ($order = Order::create($data)) {
$items = $cart->getItems();
$orderLines = array();
foreach ($items as $item) {
$data = array(
'number' => $item->article->number,
@wecc
wecc / application.controller.js
Last active September 21, 2015 11:52
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
@wecc
wecc / application.controller.js
Created November 17, 2015 22:03
New Twiddle
import Ember from 'ember';
const { set, computed: { sort } } = Ember;
export default Ember.Controller.extend({
appName:'Ember Twiddle',
sorting: ['position:asc'],
sortedItems: sort('model', 'sorting'),
@wecc
wecc / application.route.js
Created February 8, 2016 19:48 — forked from pangratz/application.route.js
belongsTo() meta
import Ember from 'ember';
import { server, json } from '../initializers/pretender';
server.map(function() {
this.get('/people/1', function() {
return json({
data: {
type: 'person',
id: 1,
attributes: {
@wecc
wecc / route.js
Last active March 28, 2016 10:32
import Ember from 'ember';
import { all, task, timeout } from 'ember-concurrency';
export default Ember.Route.extend({
serverStatusLoopTask: task(function *() {
let { servers } = this.modelFor('servers');
while (true) {
yield timeout(5 * 1000);
yield all(servers.map(::(this.get('fetchServerStatusTask')).perform));