Skip to content

Instantly share code, notes, and snippets.

View mikeymicrophone's full-sized avatar

Mike Schwab mikeymicrophone

View GitHub Profile
User.create :first_name => current_facebook_user.first_name, :last_name => current_facebook_user.last_name,
:email => current_facebook_user.email,
:facebook_id => current_facebook_user.id,
:access_token => current_facebook_user.client.access_token,
:city => current_facebook_user.location
@mikeymicrophone
mikeymicrophone / class projects
Created January 8, 2012 21:35
ideas for group projects, Ruby class 3rd Ward Brooklyn
side project
- share projects
- use social tools to push yourself
info about candidates, policies
- facebook connect
- users can comment on why they support candidates
local MCs
- upload tracks
Here's some great instructions:
http://www.frederico-araujo.com/2011/07/30/installing-rails-on-os-x-lion-with-homebrew-rvm-and-mysql/
Here's my version:
First, install XCode, which will help you compile other software. If you have OSX 10.7 (Lion), you can install XCode via the Mac App Store. You can also register (for free) at developer.apple.com and get it from the downloads section of the iOS dev center.
The newest version of XCode has a compiler called LLVM which apparently does not work with RVM's 1.9.2 installer. Use this tool to install the compiler called GCC.
https://github.com/kennethreitz/osx-gcc-installer
@mikeymicrophone
mikeymicrophone / terminal output
Created January 18, 2012 15:48
the process of setting up, editing, and deploying the community_pics app
First, download GitHub for Mac (or install git).
http://mac.github.com
Then, go to the community_pics repository page and click "Clone in Mac"
http://github.com/schwabsauce/community_pics
Open a Terminal window and move into the community_pics directory
$ cd Documents/community_pics
Then run bundle and rake db:migrate.
These are the steps you will probably need to take, to get a new Rails app running.
1. install Rails
2. create a new Rails app
3. navigate into the root directory of your app
4. generate a scaffold
A Rails app has a few top-level folders that serve different purposes. This might vary from app to app, but most apps use this basic structure pretty faithfully.
app
This folder is where most of your code goes. It has folders for your controllers (navigation logic), models (business logic), and views (display templates). Sometimes developers create extra folders in here for objects like mailers and observers. In Rails 3.1, an assets folder joined this group. The assets folder contains files that get compiled into javascript code, stylesheets, and images. These asset files are written in Ruby-like languages, but the rest of the code in the app folder is Ruby.
config
This folder has files that run when your app starts, including environment.rb and database.yml. They control decisions about how the app works in different scenarios (examples: which email account should be used for outgoing messages? which database should be used for data stored by this server?). The config folder also contains credent
@mikeymicrophone
mikeymicrophone / 20120115192726_picture_has_photo_file.rb
Created January 22, 2012 01:49
using carrierwave (for uploading files)
class UsersHaveAvatar < ActiveRecord::Migration
def up
add_column :users, :avatar, :string
end
def down
remove_column :users, :avatar
end
end
@mikeymicrophone
mikeymicrophone / gist:2485002
Created April 25, 2012 00:51
steps in feature development: comment on notes, tag notes
Commenting on notes:
- generate comments scaffold (controller, model, migration, views)
- add comment link and comment form spot to comment partial
- tell CommentsController#new to respond to JS requests
- create new.js.erb partial for comments controller
@mikeymicrophone
mikeymicrophone / genre_leader.pseudo
Created March 12, 2014 04:34
pseudo code for finding the artist who has released into/within the most genres
artists = all artists
for each artist
grab all tracks by artist
grab all genres for tracks
count number of unique genres
note the number of genres for the artist
start with the first artist
compare her number of genres with the number of genres for the second artist
whoever has more is the leader
@mikeymicrophone
mikeymicrophone / application_controller.rb
Created August 15, 2014 15:28
trying to execute __FILE__ on a different file using inheritance and callbacks in Ruby 1.8.7
class ApplicationController
#logs of code omitted
before_filter :define_file_locator
def define_file_locator
self.class.send :define_method, :log_file_location, lambda {
instance_eval 'Rails.logger.info "File location: #{__FILE__}"'
}
log_file_location