This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Given two absolute paths on a file system, write a function to determine the difference between them. | |
// For example, `/a/b/c` and `/a/d` should yield `../../d`. | |
// `/a/b/c` and `/e/f` => `../../../e/f` | |
// `/` and `/a/b/c` => `/a/b/c` | |
// `/a/b/c` and `/` => `../../../` | |
function difference(path1, path2) { | |
// break the paths into lists and discard the first empty element |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
620031587 | |
Net-Centric Computing Assignment | |
Part A - RSA Encryption | |
''' | |
import random | |
''' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
qtext() { | |
cp $1 $1.bak | |
sed -i -e 's/^/q_text.append(r"/' $1 | |
sed -i -e 's/$/")/' $1 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% | |
% 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} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
NewerOlder