Skip to content

Instantly share code, notes, and snippets.

View elliott-beach's full-sized avatar

Elliott Beach elliott-beach

  • Epic
  • Minnesota
View GitHub Profile
@elliott-beach
elliott-beach / solver.py
Last active May 14, 2022 05:24
Solving SEND+MORE=MONEY rapidly using backtracking search
# Solves the SEND + MORE = MONEY letter substituion puzzle as a constraint satisfaction problem using backtracking search,
# searching variables (letters) in the least constrained ordering and values (digits) in the most constrained ordering,
# making the algorithm thousands of times faster.
from pprint import pprint
s1 = 'send'
s2 = 'more'
s3 = 'money'
@elliott-beach
elliott-beach / WA.json
Last active November 8, 2017 17:22
Web Speech API JSON Definition
{
"info": {
"name": "Web Speech API Specification",
"subsection_number": null,
"subsection_name": null,
"url": "https://w3c.github.io/speech-api/webspeechapi.html"
},
"features": [
"SpeechRecognition",
"SpeechRecognitionAlternative",
@elliott-beach
elliott-beach / setjmp.c
Created October 12, 2017 20:10
Comments on setjmp
#include <stdio.h>
#include <setjmp.h>
#include <signal.h>
#include <string.h>
#include <unistd.h>
#include <sys/time.h>
#define SECOND 1000000
#define STACK_SIZE 4096
@elliott-beach
elliott-beach / bcvi.c
Created October 2, 2017 16:27
Version 1.4
/* Badly Coded Print Server BCLPR, a product of Badly Coded, Inc. */
/* Change log: */
/* Version 1.4, released 10/ 6/2014 */
/* Version 1.3, released 9/29/2014 */
/* Version 1.2, released 9/22/2014 */
/* Version 1.1, released 9/15/2014 */
/* Version 1.0, released 9/ 9/2014 */
.file "foo.c"
.section .rodata
.align 8
.LC0:
.string "%s should get paid %.3f because %s.\n"
.text
.globl write_check
.type write_check, @function
write_check:
.LFB0:
@elliott-beach
elliott-beach / bcvi.c
Created September 20, 2017 16:37
Badly Coded v 1.1
/* Badly Coded Text Editor BCVI, a product of Badly Coded, Inc. */
/* This is an example insecure program for CSci 5271 only: don't copy
code from here to any program that is supposed to work
correctly! */
/* version 1.0 was for exploits due 9/15/2017 */
/* This is version 1.1, for exploits due 9/22/2017. */
long bcvi_version = 110; /* 1.1 */
@elliott-beach
elliott-beach / problem4.c
Last active September 14, 2017 22:36
Problem 4
/*
Here’s a function that’s intended to reverse the order of a subsequence of integers within an
array. For instance suppose the array a originally contains the integers 1 2 3 4 5 6 7 8 9. If
you call reverse_range(a, 2, 5), the afterwards the array a will contain the same integers but
with the ones in positions 2 through 5 (counting from zero) in the opposite order. I.e., a will be 1
2 6 5 4 3 7 8 9.
Unfortunately you’ll see that this function was not implemented very carefully.
*/
/*
@elliott-beach
elliott-beach / request_iter_lines_test.py
Created September 2, 2017 02:51
Converted to python3 / BytesIO form, the tests pass
import unittest
import requests
from io import BytesIO
print(requests.__file__)
class TestIterLines(unittest.TestCase):
def iter_lines_response(self, chunk_size, delimiter=None):
response = requests.Response()
@elliott-beach
elliott-beach / err.txt
Created August 25, 2017 15:50
PackageManager::Rubygems.update "split" error
2.4.1 :009 > PackageManager::Rubygems.update "split"
ETHON: performed EASY effective_url=https://rubygems.org/api/v1/gems/split.json response_code=200 return_code=ok total_time=0.186102
HTTP Cache: [GET /api/v1/gems/split.json] miss, store
Saving split
Project Load (1.3ms) SELECT "projects".* FROM "projects" WHERE "projects"."name" = $1 AND "projects"."platform" = $2 LIMIT $3 [["name", "split"], ["platform", "Rubygems"], ["LIMIT", 1]]
(0.6ms) BEGIN
Project Exists (1.3ms) SELECT 1 AS one FROM "projects" WHERE "projects"."name" = $1 AND ("projects"."id" != $2) AND "projects"."platform" = $3 LIMIT $4 [["name", "split"], ["id", 2], ["platform", "Rubygems"], ["LIMIT", 1]]
Version Load (1.1ms) SELECT "versions".* FROM "versions" WHERE "versions"."project_id" = $1 [["project_id", 2]]
SQL (0.9ms) UPDATE "projects" SET "updated_at" = $1, "latest_release_published_at" = $2 WHERE "projects"."id" = $3 [["updated_at", "2017-08-25 15:47:13.860364"], ["latest_release_published_at", "2017-08-25 15:46:55
@elliott-beach
elliott-beach / err.txt
Created August 24, 2017 02:33
Travis build fails
0.04s$ $HOME/gopath/bin/goveralls -coverprofile=coverage.out -service=travis-ci -repotoken $COVERALLS_TOKEN
flag needs an argument: -repotoken
Usage: /home/travis/gopath/bin/goveralls [options]
-covermode string
sent as covermode argument to go test (default "count")
-coverprofile string
If supplied, use a go cover profile (comma separated)
-debug
Enable debug output
-endpoint string