{% exercise %}
Using the mean() function above, find the mean of `x`, `y`, and `z`, and assign it to `result`.
{% initial %}
var x = 5, y = 10, z = 20;
var result = ;
{% solution %}
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
@implementation MainViewController | |
- (void)viewWillAppear:(BOOL)animated | |
{ | |
// Lower screen 20px on iOS 7 | |
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) { | |
CGRect viewBounds = [self.view bounds]; | |
viewBounds.origin.y = 20; | |
viewBounds.size.height = viewBounds.size.height - 20; | |
self.webView.frame = viewBounds; |
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
#! /bin/bash | |
BREACH_PATH=/opt/breach/breach # Path to your breach installation | |
SANDBOX_PATH=/opt/google/chrome/chrome-sandbox # Path to your chrome sandbox installation | |
export CHROME_DEVEL_SANDBOX=$SANDBOX_PATH | |
screen -d -m $BREACH_PATH |
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
mysql --user=YOUR_USERNAME --password=YOUR_PASSWORD -BNe "show tables" YOUR_DBSCHEMA_NAME | tr '\n' ',' | sed -e 's/,$//' | awk '{print "SET FOREIGN_KEY_CHECKS = 0;DROP TABLE IF EXISTS " $1 ";SET FOREIGN_KEY_CHECKS = 1;"}' | mysql --user=YOUR_USERNAME --password=YOUR_PASSWORD YOUR_DBSCHEMA_NAMEt |
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 getQueryParameters(str) { | |
return (str || document.location.search) | |
.replace(/(^\?)/, '') | |
.split('&') | |
.reduce(function (a, x, i) { | |
var n = x.split('='), y = n[0], z = n[1]; | |
try { z = JSON.parse(z); } catch(e) { } | |
a[y] = a[y] ? typeof a[y] == 'object' ? (a[y].push(z) && a[y]) : [a[y], z] : z; | |
return a; | |
}, {}); |
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
var assert; // TODO: write some assert lib/function | |
function success() { | |
// TODO: make some call to store student answer | |
} | |
function failure() { | |
// TODO: make some call to store student answer, update notebook with hints, etc | |
} |
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
import { success, failure } from './assessment'; | |
var results = []; | |
Tonic.createNotebook({ | |
element: document.getElementById('embed'), | |
source: ``, | |
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
// Add script tag to src="https://raw.githubusercontent.com/bettiolo/oauth-signature-js/master/dist/oauth-signature.min.js" | |
// to get oauthSignature function on window (global) | |
function randomString(length, chars) { | |
var result = ''; | |
for (var i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))]; | |
return result; | |
} | |
function jsonp(url, callback) { |
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
const _ensureNew = (ctor) => { | |
const fn = (...args) => !(this instanceof ctor) ? new ctor(...args) : ctor(...args); | |
fn.prototype = ctor.prototype; | |
return fn; | |
} | |
const ensureNew = (ctor) => { | |
const fn = _ensureNew(ctor); | |
fn.extend = Backbone.Model.extend; | |
return fn; |
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
const $rest = Symbol('rest'); | |
const $normal = Symbol('normal'); | |
const $optional = Symbol('optional'); | |
const $pattern = Symbol('pattern'); | |
const eq = a => b => a === b; | |
const toString = val => Object.prototype.toString.call(val).split(' ')[1].slice(0, -1); | |
const isString = a => typeof a === 'string'; | |
const isArray = a => Array.isArray(a); |
OlderNewer