This file contains 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 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 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 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 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 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 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
# A list of dictionaries, where each dictionary represents a student and their assignment data | |
# Each user is uniquely defined by a given name, e.g., "Abomasnow" | |
# Each assignment's name is the human readable assignment name, e.g., "#43.4) Multiple Returns" | |
# The "events" key maps to a list of the student's events, given as a list of 4 values. | |
# The integer timestamp is an epoch time; note that some events trigger at the exact same time. | |
# Here are some common event/action types: | |
# code/set is when a student edits their code | |
# editor/run is when a student runs their code | |
# editor/reset is when they reset their code, and there's other editor/<Something> actions too | |
# feedback/<Something> is the specific kind of feedback that the student received |
This file contains 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
# Adjust this string to have your desired alphabet of letters | |
alphabet = "ABCDE" | |
# Adjust this list of strings to have the significantly different pairs | |
forbidden = ["AD", "AE", "CE", "DE"] | |
Then run! | |
def split_bads(universe, bad): | |
left, right = bad | |
modified = True |
This file contains 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
# BlockPy Examples | |
################################################################################ | |
# Boiler plate code automatically prepended before execution | |
# Import get_output, set_success, gently, explain | |
from pedal.report import * | |
# In JS, patch `get_program`, and then imperative define the report's source | |
report.set_source(get_program()) | |
# Run the tifa analysis; stuff is automatically added to the report | |
from pedal.tifa import tifa_analysis() | |
_tifa = tifa_analysis() |
This file contains 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', |