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
declare module 'react-ranger' { | |
import React, { CSSProperties } from 'react' | |
export interface RangerOptions { | |
values: number[] | |
min: number | |
max: number | |
stepSize: number | |
steps?: number[] | |
tickSize?: number |
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 SlidingWindow { | |
constructor(options) { | |
this.before = options.before || 0 | |
this.after = options.after || 0 | |
this.blockSize = options.blockSize || 1 | |
this.bounds = options.bounds || [-Infinity, +Infinity] | |
this.start = null | |
this.end = null | |
this.startIndex = null |
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
window.repeat = (str, times) => (new Array(times + 1)).join(str); | |
window.pad = (num, maxLength) => window.repeat('0', maxLength - num.toString().length) + num; | |
window.formatTime = time => `${window.pad(time.getHours(), 2)}:${window.pad(time.getMinutes(), 2)}:${window.pad(time.getSeconds(), 2)}.${window.pad(time.getMilliseconds(), 3)}`; | |
window.logMediaEvent = (name, event) => { | |
const time = formatTime(new Date) | |
const video = event.target | |
console.log(`${name} @ ${time}`, video) | |
} | |
window.events = [ |
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 EventEmitter from 'eventemitter3' | |
import { Machine } from 'xstate' | |
import fibonacci from 'shared/lib/fibonacci' | |
const CORE_EVENT_REGX = /^core:(.*)/ | |
export default class MachineCore extends EventEmitter { | |
constructor(chart) { | |
super() | |
this.machine = new Machine(chart) |
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
#! /usr/bin/env node | |
var alfredo = require('alfredo') | |
var exec = require('child_process').exec; | |
var _ = require('lodash'); | |
var team = require('./team.json') | |
function fuzzyFindUsers(query) { | |
var names = _(team).pluck('name').value() | |
var matches = alfredo.fuzzy(query, names) | |
return _.map(matches, function(name){ return _.findWhere(team, {name: name})}) |
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 delegate (child) { | |
// make it happen | |
determineKey = function (on, toFind) { | |
var correctKey; | |
keys = Object.keys(on); | |
keys.forEach(function(key){ | |
if (on[key] === toFind) { | |
correctKey = key; | |
} | |
}); |
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
App.module("BreadcrumbApp", function(BreadcrumbApp, App, Backbone, Marionette, $, _){ | |
var API = { | |
showProject: function(id){ | |
new BreadcrumbApp.Show.Controller({ | |
/* Stuff */ | |
}); | |
}, | |
showUser: function(id){ |
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
Imagine that you are generating a report of assignment submission information for all of the students in a particular course from given arrays of students, assignments, and submissions. Here is some pseudocode that accomplishes that goal: | |
for assignment in assignments | |
print assignment.name | |
for student in students | |
for submission in submissions | |
continue if submission.student_id != student.id | |
continue if submission.assignment_id != assignment.id | |
print student.name, submission.grade |
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
// Original Code | |
// I've annoted some places where I find bugs | |
$(function() { | |
$.get("/reviews.json", {}, function(data) { | |
for (var review in data) { | |
var elem = "<li>"; | |
if (review.rating) { | |
elem += review.rating + " - "; | |
} | |
elem += review.title + " - "; |
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 () { | |
$(function(){ | |
$("#colorize").on("click", function () { | |
$("div.color-container > p").css({"color": "red"}); | |
}); | |
}); | |
})(); |
NewerOlder