Skip to content

Instantly share code, notes, and snippets.

View davidb2's full-sized avatar

David Brewster davidb2

View GitHub Profile
@davidb2
davidb2 / badWords.cc
Created April 20, 2019 19:55
Example usage of ofURLFileLoader
#include <iostream>
#include <stdexcept>
#include <string>
#include "ofMain.h"
using std::cout;
using std::endl;
using std::ifstream;
using std::string;
@davidb2
davidb2 / main.cc
Created April 19, 2019 19:25
Example of making HTTP requests and manipulating JSON in openFramworks.
#include <iostream>
#include <stdexcept>
#include <string>
#include "ofxJSON.h"
#include "ofMain.h"
using std::string;
using std::cout;
using std::endl;
@davidb2
davidb2 / converter.py
Last active March 11, 2019 02:03
A tool to convert sudoku puzzles from http://lipas.uwasa.fi/~timan/sudoku/ to the right format.
#!/usr/bin/env python3.6
import argparse
import pathlib
import re
import sys
import urllib.parse
import urllib.request
'''
@davidb2
davidb2 / projectile-motion.py
Created January 9, 2019 06:20
Projectile Motion Simulation
#!/usr/bin/env python3.6
import argparse
import math
import pygame
import sys
WIDTH = 1500
HEIGHT = 1000
RADIUS = 10
MAX_FPS = 25
@davidb2
davidb2 / pingpong.c
Created December 27, 2017 23:36
ECE 391 pingpong remake
/**
* pingpong.c (with signals)
*
* Press ctr+z to run faster
* Press ctrl+\ to run slower
*
* Compile with: cc pingpong.c -o pingpong
* Run with: ./pingpong
*/
@davidb2
davidb2 / 7.txt
Created October 15, 2017 00:43
7-segment display
A E F . G C B D
0 1 1 1 0 0 1 1 1 -> 0xe7
1 0 0 0 0 0 1 1 0 -> 0x06
2 1 1 0 0 1 0 1 1 -> 0xcb
3 1 0 0 0 1 1 1 1 -> 0x8f
4 0 0 1 0 1 1 1 0 -> 0x2e
5 1 0 1 0 1 1 0 1 -> 0xad
6 1 1 1 0 1 1 0 1 -> 0xed
7 1 0 0 0 0 1 1 0 -> 0x86
8 1 1 1 0 1 1 1 1 -> 0xef
@davidb2
davidb2 / rev.cc
Created August 13, 2017 21:19
Reverse a linked list in place (recursive hackish solution)
// Compiled with: g++ -std=c++11 rev.cc -o rev
#include <iostream>
#include <utility>
struct Node {
int data;
Node* next;
Node(int data, Node* next) :
// ==UserScript==
// @name CS126
// @namespace https://prairielearn.engr.illinois.edu/*
// @description e
// @include *://prairielearn.engr.illinois.edu/*
// @version 1
// @grant none
// ==/UserScript==
function start() {
for l in list(map(lambda x:list(map(lambda y,z:int(y)*z,x[:-1].split(', '),[' ','██']*99)),list(open('in.txt')))):print(''.join(l))