Skip to content

Instantly share code, notes, and snippets.

@Wicker25
Wicker25 / ultrasonic_meter.cpp
Last active December 17, 2015 14:09
A DIY ultrasonic meter with display.
/*
Title --- ultrasonic_meter.cpp [example]
Copyright (C) 2013 Giacomo Trudu - wicker25[at]gmail[dot]com
This file is part of Rpi-hw.
Rpi-hw is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Droid Software Foundation version 3 of the License.
@Wicker25
Wicker25 / electronic_lock.cpp
Created January 5, 2014 16:37
Rpi-hw C++: electronic door lock with Raspberry Pi (prototype) http://youtu.be/yyIZsaoNUmE
/*
Title --- electronic_lock.cpp [example]
Copyright (C) 2013 Giacomo Trudu - wicker25[at]gmail[dot]com
This file is part of Rpi-hw.
Rpi-hw is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation version 3 of the License.
import { action, observable } from 'mobx';
export function withStateTransition(target) {
return class StateTransitionInjector extends target {
@observable state = 'idle';
@action
setState(state) {
this.state = state;
}
import { action, observable } from 'mobx';
export class SessionStore {
constructor() {}
@observable accessToken = null;
@observable user = null;
@observable isLoading = false;
async logInByAccessToken(accessToken) {
import React from 'react';
import { inject, observer } from 'mobx-react';
@inject('session')
@observer
export class MyComponent extends React.Component {
render() {
const { session } = this.props;
if (session.state === 'loading') {
import { observable } from 'mobx';
import { withStateTransition, stateTransition } from './StateTransition';
@withStateTransition
export class SessionStore {
constructor() {}
@observable accessToken = null;
@observable user = null;
import React from 'react';
export default class CreateUserModal extends React.Component {
render() {
const { isOpen, isLoading, errorMessage, onClose } = this.props;
if (isLoading) {
return <Spinner />;
}
import autobind from 'autobind-decorator';
import React from 'react';
import { inject, observer } from 'mobx-react';
import CreateUserModalStore from './CreateUserModalStore';
export default class CreateUserModal extends React.Component {
constructor(props) {
super(props);
this.modalStore = new CreateUserModalStore();
import autobind from 'autobind-decorator';
import React from 'react';
import { inject, observer } from 'mobx-react';
import CreateUserModalStore from './CreateUserModalStore';
export default class CreateUserModal extends React.Component {
constructor(props) {
super(props);
this.modalStore = new CreateUserModalStore();
var repl = require('repl');
function myEval(cmd, context, filename, callback) {
callback(null, String(cmd));
}
const replServer = repl.start({
prompt: '~> ',
//eval: myEval
});