This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.row | |
.col-lg-4 | |
%div{'ng:repeat' => "item in array.slice(0, array.length / 3)"} | |
{{item}} | |
.col-lg-4 | |
%div{'ng:repeat' => "item in array.slice(array.length / 3, array.length * 2/3)"} | |
{{item}} | |
.col-lg-4 | |
%div{'ng:repeat' => "item in array.slice(array.length * 2/3, array.length"} | |
{{item}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you want to go directly to the DB | |
ActiveRecord::Base.connection.select_values("select id from users") | |
# If you already have a model | |
User.all(:select => :id).collect(&:id) | |
# In Rails 3 you can do this | |
User.pluck(:id) | |
# Rails helper |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.config(function($httpProvider) { | |
var authToken = $('meta[name="csrf-token"]').attr('content'); | |
$httpProvider.defaults.headers.common["X-CSRF-TOKEN"] = authToken; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var array = []; | |
var index = $scope.array.indexOf(item); | |
$scope.array.splice(index, 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.controller('GlobalCtrl', function($rootScope, $scope, UserService, TodoService) { | |
$rootScope.users = []; | |
$rootScope.todos = []; | |
// Init. | |
UserService.all().then(function(users) { | |
angular.forEach(users, function(user) { | |
rootScope.users.push(user); | |
TodoService.all(user.id).then(function(todos) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.controller('appCtrl', function($scope, $filter) { | |
//.. | |
angular.forEach($scope.todos, function(todo) { | |
if (todo.id == updatedTodo.id) { | |
angular.extend(todo, updatedTodo); | |
} | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.controller('mainCtrl', function($rootScope, UserService) { | |
$rootScope.users = []; | |
$rootScope.todos = []; | |
// Get all users. | |
UserService.all().then(function(users) { | |
angular.forEach(users, function(user) { | |
$scope.users.push(user); | |
// Get all todos. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
drupal_add_js('misc/ajax.js'); | |
ctools_add_js('modal'); | |
ctools_add_css('modal'); | |
// Add your modal style to the settings. You find the defaults in modal.js near the top: | |
drupal_add_js(array( | |
'my-modal-style' => array( | |
'modalSize' => array( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//@see: https://drupal.org/node/1021556 | |
$wrapper = entity_metadata_wrapper('node', $node); | |
$wrapper->author->mail->value(); | |
$wrapper->author->mail->set('[email protected]'); | |
$wrapper->author->mail = '[email protected]'; | |
// Unified way of getting $node->title, $user->name, ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$access_token = 'woknfowenf'; | |
$query = 'SELECT blabla... FROM blabla...'; | |
$result = fboauth_graph_query('fql', $access_token, array('q' => $query)); |