Skip to content

Instantly share code, notes, and snippets.

import Ember from 'ember';
export default Ember.Controller.extend({
hideHomeButtonRoutes: ['index', 'login'],
isHomeButtonVisible: Ember.computed('currentRouteName', function(){
return this.get('hideHomeButtonRoutes').indexOf(this.get('currentRouteName')) === -1;
})
});
import Ember from 'ember';
export default Ember.Component.extend({
tagName: "section",
page: 1,
paginateBy: 10,
paginatedItems: Ember.computed('amenities', 'page', function(){
var i = (parseInt(this.get('page')) - 1) * parseInt(this.get('paginateBy'));
var j = i + parseInt(this.get('paginateBy'));
return this.get('items').slice(i, j);
import Ember from 'ember';
export default Ember.Component.extend({
// {Property} List of details
studentDetails: null,
// {Property} Filtered student
filteredStudent: null,
// {Property} List of students
import Ember from 'ember';
export default Ember.Component.extend({
studentDetails: null,
// {Property} List of students
students: Ember.computed('studentDetails.@each.student', function() {
let studentDetails = this.get('studentDetails') || [];
return studentDetails.getEach('student').uniq();
}),
import Ember from 'ember';
const { computed: { alias }, observer } = Ember
export default Ember.Component.extend({
routing: Ember.inject.service('-routing'),
params: alias('routing.router.currentState.routerJsState.fullQueryParams')
})
<div style="width: 100%">
<div style="width: 33%; float:left">
<h3>CommentList.js</h3>
<pre><code>class CommentList extends React.Component {
constructor() {
super();
this.state = { comments: [] }
}
componentDidMount() {
$.ajax({
@rollinsb1010
rollinsb1010 / rspec_model_testing_template.rb
Created July 23, 2016 15:36 — forked from PWSdelta/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@rollinsb1010
rollinsb1010 / array_flatten.php
Created February 2, 2016 20:53 — forked from SeanCannon/array_flatten.php
PHP array_flatten() function. Convert a multi-dimensional array into a single-dimensional array.
<?php
/**
* Convert a multi-dimensional array into a single-dimensional array.
* @author Sean Cannon, LitmusBox.com | seanc@litmusbox.com
* @param array $array The multi-dimensional array.
* @return array
*/
function array_flatten($array) {
if (!is_array($array)) {
@rollinsb1010
rollinsb1010 / array_merge_recursive_numeric()
Created November 4, 2015 17:04 — forked from Nickology/array_merge_recursive_numeric()
[PHP] Merge N arrays AND sum numeric values of identical keys
<?php
/**
* array_merge_recursive_numeric function. Merges N arrays into one array AND sums the values of identical keys.
* WARNING: If keys have values of different types, the latter values replace the previous ones.
*
* Example:
*
* $a = array( "A" => "bob", "sum" => 10, "C" => array("x","y","z" => 50) );
* $b = array( "A" => "max", "sum" => 12, "C" => array("x","y","z" => 45) );
* $c = array( "A" => "tom", "sum" => 8, "C" => array("x","y","z" => 50, "w" => 1) );
@rollinsb1010
rollinsb1010 / .gitignore
Last active September 15, 2015 15:58 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #