Skip to content

Instantly share code, notes, and snippets.

View idmontie's full-sized avatar

Ivan Montiel idmontie

View GitHub Profile
@idmontie
idmontie / check_mic.py
Last active November 26, 2020 01:36
Testing Matrix Voice
import pyaudio
p = pyaudio.PyAudio()
info = p.get_host_api_info_by_index(0)
numdevices = info.get('deviceCount')
for i in range(0, numdevices):
if (p.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels')) > 0:
print("Input Device id ", i, " - ",
p.get_device_info_by_host_api_device_index(0, i).get('name'))
@idmontie
idmontie / temp.py
Created November 23, 2020 17:47
Run a GPIO pin based on temp
'''
Run an efficient loop that checks on the RP2 temperature every second.
If the tempt exceeds a threshold, turn the fan on until the next check.
pip install gpiozero
'''
from gpiozero import LED
from time import sleep
@idmontie
idmontie / index.js
Created June 6, 2019 18:06
Intercom webhook signature validation
const express = require('express');
const bodyParser = require('body-parser');
const crypto = require('crypto');
const serverless = require('serverless-http');
const app = express();
const KEY = 'YOUR_KEY';
app.use(bodyParser.raw({
type: '*/*',
@idmontie
idmontie / todo.md
Created March 8, 2019 21:19
TODO.md template for VS Code TODO Plugin

Key ☐ incomplete · ✔ completed · ✘ canceled

Title: ☐ Item 1 ☐ Item 2

export default class Toggle extends Component {
static TOGGLE = 'TOGGLE';
state = { on: false }
onClick = (e) => {
e.preventDefault();
this.internalSetState(state => ({
on: !state.on,
class App extends Component {
stateReducer = (prevState, nextState) => {
switch (nextState.type) {
case Toggle.TOGGLE: {
const count = prevState.count || 0;
const isOn = count < 4 ? nextState.on : false;
return {
...prevState,
...nextState,
(state, action) => {
switch (action.type) {
case TOGGLE: {
const count = state.count || 0;
const isOn = count < 4 ? action.changes.on : false;
return {
...state,
...action.changes,
count: isOn ? count + 1 : count,
class App extends Component {
state = { clickCount: 0 }
canClick() {
return this.state.clickCount < 4;
}
onIncrement() {
this.setState(state => ({
clickCount: state.clickCount + 1,
<Toggle>
{({ on, onToggle }) => (
<Switch on={on} onToggle={onToggle} />
)}
</Toggle>
export default class Toggle extends Component {
state = { on: false }
onClick = (e) => {
e.preventDefault();
this.setState(state => ({
on: !state.on,
}));
}