Skip to content

Instantly share code, notes, and snippets.

Jeremy Gray jaygraygray

Block or report user

Report or block jaygraygray

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View removeDuplicateObjects.js
function removeDuplicateObjects(arrayOfObjects) {
let newObj = new Set();
arrayOfObjects.forEach(item => newObj.add(JSON.stringify(item)))
return Array.from(newObj).map(item => JSON.parse(item))
}
View getUniqueProps.js
function getUniqueProps(arrayOfObjects, propToCheck) {
let newObj = new Set();
arrayOfObjects.forEach(item => {
newObj.add(JSON.stringify(item[propToCheck]))
})
let result = Array.from(newObj).map(item => {
return { [propToCheck]: JSON.parse(item) }
@jaygraygray
jaygraygray / draftCtrl.js
Last active Apr 25, 2017
Function in an AngularJS controller for displaying author notifications
View draftCtrl.js
//
// Declare function
//
$scope.getNotifcations = headerSvc.getNotifications().then(function(resp){
$scope.notifications = resp.data
for (var i = 0; i < $scope.notifications.length; i++) {
$scope.notifications[i].title = ''
@jaygraygray
jaygraygray / article.js
Last active Apr 25, 2017
Back end controller for handling all requests related to articles.
View article.js
GetBookmarks : function(req, res) {
var results = []
//
// Get array of IDs for specific user
//
db.query("SELECT bookmarks_list FROM users WHERE id="+req.params.user_id, function(err, resp) {
if (err) {console.log(err)} else {
var bookmarks = resp[0].bookmarks_list.split(',')
@jaygraygray
jaygraygray / Room.js
Created Apr 25, 2017
Template for a single room inside an apartment
View Room.js
import React, { Component } from 'react';
import Bed from './Bed';
import "../../styles/dndbed.scss";
import { removeStudentFromApt } from '../../actions/action_student'
import { connect } from "react-redux"
class Room extends Component {
render() {
@jaygraygray
jaygraygray / Container.js
Created Apr 25, 2017
Primary component that renders child components for Apartments view
View Container.js
import React, { Component } from 'react';
import Room from './Room';
import Bed from './Bed'
import Student from './Student';
import ApartmentListFilter from "../ApartmentListFilter";
import "../../styles/dndbed.scss";
import "../../styles/housingcontainer.scss";
import { connect } from "react-redux"
import { getStudents } from "../../actions/action_student"
import { getApartments, getRooms } from "../../actions/action_apartments"
@jaygraygray
jaygraygray / 0_reuse_code.js
Created Mar 14, 2017
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
You can’t perform that action at this time.