Skip to content

Instantly share code, notes, and snippets.

View maxwellE's full-sized avatar
🤔

Maxwell Elliott maxwellE

🤔
View GitHub Profile
@maxwellE
maxwellE / .vimrc
Created May 15, 2012 18:23
my vimrc
call pathogen#infect()
filetype plugin indent on
set background=dark
colorscheme Tomorrow-Night
set number
set guifont=Monaco:h12
set tabstop=2 shiftwidth=2 expandtab
" Intuitive backspacing in insert mode
set backspace=indent,eol,start
@maxwellE
maxwellE / rbconf.rb
Created October 4, 2012 03:35
Automated Twillio RubyConf ticket avaliability checker
require 'mechanize'
require 'twilio-ruby'
# Need to save a file with the html body to refer to later in the script since this is run
# in a cron job.
if File.exists?("rubyregistration.html")
body = File.read("rubyregistration.html")
else
File.open("rubyregistration.html","w+") do |file|
@maxwellE
maxwellE / review.md
Created December 9, 2012 00:11
neelam review

Below is a list of the topics we have talked about in the course. You can expect questions on most of these topics. Mostly conceptual questions, but there will be some questions that ask you to write some code too (including in Scheme). In other words, the finals will be like the mid-terms. A single cheat-sheet is allowed.

I don't know if I will be able to post a sample final. If you have questions, please email or post or stop by during my office hours (Thursday at 1-2, and Monday at 11-12).

@maxwellE
maxwellE / mt1.md
Created December 10, 2012 03:52
mt1 sol

I am still working on grading the midterms and hope to be done before class. In the meantime, here are some detailed comments on individual questions, based on what I have seen so far; sorry, I have not proofread these comments so there may be mistakes/typos:

  1. This was about the use of intermediate languages in compilers and interpreters. Many got parts of this wrong. For example, using int. lang. doesn't improve efficiency; it can even reduce it (because of compiling in two stages rather than directly to machine language).
@maxwellE
maxwellE / mt2.md
Created December 10, 2012 03:53
mt2

I am still working on grading the midterms and hope to be done before class. In the meantime, here are some detailed comments on individual questions, based on what I have seen so far: [I haven't proofread this, sorry for any typos]:

  1. This was about type errors being caught more easily in the OO approach. Most people got this. The point is that since nodes that are instances of a given non-terminal are represented as objects that are instances of the corresponding class, there being one class for
@maxwellE
maxwellE / primes.rb
Created December 15, 2012 01:21
Calculating Primes in Ruby
def isPrimeRegexp n
"1" * n =~ /^1?$|^(11+?)\1+$/
end
@maxwellE
maxwellE / template_ex.js
Created February 26, 2013 00:03
example for jia
// ajax call
req = $.get('/get_assets',{company_id: $(this).dataset.company});
req.success(function(data){
JST['template name']
assets: data
})
//template call
<img src="{{it.assets.pic1}}"<img>
import com.github.kevinsawicki.http.HttpRequest;
public class HTTPCaller {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
@maxwellE
maxwellE / fizz_buzz.rb
Last active December 14, 2015 12:39
FizzBuzz example implementation
class FizzBuzz
def initialize(lower_bound,upper_bound)
@lower_bound = lower_bound
@upper_bound = upper_bound
end
def evaluate
(@lower_bound..@upper_bound).map do |x|
if (x % 5) == 0 && (x % 3) == 0
"FizzBuzz"
elsif (x % 5) == 0
@maxwellE
maxwellE / async_json.java
Created April 2, 2013 18:02
Code for loading red lights needs to be in an async task bc we are using json http request
public void executeAsyncGet(View view) {
AsyncHttpClient client = new AsyncHttpClient();
RequestParams params = new RequestParams();
params.put("latitude", "40.192512");
params.put("longitude", "-83.526306");
params.put("distance_in_miles", "10000");
client.get("http://redlights.herokuapp.com/in_proximity_of",params ,new JsonHttpResponseHandler() {
@Override
public void onSuccess(JSONArray red_lights) {
for (int i = 0; i < red_lights.length(); i++) {