Skip to content

Instantly share code, notes, and snippets.

View agoldis's full-sized avatar
🎯
Focused

Andrew Goldis agoldis

🎯
Focused
View GitHub Profile
@agoldis
agoldis / rename_with_decouple.java
Last active April 4, 2018 17:30
Comment frustration - rename and decouple
public Boolean isWithinCircle(Double x, Double y, Double radius) {
final Double TWO = new Double(2);
return (Math.pow(x, TWO) + Math.pow(y, TWO)) < Math.pow(radius, TWO);
}
public List<PhotosCollection> getPhotosCollectionsWithinRadius(List<Locations> locationsList) {
List<PhotosCollection> photosCollection = new ArrayList<>();
final Double RADIUS = new Double(10);
for(Location location: locationsList) {
@agoldis
agoldis / naive_example.java
Created March 29, 2018 06:31
Comments frustrated - naive example
List<ResultType> resultsList = new ArrayList<>();
final Double TWO = new Double(2);
final Double LIMIT = new Double(10);
for(ItemType item: itemsList) {
if(Math.pow(item.x, TWO) + Math.pow(item.y, TWO) < Math.pow(LIMIT, TWO)) {
resultsList.add(item.toResultType());
}
}
@agoldis
agoldis / normalized.js
Last active April 3, 2018 06:08
redux blog
{
app: {
users: {
user01: {
id: "user01",
name: "John"
},
user02: {
id: "user02",
name: "Bob"
@agoldis
agoldis / TasksByUser-01.jsx
Last active April 10, 2018 05:31
redux blog
/*
index.js
*/
import React from "react";
import { render } from "react-dom";
import { Provider } from "react-redux";
import { createStore } from "redux";
import Header from "./Header";
import UserTasks from "./UserTasks";
@agoldis
agoldis / .babelrc
Created April 7, 2018 19:54
Minimal setup for project with react, webpack, babel 7, eslint, prettier
{
"presets": [
"@babel/preset-react",
["@babel/preset-env", {
"targets": {
"browsers": ["last 2 versions", "safari >= 7"]
}
}]
]
}
const initialState = {
users: [{ id: "user01", name: "John" }, { id: "user02", name: "Bob" }],
tasks: [
{ id: "task01", title: "Wash car", assignee: "user01" },
{ id: "task02", title: "Watch tutorial", assignee: "user01" },
{ id: "task03", title: "Do Homework", assignee: "user02" }
],
get userTasks() {
return this.users.map(user =>
Object.assign({}, user, {
const initialState = {
users: [{ id: "user01", name: "John" }, { id: "user02", name: "Bob" }],
tasks: [
{ id: "task01", title: "Wash car", assignee: "user01" },
{ id: "task02", title: "Watch tutorial", assignee: "user01" },
{ id: "task03", title: "Do Homework", assignee: "user02" }
],
profiles: [
{ id: "profile01", user: "user01", picture: "picture01URL" },
{ id: "profile02", user: "user02", picture: "picture02URL" }
@agoldis
agoldis / Header.jsx
Created April 11, 2018 04:12
reduxBlog - decoupled state A
import React from "react";
import { connect } from "react-redux";
const mapStateToProps = (({ userTasksCount }) => ({ userTasksCount }));
class Header extends React.Component {
render() {
const { userTasksCount } = this.props;
return <div>
{JSON.stringify(userTasksCount)}
@agoldis
agoldis / initialState.js
Last active April 11, 2018 04:46
redux blog - create app initialState enhancement
const initialState = {
app: {
users: [{ id: "user01", name: "John" }, { id: "user02", name: "Bob" }],
tasks: [
{ id: "task01", title: "Wash car", assignee: "user01" },
{ id: "task02", title: "Watch tutorial", assignee: "user01" },
{ id: "task03", title: "Do Homework", assignee: "user02" }
]
},
ui: { /* ... */ }
@agoldis
agoldis / initialState.js
Created April 11, 2018 05:12
redux blog - initialState with reselect
import { createSelector } from "reselect";
const initialState = {
app: {
users: [{ id: "user01", name: "John" }, { id: "user02", name: "Bob" }],
tasks: [
{ id: "task01", title: "Wash car", assignee: "user01" },
{ id: "task02", title: "Watch tutorial", assignee: "user01" },
{ id: "task03", title: "Do Homework", assignee: "user02" }
]