Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / gen-project.sh
Created May 23, 2017 13:51
shell script project
mkdir project
cd project
touch index.html
mkdir js css
touch js/main.js css/styles.css
echo "some sweet text" > index.html
@tphdev
tphdev / index.html
Created May 23, 2017 13:54
a bad example
<h1>Hey guys dont do this</h1>
@tphdev
tphdev / index.html
Created May 23, 2017 13:54
a bad example
<h1>Hey guys dont do this</h1>
1. Clear USB w/ Disk Utitlity, format w/ MSDOS(FAT)
2. Download unetbootin
http://unetbootin.github.io/
3. Configure target drive for usb
/Volumes/UNetbootin/unetbootin.app/Contents/MacOS/unetbootin installtype=USB targetdrive=/dev/disk2s1
4. Run unetbootin installer -- select ubuntu 16.04x64