Skip to content

Instantly share code, notes, and snippets.

@davelnewton
davelnewton / user.rb
Created June 13, 2018 15:07
Refactored start_date validation/modification
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 August 16, 2017 00:55
Header and Title Components
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 July 28, 2017 16:38
Very Rough Refactoring
const TextForm = ({ value, onChange }) =>
<Form>
<TextArea
autoHeight
onChange={onChange}
placeholder="Description"
value={value}
/>
</Form>
@davelnewton
davelnewton / quartz.txt
Created June 22, 2017 18:16
Spring 4.3.9.RELEASE
➜ 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 June 19, 2017 19:01 — forked from them0nk/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet (include capybara matchers)
#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)
@davelnewton
davelnewton / 01-realm-1.js
Last active April 18, 2017 21:18
Realm Sample
class Car {
static schema = {
name: 'Car',
properties: {
make: 'string',
model: 'string',
miles: 'int'
}
}
}
@davelnewton
davelnewton / 1-source.js
Last active April 8, 2017 02:17
React createClass?
import React from 'react'
import ReactDOM from 'react-dom';
class Counter extends React.Component {
constructor(props) {
super(props);
this.state = {
count: 1
}
}
@davelnewton
davelnewton / 0-temp.js
Last active April 8, 2017 01:59
Beautified 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)
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.
@davelnewton
davelnewton / 00_README.md
Last active November 29, 2016 15:50
Misc React Refactors

Trivial refactoring of the render method

The length of the render function makes it difficult to know what all it's responsible for.

I broke out the wrapper <div> into a small component, and the AgGrid row into a separate component.

Moving handlers etc.

I don't know how Flux works, but I'd make each of the user controls their own components. They can update the store as they do now (roughly, depending on how Flux does things like this) with results/etc still handled by the containing component.