Skip to content

Instantly share code, notes, and snippets.

@ericabell
ericabell / gist:6186ba9a1f6ed99cbaaf
Created November 14, 2014 21:34
plot sin and cos from 0 to 360 degrees with nice tick labels
x = var('x')
f(x) = sin((x*pi)/180)
g(x) = cos((x*pi)/180)
p1 = plot([f,g],
(x,0,360),
ticks=[[30,45,60,90,120,135,150,180,270,360],
[-1,
-sqrt(3)/2,
-sqrt(2)/2,
@ericabell
ericabell / gist:e6c1647225121120be45
Created November 15, 2014 13:02
easy way to get a unit vector
def unit(v):
mag = sqrt(v[0]*v[0]+v[1]*v[1])
return (v[0]/mag, v[1]/mag)
VF = plot_vector_field(unit([-y,-x]),[x,-2,2],[y,-2,2])
@ericabell
ericabell / calc_exams.sty
Created September 19, 2015 11:36
Latex Style File for Calculus Exams
%
% advanced_calc.sty
%
% This is the LaTex style file for Calculus Exams and Handouts.
%
\RequirePackage{amssymb, amsfonts, amsmath, latexsym, verbatim, xspace, setspace}
\RequirePackage{tikz}
\usetikzlibrary{plotmarks}
\RequirePackage{pgfplots}
@ericabell
ericabell / qtext.bash
Last active November 12, 2015 11:49
Fix latex for sage script
qtext() {
cp $1 $1.bak
sed -i -e 's/^/q_text.append(r"/' $1
sed -i -e 's/$/")/' $1
}
@ericabell
ericabell / rsa.py
Created January 15, 2017 02:35
A simple RSA implementation in Python
'''
620031587
Net-Centric Computing Assignment
Part A - RSA Encryption
'''
import random
'''
@ericabell
ericabell / format_text.py
Created March 3, 2017 17:55
fix word wrap in file
import textwrap
f = open('sample_input_text.asc','r')
contents = f.read()
split_contents = contents.splitlines()
for line in split_contents:
dedent_line = textwrap.dedent( line )
import pandas
import requests
from bs4 import BeautifulSoup
page = requests.get('http://www.politico.com/2012-election/results/president/wisconsin/')
soup = BeautifulSoup(page.text, "html.parser")
for body in soup("tbody"):
body.unwrap()
@ericabell
ericabell / 0_reuse_code.js
Created June 25, 2017 16:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ericabell
ericabell / user-input-addition.js
Created August 13, 2017 16:41
Read a series of numbers from the terminal, compute their sum when input stream closes
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
prompt: 'Enter numbers sep by newlines. Ctrl-d when done> \n'
});
let inputStack = [];
@ericabell
ericabell / app.js
Created August 29, 2017 03:19
I think the map method runs synchronously
let myBigArray = []
for(let i=0; i<2000000; i++) {
myBigArray.push(i);
}
console.log('Done filling the array.');
let myNewBigArray = myBigArray.map( (e) => {
return e+2;