Skip to content

Instantly share code, notes, and snippets.

View dandrake's full-sized avatar

Dan Drake dandrake

View GitHub Profile
@dandrake
dandrake / foundational_skills_and_concepts.md
Last active August 29, 2015 14:10
Foundational Skills & Concepts assignments

(a ROUGH DRAFT of something I'm considering for my linear algebra class next semester...)

What are these?

Every week you'll have an assignment intended to help you acquire and practice skills and concepts that are, well, foundational to the study of linear algebra. The ideas, procedures, and calculations in these assignments are essential to success in this course.

@dandrake
dandrake / gist:6fa2f03b5dff632706a9
Created December 31, 2014 01:25
get a list of row operations / elementary matrices that reduce a matrix to rref
# Sage has a built-in rref() method for matrices, but sometimes when
# teaching it's nice to get a list of the row operations you would do to
# put the matrix into rref -- or, equivalent, a list of the
# corresponding elementary matrices.
#
# This script contains two functions along those lines:
#
# rref(): returns a list of elementary matrices that put the matrix into rref
# rref_steps(): returns a list of strings that describe what row ops to do
#
@dandrake
dandrake / Cheryl, eigenvalues, eigenvectors.ipynb
Last active August 29, 2015 14:21
Cheryl, eigenvalues, eigenvectors
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dandrake
dandrake / duplicitysizes.py
Created March 8, 2012 14:55
script to print out file sizes from duplicity difftar and sigtar files
"""
I use duplicity to back up my files, and cron sends me an email every
day with the output from the backup. Sometimes the size of an
incremental backup is unusually large, and I wonder what made it so big.
This script takes a .difftar.gpg or .sigtar.gpg file and prints the
names of the files in it, listed in decreasing order by size. There's no
error checking of any kind. Enjoy!
Usage:
@dandrake
dandrake / singlecelldecode.py
Created March 14, 2012 04:19
Decode URLs from Sage single cell server into Sage code
"""
Permalinks from the Sage cell server [1] include the Sage code in the URL,
and sometimes you may want to get that Sage code without loading the URL
in a browser.
The get_sage_code function does exactly that. It's basically copied from
web_server.py [2]. Just feed it the full URL and it returns the Sage
code.
The get_urls function is the inverse. It is essentially stolen from line
@dandrake
dandrake / newton.sage
Created April 23, 2012 06:20
a Sage @interact for root finding with Newton's method
"""
My Newton's method Sage @interact. A reworked version of
http://wiki.sagemath.org/interact/calculus#Newton-Raphson_Root_Finding
by Neal Holtz, and which was in turn inspired by Marshall Hampton's
tangent line grapher.
This code is available as a published worksheet at
https://sagenb.kaist.ac.kr:8066/home/pub/53 and on the Sage cell server at
http://aleph.sagemath.org/?q=81e86e25-b27c-40c6-ac01-b7489b55e84e. (Note
that right now, you need to use
@dandrake
dandrake / mmm-sagetex.el
Last active June 13, 2019 08:47
Use MMM for SageTeX in emacs
;; add this to your .emacs / init.el to use mmm (multiple major modes) with SageTeX. This works with AUCTeX and
;; emacs 23.4. The fontification gets a little wonky, though; quotes inside a SageTeX environment throw
;; off the highlighting for the LaTeX bits that follow. But the modes correctly get switched.
;; if you don't have sage-mode installed, you can either (1) do "sage -i sage-mode" and follow the instructions to
;; enable it, or (2) replace sage-mode below with python-mode, which is good enough for regular editing of Sage code
(require 'mmm-auto)
(setq mmm-global-mode 'maybe)
@dandrake
dandrake / ddrake-condvar.c
Created October 18, 2020 13:43
pthread condition variables API, waking up multiple threads
/* Like join.c, but I want to see if multiple threads can wait on a single
condition. It looks like `pthread_cond_broadcast` is the API function for this.
What's weird is that this has some kind of race condition in it. I've seen:
* only the parent woken up
* parent and child2 woken up
* child2 woken up twice!
*/
@dandrake
dandrake / auctex-synctex-evince.el
Created April 4, 2012 03:04
Make AUCTeX do forward and inverse search with SyncTeX and Evince
;; This is originally from
;; http://ubuntuforums.org/showthread.php?s=618526e60dfcf25e6413439603fa08ad&t=1716268&page=2.
;; Thanks to user "florenzen". I've included the fixes for Ubuntu 11.10
;; and wrapped buffer-file-name in a call to file-truename because
;; kpathsea/SyncTeX follow symlinks; see
;; http://tex.stackexchange.com/questions/25578/why-is-synctex-in-tl-2011-so-fussy-about-filenames.
;; Forward/inverse search with evince using D-bus.
(if (require 'dbus "dbus" t)
(progn
select * from THINGS_IM_GONNA_DO where
thing = "give you up" or
thing = "let you down" or
thing = "run around and desert you" or
thing = "make you cry" or
thing = "say goodbye" or
thing = "tell a lie and hurt you";
select count(*) from problems;
99