Skip to content

Instantly share code, notes, and snippets.

Dave Newton davelnewton

Block or report user

Report or block davelnewton

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
@davelnewton
davelnewton / refactor-nasty-ifs.js
Last active Apr 24, 2019
Code Cleanup on Aisle 5
View refactor-nasty-ifs.js
const prices = {
"Residential": 90,
"Business": 150,
}
// TODO Handle no price found.
const price = numberOfRooms * prices[propertyUsage]
let discountMultiplier = 0
if (numberOfRooms >= 10) {
@davelnewton
davelnewton / user.rb
Created Jun 13, 2018
Refactored start_date validation/modification
View user.rb
class User
MIN_DATES = {
'student' => MINIMUM_STUDENT_START_DATE,
'professor' => MINIMUM_PROFESSOR_START_DATE
}
def handle_invalid_start_date
return unless valid_type?(type)
self.start_date = MIN_DATES[type] if start_date < MIN_DATES[type]
@davelnewton
davelnewton / tmp.jsx
Created Aug 16, 2017
Header and Title Components
View tmp.jsx
const Title = ({ title }) =>
<div>
<h2>{title}</h2>
</div>
const Heading = ({ info }) =>
<div>
{info.map(x => <Title title={x.title} />)}
</div>
@davelnewton
davelnewton / CellComponent.js
Last active Jul 28, 2017
Very Rough Refactoring
View CellComponent.js
const TextForm = ({ value, onChange }) =>
<Form>
<TextArea
autoHeight
onChange={onChange}
placeholder="Description"
value={value}
/>
</Form>
@davelnewton
davelnewton / quartz.txt
Created Jun 22, 2017
Spring 4.3.9.RELEASE
View quartz.txt
➜ spring jar tvf spring-context-support-4.3.9.RELEASE.jar | grep quartz
0 Wed Jun 07 19:10:42 EDT 2017 org/springframework/scheduling/quartz/
1340 Wed Jun 07 19:10:42 EDT 2017 org/springframework/scheduling/quartz/LocalDataSourceJobStore$1.class
3879 Wed Jun 07 19:10:42 EDT 2017 org/springframework/scheduling/quartz/LocalDataSourceJobStore.class
3083 Wed Jun 07 19:10:42 EDT 2017 org/springframework/scheduling/quartz/SchedulerAccessorBean.class
977 Wed Jun 07 19:10:42 EDT 2017 org/springframework/scheduling/quartz/DelegatingJob.class
5266 Wed Jun 07 19:10:42 EDT 2017 org/springframework/scheduling/quartz/CronTriggerFactoryBean.class
1226 Wed Jun 07 19:10:42 EDT 2017 org/springframework/scheduling/quartz/LocalDataSourceJobStore$2.class
825 Wed Jun 07 19:10:42 EDT 2017 org/springframework/scheduling/quartz/MethodInvokingJobDetailFactoryBean$StatefulMethodInvokingJob.class
4959 Wed Jun 07 19:10:42 EDT 2017 org/springframework/scheduling/quartz/SimpleTriggerFactoryBean.class
@davelnewton
davelnewton / rspec_rails_cheetsheet.rb
Created Jun 19, 2017 — forked from them0nk/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet (include capybara matchers)
View rspec_rails_cheetsheet.rb
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
View 01-realm-1.js
class Car {
static schema = {
name: 'Car',
properties: {
make: 'string',
model: 'string',
miles: 'int'
}
}
}
@davelnewton
davelnewton / 1-source.js
Last active Apr 8, 2017
React createClass?
View 1-source.js
import React from 'react'
import ReactDOM from 'react-dom';
class Counter extends React.Component {
constructor(props) {
super(props);
this.state = {
count: 1
}
}
View 0-temp.js
var express = require('express');
var router = express.Router();
var mongoose = require('mongoose');
var Question = require('../models/Question.js');
var app = express();
// GET questions listing. questions/yourroute
router.get('/', function(req, res, next) {
Question.find(function(err, questions) {
if (err)
View 0_text.text
Depending on your goals this is a quick and efficient way to store a bunch of 'variables'
as the same value. The obvious down-fall being that you have to reference them by their
number which you may not know right off the bat. It's pretty fun though.
You can’t perform that action at this time.