Skip to content

Instantly share code, notes, and snippets.

@mhr
mhr / continuous_cartpole.py
Created October 28, 2021 20:47 — forked from iandanforth/continuous_cartpole.py
Continuous Cartpole for OpenAI Gym
"""
Classic cart-pole system implemented by Rich Sutton et al.
Copied from http://incompleteideas.net/sutton/book/code/pole.c
permalink: https://perma.cc/C9ZM-652R
Continuous version by Ian Danforth
"""
import math
import gym
@mhr
mhr / marginClick.jsx
Last active February 21, 2021 23:13
Focusing after click on margin in Slate.js editor
import React, { useMemo, useState } from "react";
import { createEditor, Transforms, Editor } from "slate";
import { Slate, Editable, withReact, ReactEditor } from "slate-react";
import { Box } from "@chakra-ui/react";
const App = () => {
const editor = useMemo(() => withReact(createEditor()), []);
def find_indices(condition, list_):
return [i for i, x in enumerate(list_) if condition(x)]
class Network(nn.Module):
def __init__(self, vocab_dim, embed_dim, input_dim, hidden_dim=512):
self.embedding = nn.Embedding(vocab_dim, embed_dim)
self.rnn = nn.LSTM(embed_dim+input_dim,
hidden_dim,
batch_first=True)
self.out = nn.Linear(hidden_dim, vocab_dim)
@mhr
mhr / dabblet.css
Created April 7, 2012 02:29
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
@mhr
mhr / dabblet.css
Created February 13, 2012 21:40
Untitled
color: orange