Skip to content

Instantly share code, notes, and snippets.

def f(var):
print "%s" % (var)
def g(var):
pass
from __future__ import with_statement
class Foo:
pass
class QuestionNode:
def __init__(self, question):
self.question = question
self.yes_answer_node = None
self.no_answer_node = None
class AnimalNode:
def __init__(self, animal, parent_question_node):
self.animal = animal
self.parent_question_node = parent_question_node
#include <iostream>
class A
{
public:
A() : m_member(42)
{
std::cout << "A::A" << std::endl;
}
// mcs -reference:nunit.framework ReadableRegex.cs && nunit-console ReadableRegex.exe
using NUnit.Framework;
using System.Collections.Specialized;
using System.Text.RegularExpressions;
[TestFixture]
public class ReadableRegex
{
@bcr
bcr / gist:717647
Created November 27, 2010 06:44
Get a stream on a URL or a file
private static Stream GetFileOrUrlStream(string filenameOrUrl)
{
// This function should accept the following formats:
//
// http://example.com/downloads/mybitstream.bit
// mybitstream.bin
// ..\..\mybitstream.bin
// C:\dir\mybitstream.bin
// If there is no colon, then it must be a file reference. Make it
@bcr
bcr / keybase.md
Created March 27, 2014 03:14
Keybase proof for bcr

Keybase proof

I hereby claim:

  • I am bcr on github.
  • I am blake (https://keybase.io/blake) on keybase.
  • I have a public key whose fingerprint is EAF8 5937 D351 EF6D 4780 A3A8 BD9A A265 8023 E9CD

To claim this, I am signing this object:

@bcr
bcr / ocr.py
Created June 18, 2016 06:31
OpenCV fake OCR example
#https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_gui/py_image_display/py_image_display.html#display-image
#http://docs.opencv.org/3.0-beta/modules/imgproc/doc/miscellaneous_transformations.html
#http://docs.opencv.org/2.4/doc/tutorials/imgproc/threshold/threshold.html
import cv2
# Original image for annotation
img = cv2.imread('CSH-drink-4k.jpg')
# Grayscale image
@bcr
bcr / displaytest.py
Created June 10, 2017 01:58
Minimal CircuitPython display code
import board
import busio
import digitalio
import ili9341
spi = busio.SPI(clock=board.SCK,MOSI=board.MOSI,MISO=board.MISO)
spi.configure(baudrate=23000000)
cs = digitalio.DigitalInOut(board.D9)
dc = digitalio.DigitalInOut(board.D10)
display = ili9341.ILI9341(spi, cs=cs, dc=dc)
display.fill(ili9341.color565(255, 0, 0))
@bcr
bcr / turning.js
Created September 6, 2017 00:59
Circuit Playground MakeCode turning test
let current_x = 0
let turning_right = 0
let turning_left = 0
let threshold_changed = 0
let threshold_increment = 0
let turning_threshold = 0
input.buttonA.onEvent(ButtonEvent.Click, function () {
turning_threshold += threshold_increment
turning_threshold = Math.constrain(turning_threshold, 0, 1023)
threshold_changed = 1