Skip to content

Instantly share code, notes, and snippets.

@benmcmorran
benmcmorran / README.md
Created October 5, 2022 00:19
Build and debug OpenOCD for Windows

Follow these steps to get OpenOCD building and debugging on Windows using VS Code.

Install dependencies

  1. Install MSYS2. Install it in the default location (C:\msys64).
  2. From the Start Menu, open a MSYS2 MINGW64 prompt.
  3. Get all build dependencies using pacman.
pacman -S base-devel mingw-w64-x86_64-gcc mingw-w64-x86_64-gdb git libtool autoconf automake mingw-w64-x86_64-libusb
@benmcmorran
benmcmorran / png.cmake
Last active January 29, 2022 04:03
CMake PNG encoder
set(CRC_LOOKUP_TABLE
-771559539 -1526341861 1007455905 1259060791 -714134636 -1570235646 996231864 1281784366
-589731905 -1411492055 852952723 1171273221 -608918618 -1397517520 901431946 1119744540
-810156055 -1196241025 565944005 1455205971 -925352976 -1075901594 651582172 1372678730
-1049724965 -1234614451 794826487 1483155041 -972835902 -1325104300 671994606 1594548856
-378745019 -1637089325 123907689 1885708031 -301921444 -1727644726 1010288 1997036262
-407419017 -1867483167 163128923 2126386893 -522550418 -1747078152 248832578 2043925204
-186917087 -2082672713 450215437 1842515611 -206169288 -2068763730 498629140 1790921346
-100641005 -1928894587 336475711 1661535913 -43150582 -1972722788 325317158 1684325040
-1528910307 -740712821 1255198513 1037565863 -1548523004 -726377838 1304234792 985283518
# Solution to https://fivethirtyeight.com/features/can-you-find-the-best-dungeons-dragons-strategy/
# Results
# expectation [10.50030281 9.83376316 11.16661513]
# best_option [0 2 2 2 2 2 2 2 2 2 2 2 2 0 0 0 0 0 0 0]
# worst_option [0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1]
import numpy as np
SAMPLES = int(1e9)
@benmcmorran
benmcmorran / Parser.cs
Created March 24, 2019 06:19
CMake Parser
namespace CMakeParser
{
using System;
using System.Collections.Generic;
using System.Text;
public class Range
{
public Range(int start, int end)
{
@benmcmorran
benmcmorran / quiz.py
Created August 22, 2017 02:55
Login quiz
# Displays a full-screen window asking a single question from the questions file.
# A correct answer dismisses the window after 1 second, while an incorrect
# answer displays the correct answer for 5 seconds.
# Question file is formatted as a question on one line, followed by the answer
# on another line. Blank or whitespace-only lines are ignored and can be used to
# improve the readability of the question file.
import tkinter as tk
import random
@benmcmorran
benmcmorran / prisoners.py
Created March 29, 2017 23:03
Prisoner Box Problem
import random
PRISONERS = 100
def search(i, boxes):
next_box = i
for _ in range(PRISONERS // 2):
if i == boxes[next_box]:
return True
next_box = boxes[next_box]
@benmcmorran
benmcmorran / red.py
Created July 3, 2015 20:32
.red domain search
import sys
import requests
ALREADY_TAKEN = 'is already taken'
AVAILABLE = 'is available'
response = requests.get('http://get.red/find-domain/' + sys.argv[1])
if AVAILABLE in response.text and ALREADY_TAKEN not in response.text:
print 'available'

Keybase proof

I hereby claim:

  • I am benmcmorran on github.
  • I am benmcmorran (https://keybase.io/benmcmorran) on keybase.
  • I have a public key whose fingerprint is 2431 99E0 BD6C A501 A8A7 184F 98FA F27A CF5E 3F48

To claim this, I am signing this object:

ImportError at /
No module named django.request
Request Method: GET
Request URL: http://0.0.0.0:8001/
Django Version: 1.4.8
Exception Type: ImportError
Exception Value:
No module named django.request
Exception Location: /edx/app/edxapp/edx-platform/cms/djangoapps/contentstore/views/component.py in <module>, line 19
Python Executable: /edx/app/edxapp/venvs/edxapp/bin/python