Skip to content

Instantly share code, notes, and snippets.

View RyanMarcus's full-sized avatar

Ryan Marcus RyanMarcus

View GitHub Profile
@RyanMarcus
RyanMarcus / notes_for_shuai.md
Created August 31, 2018 19:37
Code review #1 for Shuai on D3 JS stuff

Separate scripts into their own files

Scripts should moved into their own files instead of embedding them directly inside of the HTML. For example, if you move your JavaScript into a file called fragmentViz.js, then you can include it in an html page like this:

<script src="fragmentViz.js"></script>

Use const and let

In modern JavaScript, var has been replaced with const and let. For example, instead of writing:

Lab 2: Inverted Index

Due: March 2nd, 11:55PM

In this lab, you'll make an inverted index from a subset of the Wikipedia dataset. As a reminder, an inverted index maps each term in a document (e.g., "alligator", "Ryan") to a set of documents in which that term appears. An example inverted index might look like:

penguin -> 91, 12, 58, 10
rhino -> 184, 182, 87, 10
@RyanMarcus
RyanMarcus / sql_lab.md
Created January 23, 2018 20:39
COSI 132 Lab #1 SQL

COSI 132 Lab 1: Joins

Due date: TBD

Introduction

In this lab, you'll get experience using SQL to perform basic join operations on a small dataset. This lab will show you how a relational data model, combined with a powerful query processing language, can greatly simplify finding answers to complex questions.

Instead of installing a full-fledged DBMS on your machine, we'll be using https://www.db-fiddle.com, an interactive and web-based SQL interface.

Instructions

In the pursuit of some nice-looking, functional-feeling Python code, I'm wondering how to bind a set of names to the result of applying a function to their currently bound values. Consider this code:

# preamble
a = [4]
b = [5]
c = [6]

# code
a = len(a)

b = len(b)

import numpy as np
from matplotlib import pyplot as plt
import itertools
np.set_printoptions(precision=4, suppress=True)
def all_waves(N):
for i in itertools.count():
k = i + 1
import numpy as np
from matplotlib import pyplot as plt
import itertools
np.set_printoptions(precision=4, suppress=True)
def all_waves(N):
for i in itertools.count():
k = i + 1
import numpy as np
from matplotlib import pyplot as plt
N = 3
def get_basis(idx):
x = (idx // (N - 1)) + 1
y = (idx % (N - 1)) + 1
sin = np.sin(2 * np.pi * x * np.arange(N**2) / N**2)
@RyanMarcus
RyanMarcus / exam.md
Last active June 23, 2017 18:53
Practice exam Spring 2016

Please Read

These questions are representative of the ones that will be on the final exam. We will select around 10% to 20% of them for the exam. Note that we will possibly tweak the questions a little so some may not be not identical.

Here are the resources you should use for studying in addition to these sample questions:

The source code from the class demonstrations which you can find here: https://github.com/Cosi-12b

The complete set of slides from class: https://drive.google.com/a/brandeis.edu/folderview?id=0B2SSgva8RXyFNDdTY2hFeDNNRG8&amp;usp=sharing

@RyanMarcus
RyanMarcus / python2or3.py
Created March 7, 2016 20:39
Python 2 vs. 3 semantics
# Ryan Marcus 2016
# Think about what you would expect this code to print
# And then run it using Python 2.7.11 (or newer) and with Python 3
for i in range(20):
x = [i for i in range(2000, 4000)]
print(i)

The if collapse refactor

Whenever you have code like this:

if (condition) {
    if (confition2) {
        doSomeStuff();
    }
}