Skip to content

Instantly share code, notes, and snippets.

View sliminality's full-sized avatar

Slim sliminality

View GitHub Profile
@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 / 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 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 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 / 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 / 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 / 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 / README.md
Last active July 4, 2017 11:30
The Missing README provides installation instructions for true JavaScript development beginners

The Missing README for JavaScript Projects

This README provides general instructions for installing Node.js and npm ecosystem projects from GitHub.

Many project READMEs assume a baseline level of user knowledge, but the following "Getting Started" section isn't very helpful to an absolute beginner:

Getting Started

npm install
@sliminality
sliminality / reference.md
Last active July 6, 2017 17:32
Sublime project config reference

Build system arguments

Argument Example Notes
cmd ['python', '-m', '$project'] Required if shell_cmd is empty; overridden by shell_cmd; searched in PATH
shell_cmd yarn build Required if cmd is empty; overrides cmd
working_dir ?? Temporarily change to directory before executing cmd
env { EDITOR: 'vim' }? Can merge in a dictionary before passing to cmd; expands environment variables.
shell true Runs cmd through the shell if true; noop if shell_cmd is used
path /User/sarah/git Used by cmd; expands environment variables.
@sliminality
sliminality / simple.tex
Created September 26, 2017 21:20
Simple pandoc template
\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$babel-lang$,$endif$$if(papersize)$$papersize$paper,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{$documentclass$}
$if(beamerarticle)$
\usepackage{beamerarticle} % needs to be loaded first
$endif$
$if(fontfamily)$
\usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$}
$else$
\usepackage{lmodern}
$endif$
$if(linestretch)$