Skip to content

Instantly share code, notes, and snippets.

View madetech-com's full-sized avatar

Derek McMade madetech-com

View GitHub Profile
@madetech-com
madetech-com / 01.jsx
Created June 14, 2017 10:18
React & MVC Blog Post
// Defining the component
const ProfilePage = ({ username, numPosts, numComments }) =>
<main>
<h1>{username}</h1>
<span>{numPosts} Posts</span>
<span>{numComments} Comments</span>
</main>
ProfilePage.propTypes = {
username: PropTypes.string.isRequired,
@madetech-com
madetech-com / 01.rb
Created June 8, 2017 09:56
Dumb Things With Postgres
class Article < ActiveRecord::Base
# all the other logic
def associated_articles
Article.where.not(id: id).where('tags && ARRAY[?]', tags)
end
end
@madetech-com
madetech-com / 01.txt
Created April 5, 2017 13:16
"Using Ansible for infrastucture" post - code samples
[playground]
aws_access_key_id = 13ABCHHASDBYB2U3NG34NG
aws_secret_access_key = nfu8n3787N4F874GN8n7g847878G87NG/GUNREIN
@madetech-com
madetech-com / things_we_learned_about_react_1.jsx
Last active March 29, 2017 13:20
"Things We Learned Building A Complex React App" post
@connect(...)
class HomePage extends React.Component {
handleContactFormSubmission (e) {
e.preventDefault()
const formData = { ... }
this.props.dispatch(submitContactForm(formData))
}
render () {
return (
@madetech-com
madetech-com / 1.js
Created June 22, 2016 10:18
Pros and Cons of React + Redux
{ type: 'ADD_COMMENT', comment: { body: 'test comment', user: 1 } }
Original command docker-compose command
rails c docker-compose run web rails c
RAILS_ENV=test rake db:create docker-compose run -e RAILS_ENV=test web rake db:create
rspec spec/path/to/spec.rb docker-compose run web rspec spec/path/to/spec.rb
bundle install docker-compose run web bundle install
<link rel="import" href="/components/gallery.html">
<gallery />
<Comment props={{ username: 'richard', comment: 'React!' }} />
class Comment {
styles = {
username: {
fontWeight: 'bold',
paddingRight: '10px',
},
comment: {
color: '#444',
},
};
<template name="gallery">
<style>
section {
padding: 10px;
background: #333;
}
.images img {
display: none;
}