Skip to content

Instantly share code, notes, and snippets.

View sophiebits's full-sized avatar

Sophie Alpert sophiebits

View GitHub Profile
@sophiebits
sophiebits / reducer-with-effects.js
Last active July 29, 2020 12:10 — forked from davidkpiano/reducer-with-effects.js
An idea for actor-model-based effects with reducers
import {
useReducerWithEffects,
emitEffect,
} from 'react';
// In a component
const UserComponent = () => {
function fetchUserEffect(id, parentRef) {
const controller = new AbortController();
const {useCallback, useEffect, useReducer, useRef} = require('react');
let effectCapture = null;
exports.useReducerWithEmitEffect = function(reducer, initialArg, init) {
let updateCounter = useRef(0);
let wrappedReducer = useCallback(function(oldWrappedState, action) {
effectCapture = [];
try {
let newState = reducer(oldWrappedState.state, action.action);
<!doctype html>
<html>
<head>
<script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/2.2.0/es5-shim.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/2.2.0/es5-sham.js"></script>
<script src="http://fb.me/react-0.8.0.min.js"></script>
<script src="http://fb.me/JSXTransformer-0.8.0.js"></script>
<script type="text/jsx">
/** @jsx React.DOM */
var InputBox = React.createClass({
/* This class is used to create the /topic/projectfeedback page,
* which shows expandable lists of feedback requests that need answering.
*/
var ProjectFeedbackPage = React.createClass({
propTypes: {
topic: React.PropTypes.string.isRequired
},
render: function() {
var helpCollection = new DiscussionItemCollection([], {
topic: this.props.topic,
$ hg st
$ touch hello
$ hg st
$ rm hello
$ hg st
\documentclass[11pt]{article}
\usepackage{enumerate}
\usepackage{fullpage}
\usepackage{fancyhdr}
\usepackage{amsmath, amsfonts, amsthm, amssymb}
\setlength{\parindent}{0pt}
\setlength{\parskip}{5pt plus 1pt}
\pagestyle{empty}
\def\indented#1{\list{}{}\item[]}
signature Stuff =
sig
type pizza
val x : 7
end
let val x = 5
val y = 7
in

Recover the Sequence

Merge sort is one of the classic sorting algorithms. It divides the input array into two halves, recursively sorts each half, then merges the two sorted halves.

In this problem merge sort is used to sort an array of integers in ascending order. The exact behavior is given by the following pseudo-code:

function merge_sort(arr):
    n = arr.length()
    if n <= 1:
diff -r 7f333be583d6 exercises.py
--- a/exercises.py Fri Sep 02 14:25:23 2011 -0700
+++ b/exercises.py Sun Sep 04 19:26:16 2011 -0400
@@ -308,6 +308,7 @@
if problem_log.correct:
proficient = user_data.is_proficient_at(user_exercise.exercise)
+ explicitly_proficient = user_data.is_explicitly_proficient_at(user_exercise.exercise)
suggested = user_data.is_suggested(user_exercise.exercise)
problem_log.suggested = suggested
require 'sinatra'
require 'json'
require 'net/https'
USER = "KhanBugz"
PASS = ""
def gh_http
http = Net::HTTP.new("api.github.com", 443)
http.use_ssl = true