Title: ☐ Item 1 ☐ Item 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: '*/*', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class Toggle extends Component { | |
static TOGGLE = 'TOGGLE'; | |
state = { on: false } | |
onClick = (e) => { | |
e.preventDefault(); | |
this.internalSetState(state => ({ | |
on: !state.on, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class App extends Component { | |
state = { clickCount: 0 } | |
canClick() { | |
return this.state.clickCount < 4; | |
} | |
onIncrement() { | |
this.setState(state => ({ | |
clickCount: state.clickCount + 1, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Toggle> | |
{({ on, onToggle }) => ( | |
<Switch on={on} onToggle={onToggle} /> | |
)} | |
</Toggle> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class Toggle extends Component { | |
state = { on: false } | |
onClick = (e) => { | |
e.preventDefault(); | |
this.setState(state => ({ | |
on: !state.on, | |
})); | |
} |
NewerOlder