Instantly share code, notes, and snippets.

View chicken-wing-prices.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View A249067.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View sqrt fact floor 2018.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View 2018-sqrt-floor-fact.py
from math import factorial, sqrt, floor
id = lambda x: x
commands = {
's': sqrt,
'f': floor,
'!': factorial,
}
View README.md
View everyones-a-mathematician.js
javascript:(function() {function textNodesUnder(el){ var n, a=[], walk=document.createTreeWalker(el,NodeFilter.SHOW_TEXT,null,false); while(n=walk.nextNode()) a.push(n); return a; }; var nodes=textNodesUnder(document.body); var lowercase = 'a-zàèìòùáéíóúýâêîôûãñõäëïöüÿçßøåæœ'; var uppercase = 'A-ZÀÈÌÒÙÁÉÍÓÚÝÂÊÎÔÛÃÑÕÄËÏÖÜŸÇØÅÆ'; var one_name = '['+uppercase+']['+lowercase+']+\\.?'; var re_name = new RegExp('((?:(?:'+one_name+'(?:-'+one_name+')*|(?:['+uppercase+']\\.)+)(?: (?:(?:['+uppercase+']\\.)+|'+one_name+'(?:-'+one_name+')*))* (?:(?:de|von|van|ibn) |(?:ibn )?al-|el-|d\')?'+one_name+'(?:-'+one_name+')*)|Euclid|Archimedes|Pythagoras|Brahmagupta|Eudoxus|Fibonacci|Aryabhata|Apollonius|Diophantus|Bháscara|Hipparchus|Archytus|Panini|Aristotle|Pappus|Hippocrates|Thales)','g'); Array.prototype.map.call(nodes,function(n){ n.textContent = n.textContent.replace(re_name,'Mathematician $1')}) })()
View single-quote-in-exam-file.exam
// Numbas version: exam_question_groups
{"name": "Single quote in .exam file", "extensions": [], "resources": [], "navigation": {"showfrontpage": false, "preventleave": false, "allowregen": true}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"statement": "<p>it's OK</p>", "variablesTest": {"maxRuns": 100, "condition": ""}, "extensions": [], "rulesets": {}, "variables": {}, "functions": {}, "metadata": {"licence": "None specified", "description": ""}, "preamble": {"css": "", "js": ""}, "name": "Single quote in .exam file", "tags": [], "parts": [], "variable_groups": [], "ungrouped_variables": [], "advice": ""}]}]}
View rounding-two-thirds-x.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View oscars.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View log_replacement.php
<?php
function find_logs_without_strings($str) {
// this function finds log_<whatever>(, then searches forward until it finds the matching closing bracket.
// it calls itself on the contents of the brackets, so any nested logs are caught
// it doesn't deal with strings, or `log10`. It wouldn't be too hard to add, but the resulting code would be UGLY
$offset = 0;
$len = strlen($str);
while($offset<$len) {
if(preg_match("/log_([\S]+?)\(/",$str,$m,PREG_OFFSET_CAPTURE,$offset)) {