Skip to content

Instantly share code, notes, and snippets.

View bembu's full-sized avatar

Peter Kronström bembu

View GitHub Profile
@bembu
bembu / mhz14.ino
Created March 11, 2016 15:33
Read MH-Z14 CO2 Sensor via SoftwareSerial
#include <SoftwareSerial.h>
#define CO2_TX 3
#define CO2_RX 2
SoftwareSerial SerialCO2(CO2_RX, CO2_TX); // RX, TX
const uint8_t cmd[9] = {0xFF,0x01,0x86,0x00,0x00,0x00,0x00,0x00,0x79};
int getCO2() {
@bembu
bembu / monty.py
Last active February 15, 2016 17:37
Monty Hall Proof
# A quick test to prove https://en.wikipedia.org/wiki/Monty_Hall_problem
import random
ITERATIONS = 100000
DOORS = ["goat", "goat", "tesla"]
j = 0
for i in range (0, ITERATIONS):
shuffled_list = DOORS[:] # copy a list
random.shuffle(shuffled_list) # shuffle our copy
"""
This is a crude script to download the first subtitle query from SubScene.
Install:
- python 2.7+ required
- pip install beautifulsoup4
How to use:
1) copy the filename to clipboard
- Windows: select the file, press F2, CTRL+C