Skip to content

Instantly share code, notes, and snippets.

View sliminality's full-sized avatar

Slim sliminality

View GitHub Profile
@sliminality
sliminality / 111-w17-tutorial9.md
Last active June 24, 2017 09:32
Final exam review problems for EECS 111, Winter 2017

EECS 111 Winter 2017 Tutorial 9 (Exam Practice)

Sarah Lim (http://sarahlim.com/eecs-111)

Q1. Scope and Mutation

In most countries, the age of majority is 18. Some countries have different laws. In Scotland, for instance, the age of majority is 16.

Suppose we want to write a program to determine whether someone is a legal adult. We'll write a global version that works for most countries, and a Scotland-specific version.

@sliminality
sliminality / snippets.js
Created May 30, 2017 02:44
reproducing crash
// http://loremipsumgenerator.com
// in an extension background script
// endpoint.target is the current debugging target
// triggers 'Aw, Snap'
chrome.debugger.sendCommand(endpoint.target, 'DOM.getDocument', {}, ({ root }) => {
chrome.debugger.sendCommand(endpoint.target, 'DOM.querySelector', { nodeId: root.nodeId, selector: 'footer' }, ({ nodeId }) => {
chrome.debugger.sendCommand(endpoint.target, 'CSS.getMatchedStylesForNode', { nodeId: nodeId }, (styles) => {
console.log(styles);
});
@sliminality
sliminality / playground.rs
Created May 25, 2017 15:56 — forked from anonymous/playground.rs
Rust code shared from the playground
struct Tree<'a> {
pawns: Vec<usize>,
rolls: Vec<usize>,
pawns_iter: std::slice::Iter<'a, usize>,
rolls_iter: std::slice::Iter<'a, usize>,
}
impl<'a> Tree<'a> {
fn new(pawns: Vec<usize>, rolls: Vec<usize>) -> Tree<'a> {
Tree {
@sliminality
sliminality / playground.rs
Created May 24, 2017 03:08 — forked from anonymous/playground.rs
Rust code shared from the playground
use std::sync::{Arc, Mutex};
use std::thread;
use std::sync::mpsc;
fn main() {
let v = vec![1, 2];
println!("{:?}", v.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(" "));
let mut iter = (0..4).zip((0..6));
for (x, y) in iter {
@sliminality
sliminality / big-o.md
Created May 23, 2017 02:24
big O explanation

Big O

Sarah Lim (slim at u.northwestern.edu)
Last updated 24 April 2016

Measuring performance

To measure an algorithm's efficiency, one intuitive idea is to consider the amount of time it takes to solve a problem (transform the input into the desired output).

Unfortunately, it's difficult to measure the exact runtime of an algorithm. In practice, runtimes are influenced by a lot of factors unrelated to the algorithm itself. For instance, the same function might run quickly on a state-of-the-art gaming PC, and much more slowly on an ancient Windows 98 machine.

@sliminality
sliminality / playground.rs
Created May 14, 2017 22:37 — forked from anonymous/playground.rs
Rust code shared from the playground
#![allow(dead_code)]
extern crate rand;
use rand::Rng;
use std::sync::{Arc, Mutex};
// use std::time::Duration;
use std::thread;
use std::sync::mpsc;
fn partition(arr: &mut [i32]) -> usize {
@sliminality
sliminality / big-o.md
Created April 24, 2017 00:11
fun thoughts about big O
title author date
ELI5: Big O
Sarah Lim
24 April 2016 (edited 23 April 2017)

Measuring performance

To measure an algorithm's efficiency, one intuitive idea is to consider the amount of time it takes to solve a problem (transform the input into the desired output).

@sliminality
sliminality / vim.md
Last active March 26, 2017 20:13
a vim cheat sheet by Jason Bertsche (https://github.com/TheBizzle)

Essentials

Command Meaning
:q quit
:w save
:w <filename> save as <filename>
:w! force save
:help <topic> get help on <topic>
:e open the file given by ``
@sliminality
sliminality / Default (OSX).sublime-keymap
Last active March 1, 2025 23:59
Racket and Sublime Text 3
{
// Evaluate file in the open SublimeREPL.
// Depends on you creating the Packages/User/EvalInREPL.sublime-macro file.
{ "keys": ["super+r"], "command": "run_macro_file", "args": { "file": "Packages/User/EvalInREPL.sublime-macro" },
"context": [
{ "key": "selector", "operator": "equal", "operand": "source.elm" }
]
},
// Reindent selection on tab
@sliminality
sliminality / conditionals.rkt
Created January 30, 2017 04:11
w17 eecs 111 review 1
;; Conditionals
(require 2htdp/image)
(require cs111/iterated)
;; boolean is one of
;; - true (#true, #t)
;; - false (#false, #f)
;; and : boolean, boolean, ... -> boolean