Skip to content

Instantly share code, notes, and snippets.

View andrewjmead's full-sized avatar

Andrew Mead andrewjmead

View GitHub Profile
@andrewjmead
andrewjmead / app.js
Created February 16, 2016 13:11
Shena - Random Token
// The crypto module is part of node and does not need to be installed via npm
require('crypto').randomBytes(48, function(ex, buf) {
var token = buf.toString('hex');
console.log(token)
});
@andrewjmead
andrewjmead / server.js
Created February 20, 2016 15:33
Joren Query
var description = 'something Here';
Todo.findOne({
where: {
$and: [
Sequelize.where(Sequelize.fn('lower', Sequelize.col('description')), sequelize.fn('lower', description))
]
}
});
@andrewjmead
andrewjmead / webpack.config.js
Created February 21, 2016 15:18
Marcus ES6 & JSX Webpack
module.exports = {
entry: './public/index.js',
output: {
path: __dirname,
filename: './public/bundle.js'
},
resolve: {
extensions: ['', '.js', '.jsx']
},
module: {
@andrewjmead
andrewjmead / server.js
Created February 22, 2016 13:15
Luiscapo - Middleware
var middleware = {
logger: function(req, res, next) {
console.log(new Date().toString());
console.log('Request: ' + req.method + req.originalUrl);
next();
},
requireAuthentication: function(db) {
return function(req, res, next) {
var token = req.get('Auth');
@andrewjmead
andrewjmead / bashfile.sh
Created February 23, 2016 16:22
Remove Icon Files From Once Shared Folders
# Be careful which directory this is executed in
find . -name Icon? -exec rm -rf {} \;
@andrewjmead
andrewjmead / app.js
Created February 29, 2016 01:27
TK Object Reference Example
var accounts = [];
function createAccount(userName_, initialBalance_) {
var account = {
balance: initialBalance_ || 0,
userName: userName_ || ' '
};
accounts.push(account);
@andrewjmead
andrewjmead / ShowTodo.jsx
Created February 29, 2016 01:44
Marcus ShowTodo
import React, { Component, PropTypes } from 'react';
import { reduxForm } from 'redux-form';
import { connect } from 'react-redux';
import LogoutHeader from 'LogoutHeader';
import { fetchTodo, updateTodo, deleteTodo } from 'Actions';
import { Link } from 'react-router';
var contextTypes = {
router: PropTypes.object
};
@andrewjmead
andrewjmead / routes.jsx
Last active February 29, 2016 13:51
Nested Route Example
ReactDOM.render(
<Router history={hashHistory}>
<Route path="/docs" component={Main}>
<Route path="/page-one" component={PageOne}/>
<Route path="/page-two" component={PageTwo}/>
<IndexRoute component={DocHome}/>
</Route>
</Router>,
document.getElementById('app')
);
@andrewjmead
andrewjmead / ShowTodo.jsx
Created February 29, 2016 22:13
Marcus - Show Todo
var ShowTodo = React.createClass({
render: function () {
console.log('rendering ShowTodo');
return (
<div>
<input type="text" onChange={this.textChange}/>
</div>
)
},
@andrewjmead
andrewjmead / app.js
Created March 2, 2016 02:14
Keith Composite Index Sequelize
var UserTodos = sequelize.define('UserTodos', {
favorite: {
type: Sequelize.BOOLEAN
},
UserId: {
type: Sequelize.INTEGER,
unique: 'compositeIndex'
},
TodoId: {
type: Sequelize.INTEGER,