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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Basic Ruby code for launching a command-line MP3 player and playing a file | |
command = "afplay fatal_wedding.mp3" | |
value = `#{command}` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# My own scripts | |
export PATH="~/bin:$PATH" | |
### RBENV | |
export PATH="$HOME/.rbenv/bin:$PATH" | |
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi | |
alias l='ls -alh' | |
export GIT_MERGE_AUTOEDIT=no |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------------------------------------------------------------------------------- | |
# Welcome Prompt | |
# prints stats on terminal load | |
#------------------------------------------------------------------------------- | |
# welcome and unwelcome functions to toggle welcome_prompt are in .bash_prompt | |
WELCOME_PROMPT=true | |
welcome_msg() { | |
echo $(git --version) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# just add to the .profile or .bash_rc | |
# don't set prompt if this is not interactive shell | |
[[ $- != *i* ]] && return | |
color_default='\['`tput sgr0`'\]' | |
color_red='\['`tput sgr0; tput setaf 1`'\]' | |
color_green='\['`tput sgr0; tput setaf 2`'\]' | |
color_yellow='\['`tput sgr0; tput setaf 3`'\]' | |
color_light_blue='\['`tput sgr0; tput setaf 4`'\]' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# bash/zsh completion support for core Git. | |
# | |
# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]> | |
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). | |
# Distributed under the GNU General Public License, version 2.0. | |
# | |
# The contained completion routines provide support for completing: | |
# | |
# *) local and remote branch names | |
# *) local and remote tag names |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 256 colors for vim | |
set -g default-terminal "screen-256color" | |
# Start window numbering at 1 | |
set-option -g base-index 1 | |
set-window-option -g pane-base-index 1 | |
# Cycle panes with C-b C-b | |
unbind ^B | |
bind ^B select-pane -t :.+ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Project | |
attr_accessor :title | |
def slug | |
@title.strip.downcase.gsub(/(&|&)/, ' and ').gsub(/[\s\.\/\\]/, '-').gsub(/[^\w-]/, '').gsub(/[-_]{2,}/, '-').gsub(/^[-_]/, '').gsub(/[-_]$/, '') | |
end | |
end |
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").
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
OlderNewer