Skip to content

Instantly share code, notes, and snippets.

puts "hello gist"
@tphdev
tphdev / NavBar.js
Last active May 10, 2016 20:45
nav bar in react using single responsibility principle
var MyNav = React.createClass({
_testForCompleteFields: function(uMod){
var criticalFields = ['yard', 'dev', 'whatev']
var fieldsAreComplete = true
criticalFields.forEach(function(field){
if ( uMod.get(field) === null ) { fieldsAreComplete = false }
})
return fieldsAreComplete
@tphdev
tphdev / promiser.js
Last active October 14, 2016 10:57
simple promise implementation
console.log('wired up!')
var Promiser = {
callBackList: [],
fetchJSON: function(url){
var resolvePromise = function (context) {
var dataResponse = JSON.parse(this.responseText)
var cb = context.callBackList.shift()
@tphdev
tphdev / get-fonts.sh
Created October 16, 2016 17:05
get-fonts.sh
mkdir ./css/fonts
FONTS_ARRAY=(eot svg ttf woff woff2)
for font_ext in "${FONTS_ARRAY[@]}"
do
echo downloading $font_ext
curl https://raw.githubusercontent.com/FortAwesome/Font-Awesome/master/fonts/fontawesome-webfont.${font_ext}?raw=true > ./css/fonts/fontawesome-webfont.${font_ext}
done
@tphdev
tphdev / get-fa-fonts.sh
Last active October 16, 2016 17:06
get-fa-fonts.sh
mkdir ./css/fonts
FONTS_ARRAY=(eot svg ttf woff woff2)
for font_ext in "${FONTS_ARRAY[@]}"
do
echo downloading $font_ext
curl https://raw.githubusercontent.com/FortAwesome/Font-Awesome/master/fonts/fontawesome-webfont.${font_ext}?raw=true > ./css/fonts/fontawesome-webfont.${font_ext}
done
@tphdev
tphdev / warmup-math-prototype-range.js
Created October 20, 2016 12:30
Create sth on the prototype - Math.prototype.range
//-----------------------------------------
// Math.protoytype.range()
// Write a method called `range` to the Math prototype that accepts 2 arguments and
// returns a random integer number inside of that range
//
// The order of the arguments passed shouldn't matter.
//
// Hint: You will need to use the existing Math.prorotMath.prototype.floor()
//------------------------------------------
@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>
)
}
@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 / 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 / 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>"