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
| class MockPlt: | |
| ''' | |
| Mock MatPlotLib library that can be used to capture plot data. | |
| ''' | |
| def __init__(self): | |
| self.plots = [] | |
| self._reset_plot() | |
| def show(self, **kwargs): | |
| self.plots.append(self.active_plot) | |
| self._reset_plot() |
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
| # Example URL: https://i.imgur.com/TqN0Be5.png | |
| # This let's you copy/paste a URL into your source code (png, bmp anyway) | |
| import base64 | |
| # This is for copying HTTP images | |
| from urllib.request import urlopen | |
| ... | |
| class EnhancedText(TweakableText): | |
| def __init__(self, master=None, cnf={}, **kw): |
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
| # Code without call outside, without call inside | |
| def a(): | |
| print("a() was called") | |
| # Code without call outside, with call inside | |
| def b(): | |
| print("b() was called") | |
| b() | |
| # Code with call outside, without call inside |
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
| # -*- coding: utf-8 -*- | |
| """ | |
| Created on Thu Jan 25 23:27:40 2018 | |
| @author: acbart | |
| """ | |
| import unittest | |
| from unittest.mock import patch | |
| import io |
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
| function renderSimple(workspace) { | |
| aleph = workspace.svgBlockCanvas_.cloneNode(true); | |
| aleph.removeAttribute("width"); | |
| aleph.removeAttribute("height"); | |
| if (aleph.children[0] !== undefined) { | |
| aleph.removeAttribute("transform"); | |
| aleph.children[0].removeAttribute("transform"); | |
| aleph.children[0].children[0].removeAttribute("transform"); | |
| var linkElm = document.createElementNS("http://www.w3.org/1999/xhtml", "style"); | |
| linkElm.textContent = Blockly.Css.CONTENT.join('') + '\n\n'; |
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
| /* Just a silly little bit of example code */ | |
| var filename = '__main__.py'; | |
| var python_source = 'a, b = 0'; | |
| parse = Sk.parse(filename, python_source); | |
| ast = Sk.astFromParse(parse.cst, filename, parse.flags); | |
| /* Actually useful stuff, taken from | |
| https://github.com/python-git/python/blob/master/Lib/ast.py#L219 */ | |
| var iter_fields = function(node) { |
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
| with open('data', 'r') as inputFile: | |
| with open('sampled', 'w') as outputFile: | |
| for index, line in enumerate(inputFile): | |
| # and maybe grab 3 more lines? | |
| outputFile.write(line) | |
| if index > SAMPLE_SIZE: | |
| break |
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
| (require 2htdp/image) | |
| (require 2htdp/universe) | |
| (define PMAX 10) | |
| (define CELL-SIZE 30) | |
| (define-struct cell (value polluted? x y)) | |
| ;; make-cell: number boolean number number -> cell | |
| ;; A cell has a value indicating permeability, | |
| ;; a flag indicating whether it has been polluted yet |
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
| // Query to GET a list of external tools, filter it for your tool, and then PUT it's changes | |
| // Need to change the <course_id>, add your filtering criteria, and | |
| // customize your data attributes for the tool. | |
| $.get('https://canvas.instructure.com/api/v1/courses/<course_id>/external_tools/', {}, function(result) { | |
| $.each(data, function(i, item) { | |
| if (item /* matches some criteria, maybe the name? */) { | |
| $.ajax({ url: 'https://canvas.instructure.com/api/v1/courses/<course_id>/external_tools/'+item.id, | |
| type: 'put', | |
| data: {'course_navigation[enabled]': 'true', |
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
| I’m not familiar with that article, but it reminds me of one of my “first day of class” lectures. | |
| Imagine you were assigned to write a 20-page paper, by the end of the semester, on Napoleon’s invasion of Russia. What would you need to know? | |
| [Guided classroom discussion, usually producing something like the following:] | |
| Know about Napoleon and Russia | |
| Know how to do library research | |
| Know how to structure a 20-page paper so it’s coherent. | |
| Know how to budget your time so you finish it by the end of the semester | |
| Now suppose you were required to write this paper in Swedish, using a quill pen. What else would you need to know? |