Skip to content

Instantly share code, notes, and snippets.

View amcooper's full-sized avatar
🐖
🐖

Adam Cooper amcooper

🐖
🐖
View GitHub Profile
@amcooper
amcooper / 01_Article.jsx
Last active February 20, 2019 20:38
Troubled Relay container subtree
// Article.jsx
import React from "react";
import { createFragmentContainer, graphql } from "react-relay";
import CommentList from "./CommentList.jsx";
class Article extends React.Component {
render() {
return (
@amcooper
amcooper / generateComponentTests.js
Created January 15, 2019 19:20
Janky component test generation script
/**
*
* A quick, janky script to generate & colocate Storyshots. Just saving this in case all hell.
*
*/
const fs = require("fs");
const path = require("path");
const elementsDir = path.join(__dirname, "..", "src", "components", "elements");
const modulesDir = path.join(__dirname, "..", "src", "components", "modules");
@amcooper
amcooper / keybase.md
Created August 14, 2018 19:24
keybase.md

Keybase proof

I hereby claim:

  • I am amcooper on github.
  • I am amcooper (https://keybase.io/amcooper) on keybase.
  • I have a public key ASCoyzf-i3fIIrA10e4mnJrLC87i4yUHAvj34gz7uZcLdgo

To claim this, I am signing this object:

Knex - Express - CRUD

Practicing Relationships

Quickly Setup Your Project

Let's quickly review creating a new project utilizing todos.

  • Init a new Project

@amcooper
amcooper / App.js
Last active November 16, 2017 21:25
react-stalker
import React, { Component } from 'react';
import './App.css';
import config from './config.js';
class Form extends Component {
constructor(props) {
super(props);
this.state = {
celebrity: '',
stalker: '',
@amcooper
amcooper / App.js
Last active August 2, 2017 00:29
Vigilant snippet no. 2
import React, { Component } from 'react';
import './App.css';
import seedTweets from './seeds.js';
class Tweet extends Component {
render() {
return(
<div className="tweet">
<p className="tweetText">{ this.props.text }</p>
<p className="tweetMetadata">
@amcooper
amcooper / README.md
Last active August 2, 2017 00:59
Vigilant snippet no. 1

Snippet no. 1: the Tweet Controller (Ruby)

Introduction

Lesser Evil (lesser-evil-cli) is a hosted Ruby gem for the command line which applies a third-party, open-source sentiment analysis tool to collect negative-affect tweets regarding the 2016 U.S. Presidential candidates. The user chooses the candidate ("Trump" or "Clinton") and the negativity threshold ("angry" or "very angry").

What does it do?

The fetch_tweets method in the Tweet Controller is the primary engine of the application. It performs the following tasks:

  • Retrieves a batch of tweets. It calls (line 29) the get_batch method which makes GET requests to the Twitter Search API. The request includes search terms, desired number of results, and the maximum ID (i.e., the most recent ID from which to start the search)
  • Filters them according to sentiment. The if statement of line 36 tests for sentiment negativity and user-specified intensity
  • Creates a TweetSlim object from each matched tweet (line 37)
  • Prints each TweetSli
@amcooper
amcooper / dbc-take-two.md
Last active July 11, 2017 02:39
Code challenge July 2017

dbc code challenge

rails new
rails generate scaffold User email password_digest
rails generate controller Sessions new create destroy
rails generate scaffold Album title user:references artist:references
rails generate scaffold Artist name
rails generate scaffold Song name album:references
rails generate scaffold Favorite user:references artist:references album:references song:references
@amcooper
amcooper / project.rb
Created November 30, 2016 22:50
New code for title slugging
class Project
attr_accessor :title
def slug
@title.strip.downcase.gsub(/(&|&amp;)/, ' and ').gsub(/[\s\.\/\\]/, '-').gsub(/[^\w-]/, '').gsub(/[-_]{2,}/, '-').gsub(/^[-_]/, '').gsub(/[-_]$/, '')
end
end
" Make backspace behave in a sane manner.
set backspace=indent,eol,start
" Switch syntax highlighting on
syntax enable
" Enable file type detection and do language-dependent indenting
filetype plugin indent on
" Show line numbers