Skip to content

Instantly share code, notes, and snippets.

@tphdev
tphdev / secrets.js
Created March 31, 2017 12:48
secrets
let youtubeRedirectUrl = 'http://www.yoursite.com/oauth/youtube/redirect-callback'
if(process.env.NODE_ENV === 'development'){
youtubeRedirectUrl = 'http://localhost:3000/oauth/youtube/redirect-callback'
}
module.exports = {
sessionSecret: 'cookieMonster7482',
youTubeOAuth: {
clientID:'221782448762-5svpitibr4rhfq7tvs422egniceb2m8d.apps.googleusercontent.com',
@tphdev
tphdev / slider-puzzle.js
Created March 28, 2017 16:33
slider puzzle
let initGameBoard = function(){
let arr = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","x"]
return _.chunk( _.shuffle(arr),4 )
}
function printGameBoard(board){
let boardHtml = board.map((rowVals)=> rowVals.map( (colVal)=> {
return `<div id="${colVal}">${colVal}</div>`
@tphdev
tphdev / mouse.js
Created March 16, 2017 14:57 — forked from electricg/mouse.js
Mouse position relative to document and element
// Which HTML element is the target of the event
function mouseTarget(e) {
var targ;
if (!e) var e = window.event;
if (e.target) targ = e.target;
else if (e.srcElement) targ = e.srcElement;
if (targ.nodeType == 3) // defeat Safari bug
targ = targ.parentNode;
return targ;
}
@tphdev
tphdev / user-model.js
Last active March 9, 2017 19:20
a user model for authentication w/ backbone
import Backbone from 'backbone'
import $ from 'jquery'
export const UserModel = Backbone.Model.extend({
initialize: function(){
},
urlRoot: '/api/users',
idAttribute: '_id'
})
@tphdev
tphdev / router.js
Created February 27, 2017 18:23
router.js - undelegating events
const AppRouter = Backbone.Router.extend({
//(1)
_currentViewInstance: null,
//(2a) this will undelegate the event-listeners
// from the 'zombie view'
_destroyZombieView: function(){
console.log(this._currentViewInstance)
@tphdev
tphdev / component-viewcontroller.js
Last active November 11, 2016 19:02
View Controller for React Components
const React = require('react')
const HomeView = require('./component-homeview.js')
const ACTIONS = require('./actions.js')
const STORE = require('./store.js')
const AppViewController = React.createClass({
getInitialState: function(){
let startingState = {}
return startingState
},
@tphdev
tphdev / app.js
Last active November 11, 2016 19:04
Basic Backbone Router
const Backbone = require('backbone')
// const AppViewController = require('backbone')
const AppRouter = Backbone.Router.extend({
routes: {
"*" : "renderCatchAll"
},
renderCatchAll: function(){
document.querySelector('#app-container').innerHTML = "<h1>YOLO</h1>"
@tphdev
tphdev / actions.js
Created November 10, 2016 13:45
Actions - Basic Setup
const Backbone = require('backbone');
// import STORE from '../store/store.js';
// import toastr from 'toastr'
const { UserModel, TodoModel, TodoCollection } = require('UserModel')
const ACTIONS = {
fetchTodoCollection: function(queryObj){
},
@tphdev
tphdev / store.js
Last active March 19, 2017 16:11
Data Store
export const STORE = {
_data: {
shoutOutList: [],
shownRatingType: 'PG',
currentNavRoute: ''
},
getStoreData: function(){
return this._data
},
@tphdev
tphdev / container-component.js
Last active November 5, 2016 18:35
React Container Component
const DivContainerComponent = React.createClass({
render: function(){
return (
<div className={this.props.containerClassName || ""}>
{this.props.dataList.map((elData, i)=>{
return React.cloneElement(this.props.children, {data: elData, key: `${(new Date()).getTime()}-${i}`})
})}
</div>
)
}