Skip to content

Instantly share code, notes, and snippets.

@raghubetina
raghubetina / homework_workflow.md
Created January 13, 2015 18:15
Homework Workflow

TLDR; Get Help, Don't Get Frustrated

Here's a general workflow that you ought to think about while doing homework:

  1. Read any instructions completely.
  2. Dive in; don't spend too much time planning. Break the problem into the smallest steps you can think of and get started on the first one.
  3. Code until you get stuck on something for at least 15 minutes.

What To Do When You Get Stuck

@raghubetina
raghubetina / installing_rails.md
Last active November 15, 2018 18:34
Installing Ruby and Rails

Installing Ruby and Rails

Ruby is a wonderfully simple language, and Rails is an astonishingly powerful framework. Unfortunately, installing them can sometimes be the hardest part of learning to code.

In this guide I will lay out the least error-prone method of installing that we've found. Hopefully you will have no issues and it will be smooth sailing.

In case you do run into an error, first try restarting your computer and then re-try the last step that you got stuck on. If that doesn't work, we'll fix it together.

If you can't install Ruby on your laptop for some reason (for example, it belongs to your employer and you are not allowed to install things), skip to here.

@raghubetina
raghubetina / sublime.md
Last active April 26, 2017 15:38
Sublime Setup Guide

One-Time Sublime Configuration

We are going to be writing all of our code using the plain text editor Sublime Text 3. In this guide, you will customize your installation with shortcuts and other things in order to make your life easier.

What follows may seem opaque, but don't worry about it -- we just need to go through this process once, and then we'll be all set for the quarter. You aren't expected to understand exactly how it is all working right now.

Installation

Download Sublime Text 3 (not 2) for your platform of choice [here][1], and install it (locate and double-click the file you just downloaded).

@raghubetina
raghubetina / person.rb
Created July 16, 2014 13:58
Day 10 Warmup
# The following line will pull Rails' enhancements of Ruby's Date class into
# this script.
# You will then be able to use methods like Date.today, which returns an object
# representing today.
# You can also do things like Date.parse("1809-02-12") and it will return an
# object representing that date.
# You can then subtract one from the other to find the number of days between.
require 'active_support/core_ext/date/calculations'
class Person < Primate
@raghubetina
raghubetina / list_tag.rb
Created May 25, 2013 22:31
A simple typeahead input tag
module ApplicationHelper
def list_tag(name, *args)
options = args.extract_options!.merge(name: name, list: name)
input_tag = tag :input, options
datalist_tag = content_tag :datalist, nil, id: name do
args[0].collect do |value|
tag :option, value: value
end.join.html_safe
end
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
require 'open-uri'
require 'json'
require './student.rb'
url = "http://yearbook-api.herokuapp.com/2013/Spring/36.json"
raw_response_string = open(url).read
ruby_response_object = JSON.parse(raw_response_string)
list_from_api = ruby_response_object["students"]
class Student
attr_accessor :name, :photo_url, :section, :twitter
def introduce
return " <li>
<img src='#{self.photo_url}'>
<h3><a href='https://twitter.com/#{self.twitter}'>#{self.name}</a></h3>
</li>"
end
end
@raghubetina
raghubetina / friendbc.rb
Last active December 16, 2015 01:39
Example of reading from the Graph API
require 'open-uri'
require 'json'
your_access_token = "put your access token from the Graph API Explorer here"
url = "https://graph.facebook.com/me/home?fields=from,picture,link,source,name,description,type&access_token=#{your_access_token}"
result = JSON.parse(open(url).read)
posts = result["data"]
5.times do |i| for (var i = 0; i < 5; i++) {
puts "howdy #{i}" alert("howdy " + i.toString());
end };
(10..20).step(2) do |i| for (var i = 10; i <= 20; i = i + 2) {
puts "howdy #{i}" alert("howdy " + i.toString());
end };
a = ["apple", "orange", "banana"] var a = ["apple", "orange", "banana"];
a.each do |fruit| for (var i = 0; i < a.length; i++) {