|
|
The Boost Statechart LibraryTutorial |
A Japanese translation of an earlier version of this tutorial can be found at http://prdownloads.sourceforge.jp/jyugem/7127/fsm-tutorial-jp.pdf. Kindly contributed by Mitsuo Fukasawa.
The Boost Statechart library is a framework that allows you to quickly transform a UML statechart into executable C++ code, without needing to use a code generator. Thanks to support for almost all UML features the transformation is straight-forward and the resulting C++ code is a nearly redundancy-free textual description of the statechart.
This tutorial was designed to be read linearly. First time users should start reading right at the beginning and stop as soon as they know enough for the task at hand. Specifically:
We will use the simplest possible program to make our first steps. The statechart ...
... is implemented with the following code:
#include <boost/statechart/state_machine.hpp> #include <boost/statechart/simple_state.hpp> #include <iostream> namespace sc = boost::statechart; // We are declaring all types asstruct
s only to avoid having to // typepublic
. If you don't mind doing so, you can just as well // useclass.
// We need to forward-declare the initial state because it can // only be defined at a point where the state machine is // defined. struct Greeting; // Boost.Statechart makes heavy use of the curiously recurring // template pattern. The deriving class must always be passed as // the first parameter to all base class templates. // // The state machine must be informed which state it has to // enter when the machine is initiated. That's why Greeting is // passed as the second template parameter. struct Machine : sc::state_machine< Machine, Greeting > {}; // For each state we need to define which state machine it // belongs to and where it is located in the statechart. Both is // specified with Context argument that is passed to // simple_state<>. For a flat state machine as we have it here, // the context is always the state machine. Consequently, // Machine must be passed as the second template parameter to // Greeting's base (the Context parameter is explained in more // detail in the next example). struct Greeting : sc::simple_state< Greeting, Machine > { // Whenever the state machine enters a state, it creates an // object of the corresponding state class. The object is then // kept alive as long as the machine remains in the state. // Finally, the object is destroyed when the state machine // exits the state. Therefore, a state entry action can be // defined by adding a constructor and a state exit action can // be defined by adding a destructor. Greeting() { std::cout << "Hello World!\n"; } // entry ~Greeting() { std::cout << "Bye Bye World!\n"; } // exit }; int main() { Machine myMachine; // The machine is not yet running after construction. We start // it by calling initiate(). This triggers the construction of // the initial state Greeting myMachine.initiate(); // When we leave main(), myMachine is destructed what leads to // the destruction of all currently active states. return 0; }
This prints Hello World!
and Bye Bye World!
before exiting.
Next we will model a simple mechanical stop watch with a state machine. Such watches typically have two buttons:
And two states:
Here is one way to specify this in UML:
The two buttons are modeled by two events. Moreover, we also define the necessary states and the initial state. The following code is our starting point, subsequent code snippets must be inserted:
#include <boost/statechart/event.hpp> #include <boost/statechart/state_machine.hpp> #include <boost/statechart/simple_state.hpp> namespace sc = boost::statechart; struct EvStartStop : sc::event< EvStartStop > {}; struct EvReset : sc::event< EvReset > {}; struct Active; struct StopWatch : sc::state_machine< StopWatch, Active > {}; struct Stopped; // The simple_state class template accepts up to four parameters: // - The third parameter specifies the inner initial state, if // there is one. Here, only Active has inner states, which is // why it needs to pass its inner initial state Stopped to its // base // - The fourth parameter specifies whether and what kind of // history is kept // Active is the outermost state and therefore needs to pass the // state machine class it belongs to struct Active : sc::simple_state< Active, StopWatch, Stopped > {}; // Stopped and Running both specify Active as their Context, // which makes them nested inside Active struct Running : sc::simple_state< Running, Active > {}; struct Stopped : sc::simple_state< Stopped, Active > {}; // Because the context of a state must be a complete type (i.e. // not forward declared), a machine must be defined from // "outside to inside". That is, we always start with the state // machine, followed by outermost states, followed by the direct // inner states of outermost states and so on. We can do so in a // breadth-first or depth-first way or employ a mixture of the // two. int main() { StopWatch myWatch; myWatch.initiate(); return 0; }
This compiles but doesn't do anything observable yet.
For the moment we will use only one type of reaction: transitions. We insert the bold parts of the following code:
#include <boost/statechart/transition.hpp> // ... struct Stopped; struct Active : sc::simple_state< Active, StopWatch, Stopped > { typedef sc::transition< EvReset, Active > reactions; }; struct Running : sc::simple_state< Running, Active > { typedef sc::transition< EvStartStop, Stopped > reactions; }; struct Stopped : sc::simple_state< Stopped, Active > { typedef sc::transition< EvStartStop, Running > reactions; }; // A state can define an arbitrary number of reactions. That's // why we have to put them into an mpl::list<> as soon as there // is more than one of them // (see Specifying multiple reactions for a state). int main() { StopWatch myWatch; myWatch.initiate(); myWatch.process_event( EvStartStop() ); myWatch.process_event( EvStartStop() ); myWatch.process_event( EvStartStop() ); myWatch.process_event( EvReset() ); return 0; }
Now we have all the states and all the transitions in place and a number of events are also sent to the stop watch. The machine dutifully makes the transitions we would expect, but no actions are executed yet.
Next we'll make the stop watch actually measure time. Depending on the state the stop watch is in, we need different variables:
We observe that the elapsed time variable is needed no matter what state
the machine is in. Moreover, this variable should be reset to 0 when we
send an EvReset
event to the machine. The other variable is
only needed while the machine is in the Running state. It should be set to
the current time of the system clock whenever we enter the Running state.
Upon exit we simply subtract the start time from the current system clock
time and add the result to the elapsed time.
#include <ctime> // ... struct Stopped; struct Active : sc::simple_state< Active, StopWatch, Stopped > { public: typedef sc::transition< EvReset, Active > reactions; Active() : elapsedTime_( 0.0 ) {} double ElapsedTime() const { return elapsedTime_; } double & ElapsedTime() { return elapsedTime_; } private: double elapsedTime_; }; struct Running : sc::simple_state< Running, Active > { public: typedef sc::transition< EvStartStop, Stopped > reactions; Running() : startTime_( std::time( 0 ) ) {} ~Running() { // Similar to when a derived class object accesses its // base class portion, context<>() is used to gain // access to the direct or indirect context of a state. // This can either be a direct or indirect outer state // or the state machine itself // (e.g. here: context< StopWatch >()). context< Active >().ElapsedTime() += std::difftime( std::time( 0 ), startTime_ ); } private: std::time_t startTime_; }; // ...
The machine now measures the time, but we cannot yet retrieve it from the main program.
At this point, the advantages of state-local storage (which is still a relatively little-known feature) may not yet have become apparent. The FAQ item "What's so cool about state-local storage?" tries to explain them in more detail by comparing this StopWatch with one that does not make use of state-local storage.
To retrieve the measured time, we need a mechanism to get state
information out of the machine. With our current machine design there are
two ways to do that. For the sake of simplicity we use the less efficient
one: state_cast<>()
(StopWatch2.cpp shows the slightly
more complex alternative). As the name suggests, the semantics are very
similar to the ones of dynamic_cast
. For example, when we call
myWatch.state_cast< const Stopped & >()
and
the machine is currently in the Stopped state, we get a reference to the
Stopped
state. Otherwise std::bad_cast
is thrown.
We can use this functionality to implement a StopWatch
member
function that returns the elapsed time. However, rather than ask the
machine in which state it is and then switch to different calculations for
the elapsed time, we put the calculation into the Stopped and Running
states and use an interface to retrieve the elapsed time:
#include <iostream> // ... struct IElapsedTime { virtual double ElapsedTime() const = 0; }; struct Active; struct StopWatch : sc::state_machine< StopWatch, Active > { double ElapsedTime() const { return state_cast< const IElapsedTime & >().ElapsedTime(); } }; // ... struct Running : IElapsedTime, sc::simple_state< Running, Active > { public: typedef sc::transition< EvStartStop, Stopped > reactions; Running() : startTime_( std::time( 0 ) ) {} ~Running() { context< Active >().ElapsedTime() = ElapsedTime(); } virtual double ElapsedTime() const { return context< Active >().ElapsedTime() + std::difftime( std::time( 0 ), startTime_ ); } private: std::time_t startTime_; }; struct Stopped : IElapsedTime, sc::simple_state< Stopped, Active > { typedef sc::transition< EvStartStop, Running > reactions; virtual double ElapsedTime() const { return context< Active >().ElapsedTime(); } }; int main() { StopWatch myWatch; myWatch.initiate(); std::cout << myWatch.ElapsedTime() << "\n"; myWatch.process_event( EvStartStop() ); std::cout << myWatch.ElapsedTime() << "\n"; myWatch.process_event( EvStartStop() ); std::cout << myWatch.ElapsedTime() << "\n"; myWatch.process_event( EvStartStop() ); std::cout << myWatch.ElapsedTime() << "\n"; myWatch.process_event( EvReset() ); std::cout << myWatch.ElapsedTime() << "\n"; return 0; }
To actually see time being measured, you might want to single-step
through the statements in main()
. The StopWatch example
extends this program to an interactive console application.
So far so good. However, the approach presented above has a few limitations:
state_machine::initiate()
is called, a number of template
instantiations take place, which can only succeed if the full declaration
of each and every state of the machine is known. That is, the whole
layout of a state machine must be implemented in one single translation
unit (actions can be compiled separately, but this is of no importance
here). For bigger (and more real-world) state machines, this leads to the
following limitations:
All these limitations can be overcome with custom reactions. Warning: It is easy to abuse custom reactions up to the point of invoking undefined behavior. Please study the documentation before employing them!
Let's say your company would like to develop a digital camera. The camera has the following controls:
EvShutterHalf
,
EvShutterFull
and EvShutterReleased
EvConfig
eventOne use case for the camera says that the photographer can half-press the shutter anywhere in the configuration mode and the camera will immediately go into shooting mode. The following statechart is one way to achieve this behavior:
The Configuring and Shooting states will contain numerous nested states while the Idle state is relatively simple. It was therefore decided to build two teams. One will implement the shooting mode while the other will implement the configuration mode. The two teams have already agreed on the interface that the shooting team will use to retrieve the configuration settings. We would like to ensure that the two teams can work with the least possible interference. So, we put the two states in their own translation units so that machine layout changes within the Configuring state will never lead to a recompilation of the inner workings of the Shooting state and vice versa.
Unlike in the previous example, the excerpts presented here often outline different options to achieve the same effect. That's why the code is often not equal to the Camera example code. Comments mark the parts where this is the case.
Camera.hpp:
#ifndef CAMERA_HPP_INCLUDED #define CAMERA_HPP_INCLUDED #include <boost/statechart/event.hpp> #include <boost/statechart/state_machine.hpp> #include <boost/statechart/simple_state.hpp> #include <boost/statechart/custom_reaction.hpp> namespace sc = boost::statechart; struct EvShutterHalf : sc::event< EvShutterHalf > {}; struct EvShutterFull : sc::event< EvShutterFull > {}; struct EvShutterRelease : sc::event< EvShutterRelease > {}; struct EvConfig : sc::event< EvConfig > {}; struct NotShooting; struct Camera : sc::state_machine< Camera, NotShooting > { bool IsMemoryAvailable() const { return true; } bool IsBatteryLow() const { return false; } }; struct Idle; struct NotShooting : sc::simple_state< NotShooting, Camera, Idle > { // With a custom reaction we only specify that we might do // something with a particular event, but the actual reaction // is defined in the react member function, which can be // implemented in the .cpp file. typedef sc::custom_reaction< EvShutterHalf > reactions; // ... sc::result react( const EvShutterHalf & ); }; struct Idle : sc::simple_state< Idle, NotShooting > { typedef sc::custom_reaction< EvConfig > reactions; // ... sc::result react( const EvConfig & ); }; #endif
Camera.cpp:
#include "Camera.hpp" // The following includes are only made here but not in // Camera.hpp // The Shooting and Configuring states can themselves apply the // same pattern to hide their inner implementation, which // ensures that the two teams working on the Camera state // machine will never need to disturb each other. #include "Configuring.hpp" #include "Shooting.hpp" // ... // not part of the Camera example sc::result NotShooting::react( const EvShutterHalf & ) { return transit< Shooting >(); } sc::result Idle::react( const EvConfig & ) { return transit< Configuring >(); }
Caution: Any call to
simple_state<>::transit<>()
or
simple_state<>::terminate()
(see reference) will inevitably destruct the state
object (similar to delete this;
)! That is, code executed after
any of these calls may invoke undefined behavior! That's why
these functions should only be called as part of a return statement.
The inner workings of the Shooting state could look as follows:
When the user half-presses the shutter, Shooting and its inner initial state Focusing are entered. In the Focusing entry action the camera instructs the focusing circuit to bring the subject into focus. The focusing circuit then moves the lenses accordingly and sends the EvInFocus event as soon as it is done. Of course, the user can fully-press the shutter while the lenses are still in motion. Without any precautions, the resulting EvShutterFull event would simply be lost because the Focusing state does not define a reaction for this event. As a result, the user would have to fully-press the shutter again after the camera has finished focusing. To prevent this, the EvShutterFull event is deferred inside the Focusing state. This means that all events of this type are stored in a separate queue, which is emptied into the main queue when the Focusing state is exited.
struct Focusing : sc::state< Focusing, Shooting > { typedef mpl::list< sc::custom_reaction< EvInFocus >, sc::deferral< EvShutterFull > > reactions; Focusing( my_context ctx ); sc::result react( const EvInFocus & ); };
Both transitions originating at the Focused state are triggered by the same event but they have mutually exclusive guards. Here is an appropriate custom reaction:
// not part of the Camera example sc::result Focused::react( const EvShutterFull & ) { if ( context< Camera >().IsMemoryAvailable() ) { return transit< Storing >(); } else { // The following is actually a mixture between an in-state // reaction and a transition. See later on how to implement // proper transition actions. std::cout << "Cache memory full. Please wait...\n"; return transit< Focused >(); } }
Custom reactions can of course also be implemented directly in the state declaration, which is often preferable for easier browsing.
Next we will use a guard to prevent a transition and let outer states react to the event if the battery is low:
Camera.cpp:
// ... sc::result NotShooting::react( const EvShutterHalf & ) { if ( context< Camera >().IsBatteryLow() ) { // We cannot react to the event ourselves, so we forward it // to our outer state (this is also the default if a state // defines no reaction for a given event). return forward_event(); } else { return transit< Shooting >(); } } // ...
The self-transition of the Focused state could also be implemented as an in-state reaction, which has the same effect as long as Focused does not have any entry or exit actions:
Shooting.cpp:
// ... sc::result Focused::react( const EvShutterFull & ) { if ( context< Camera >().IsMemoryAvailable() ) { return transit< Storing >(); } else { std::cout << "Cache memory full. Please wait...\n"; // Indicate that the event can be discarded. So, the // dispatch algorithm will stop looking for a reaction // and the machine remains in the Focused state. return discard_event(); } } // ...
Because the in-state reaction is guarded, we need to employ a
custom_reaction<>
here. For unguarded in-state reactions
in_state_reaction<>
should be used for better code-readability.
As an effect of every transition, actions are executed in the following order:
Example:
Here the order is as follows: ~D(), ~C(), ~B(), ~A(), t(), X(), Y(), Z(). The transition action t() is therefore executed in the context of the InnermostCommonOuter state because the source state has already been left (destructed) and the target state has not yet been entered (constructed).
With Boost.Statechart, a transition action can be a member of any common outer context. That is, the transition between Focusing and Focused could be implemented as follows:
Shooting.hpp:
// ... struct Focusing; struct Shooting : sc::simple_state< Shooting, Camera, Focusing > { typedef sc::transition< EvShutterRelease, NotShooting > reactions; // ... void DisplayFocused( const EvInFocus & ); }; // ... // not part of the Camera example struct Focusing : sc::simple_state< Focusing, Shooting > { typedef sc::transition< EvInFocus, Focused, Shooting, &Shooting::DisplayFocused > reactions; };
Or, the following is also possible (here the state machine itself serves as the outermost context):
// not part of the Camera example struct Camera : sc::state_machine< Camera, NotShooting > { void DisplayFocused( const EvInFocus & ); };
// not part of the Camera example struct Focusing : sc::simple_state< Focusing, Shooting > { typedef sc::transition< EvInFocus, Focused, Camera, &Camera::DisplayFocused > reactions; };
Naturally, transition actions can also be invoked from custom reactions:
Shooting.cpp:
// ... sc::result Focusing::react( const EvInFocus & evt ) { // We have to manually forward evt return transit< Focused >( &Shooting::DisplayFocused, evt ); }
Often a state must define reactions for more than one event. In this
case, an mpl::list<>
must be used as outlined below:
// ... #include <boost/mpl/list.hpp> namespace mpl = boost::mpl; // ... struct Playing : sc::simple_state< Playing, Mp3Player > { typdef mpl::list< sc::custom_reaction< EvFastForward >, sc::transition< EvStop, Stopped > > reactions; /* ... */ };
Non-trivial state machines often need to post internal events. Here's an example of how to do this:
Pumping::~Pumping() { post_event( EvPumpingFinished() ); }
The event is pushed into the main queue. The events in the queue are
processed as soon as the current reaction is completed. Events can be
posted from inside react
functions, entry-, exit- and
transition actions. However, posting from inside entry actions is a bit
more complicated (see e.g. Focusing::Focusing()
in
Shooting.cpp
in the Camera example):
struct Pumping : sc::state< Pumping, Purifier > { Pumping( my_context ctx ) : my_base( ctx ) { post_event( EvPumpingStarted() ); } // ... };
As soon as an entry action of a state needs to contact the "outside
world" (here: the event queue in the state machine), the state must derive
from state<>
rather than from
simple_state<>
and must implement a forwarding
constructor as outlined above (apart from the constructor,
state<>
offers the same interface as
simple_state<>
). Hence, this must be done whenever an
entry action makes one or more calls to the following functions:
simple_state<>::post_event()
simple_state<>::clear_shallow_history<>()
simple_state<>::clear_deep_history<>()
simple_state<>::outermost_context()
simple_state<>::context<>()
simple_state<>::state_cast<>()
simple_state<>::state_downcast<>()
simple_state<>::state_begin()
simple_state<>::state_end()
In my experience, these functions are needed only rarely in entry actions so this workaround should not uglify user code too much.
Photographers testing beta versions of our digital camera said that they really liked that half-pressing the shutter anytime (even while the camera is being configured) immediately readies the camera for picture-taking. However, most of them found it unintuitive that the camera always goes into the idle mode after releasing the shutter. They would rather see the camera go back into the state it had before half-pressing the shutter. This way they can easily test the influence of a configuration setting by modifying it, half- and then fully-pressing the shutter to take a picture. Finally, releasing the shutter will bring them back to the screen where they have modified the setting. To implement this behavior we'd change the state chart as follows:
As mentioned earlier, the Configuring state contains a fairly complex and deeply nested inner machine. Naturally, we'd like to restore the previous state down to the innermost state(s) in Configuring, that's why we use a deep history pseudo state. The associated code looks as follows:
// not part of the Camera example struct NotShooting : sc::simple_state< NotShooting, Camera, Idle, sc::has_deep_history > { // ... }; // ... struct Shooting : sc::simple_state< Shooting, Camera, Focusing > { typedef sc::transition< EvShutterRelease, sc::deep_history< Idle > > reactions; // ... };
History has two phases: Firstly, when the state containing the history
pseudo state is exited, information about the previously active inner state
hierarchy must be saved. Secondly, when a transition to the history pseudo
state is made later, the saved state hierarchy information must be
retrieved and the appropriate states entered. The former is expressed by
passing either has_shallow_history
,
has_deep_history
or has_full_history
(which
combines shallow and deep history) as the last parameter to the
simple_state
and state
class templates. The
latter is expressed by specifying either
shallow_history<>
or deep_history<>
as a transition destination or, as we'll see in an instant, as an inner
initial state. Because it is possible that a state containing a history
pseudo state has never been entered before a transition to history is made,
both class templates demand a parameter specifying the default state to
enter in such situations.
The redundancy necessary for using history is checked for consistency at
compile time. That is, the state machine wouldn't have compiled had we
forgotten to pass has_deep_history
to the base of
NotShooting
.
Another change request filed by a few beta testers says that they would like to see the camera go back into the state it had before turning it off when they turn it back on. Here's the implementation:
// ... // not part of the Camera example struct NotShooting : sc::simple_state< NotShooting, Camera, mpl::list< sc::deep_history< Idle > >, sc::has_deep_history > { // ... }; // ...
Unfortunately, there is a small inconvenience due to some
template-related implementation details. When the inner initial state is a
class template instantiation we always have to put it into an
mpl::list<>
, although there is only one inner initial
state. Moreover, the current deep history implementation has some limitations.
To implement this statechart you simply specify more than one inner initial state (see the Keyboard example):
struct Active; struct Keyboard : sc::state_machine< Keyboard, Active > {}; struct NumLockOff; struct CapsLockOff; struct ScrollLockOff; struct Active: sc::simple_state< Active, Keyboard, mpl::list< NumLockOff, CapsLockOff, ScrollLockOff > > {};
Active's inner states must declare which orthogonal region they belong to:
struct EvNumLockPressed : sc::event< EvNumLockPressed > {}; struct EvCapsLockPressed : sc::event< EvCapsLockPressed > {}; struct EvScrollLockPressed : sc::event< EvScrollLockPressed > {}; struct NumLockOn : sc::simple_state< NumLockOn, Active::orthogonal< 0 > > { typedef sc::transition< EvNumLockPressed, NumLockOff > reactions; }; struct NumLockOff : sc::simple_state< NumLockOff, Active::orthogonal< 0 > > { typedef sc::transition< EvNumLockPressed, NumLockOn > reactions; }; struct CapsLockOn : sc::simple_state< CapsLockOn, Active::orthogonal< 1 > > { typedef sc::transition< EvCapsLockPressed, CapsLockOff > reactions; }; struct CapsLockOff : sc::simple_state< CapsLockOff, Active::orthogonal< 1 > > { typedef sc::transition< EvCapsLockPressed, CapsLockOn > reactions; }; struct ScrollLockOn : sc::simple_state< ScrollLockOn, Active::orthogonal< 2 > > { typedef sc::transition< EvScrollLockPressed, ScrollLockOff > reactions; }; struct ScrollLockOff : sc::simple_state< ScrollLockOff, Active::orthogonal< 2 > > { typedef sc::transition< EvScrollLockPressed, ScrollLockOn > reactions; };
orthogonal< 0 >
is the default, so
NumLockOn
and NumLockOff
could just as well pass
Active
instead of Active::orthogonal< 0 >
to specify their context. The numbers passed to the orthogonal
member template must correspond to the list position in the outer state.
Moreover, the orthogonal position of the source state of a transition must
correspond to the orthogonal position of the target state. Any violations
of these rules lead to compile time errors. Examples:
// Example 1: does not compile because Active specifies // only 3 orthogonal regions struct WhateverLockOn: sc::simple_state< WhateverLockOn, Active::orthogonal< 3 > > {}; // Example 2: does not compile because Active specifies // that NumLockOff is part of the "0th" orthogonal region struct NumLockOff : sc::simple_state< NumLockOff, Active::orthogonal< 1 > > {}; // Example 3: does not compile because a transition between // different orthogonal regions is not permitted struct CapsLockOn : sc::simple_state< CapsLockOn, Active::orthogonal< 1 > > { typedef sc::transition< EvCapsLockPressed, CapsLockOff > reactions; }; struct CapsLockOff : sc::simple_state< CapsLockOff, Active::orthogonal< 2 > > { typedef sc::transition< EvCapsLockPressed, CapsLockOn > reactions; };
Often reactions in a state machine depend on the active state in one or
more orthogonal regions. This is because orthogonal regions are not
completely orthogonal or a certain reaction in an outer state can only take
place if the inner orthogonal regions are in particular states. For this
purpose, the state_cast<>
function introduced under
Getting state information
out of the machine is also available within states.
As a somewhat far-fetched example, let's assume that our keyboard also accepts
EvRequestShutdown
events, the reception of which makes the
keyboard terminate only if all lock keys are in the off state. We would
then modify the Keyboard state machine as follows:
struct EvRequestShutdown : sc::event< EvRequestShutdown > {}; struct NumLockOff; struct CapsLockOff; struct ScrollLockOff; struct Active: sc::simple_state< Active, Keyboard, mpl::list< NumLockOff, CapsLockOff, ScrollLockOff > > { typedef sc::custom_reaction< EvRequestShutdown > reactions; sc::result react( const EvRequestShutdown & ) { if ( ( state_downcast< const NumLockOff * >() != 0 ) && ( state_downcast< const CapsLockOff * >() != 0 ) && ( state_downcast< const ScrollLockOff * >() != 0 ) ) { return terminate(); } else { return discard_event(); } } };
Passing a pointer type instead of reference type results in 0 pointers
being returned instead of std::bad_cast
being thrown when the
cast fails. Note also the use of state_downcast<>()
instead of state_cast<>()
. Similar to the differences
between boost::polymorphic_downcast<>()
and
dynamic_cast
, state_downcast<>()
is a much
faster variant of state_cast<>()
and can only be used
when the passed type is a most-derived type.
state_cast<>()
should only be used if you want to query
an additional base.
It is often desirable to find out exactly which state(s) a machine
currently resides in. To some extent this is already possible with
state_cast<>()
and state_downcast<>()
but their utility is rather limited because both only return a yes/no
answer to the question "Are you in state X?". It is possible to ask more
sophisticated questions when you pass an additional base class rather than
a state class to state_cast<>()
but this involves more
work (all states need to derive from and implement the additional base), is
slow (under the hood state_cast<>()
uses
dynamic_cast
), forces projects to compile with C++ RTTI turned
on and has a negative impact on state entry/exit speed.
Especially for debugging it would be so much more useful being able to
ask "In which state(s) are you?". For this purpose it is possible to
iterate over all active innermost states with
state_machine<>::state_begin()
and
state_machine<>::state_end()
. Dereferencing the returned
iterator returns a reference to const
state_machine<>::state_base_type
, the common base of all
states. We can thus print the currently active state configuration as
follows (see the Keyboard example for the complete code):
void DisplayStateConfiguration( const Keyboard & kbd ) { char region = 'a'; for ( Keyboard::state_iterator pLeafState = kbd.state_begin(); pLeafState != kbd.state_end(); ++pLeafState ) { std::cout << "Orthogonal region " << region << ": "; // The following use of typeid assumes that // BOOST_STATECHART_USE_NATIVE_RTTI is defined std::cout << typeid( *pLeafState ).name() << "\n"; ++region; } }
If necessary, the outer states can be accessed with
state_machine<>::state_base_type::outer_state_ptr()
,
which returns a pointer to const
state_machine<>::state_base_type
. When called on an outermost
state this function simply returns 0.
To cut down on executable size some applications must be compiled with C++ RTTI turned off. This would render the ability to iterate over all active states pretty much useless if it weren't for the following two functions:
static unspecified_type
simple_state<>::static_type()
unspecified_type
state_machine<>::state_base_type::dynamic_type() const
Both return a value that is comparable via operator==()
and
std::less<>
. This alone would be enough to implement the
DisplayStateConfiguration
function above without the help of
typeid
but it is still somewhat cumbersome as a map must be
used to associate the type information values with the state names.
That's why the following functions are also provided (only available when BOOST_STATECHART_USE_NATIVE_RTTI is not defined):
template< class T >
static void simple_state<>::custom_static_type_ptr( const T *
);
template< class T >
static const T *
simple_state<>::custom_static_type_ptr();
template< class T >
const T * state_machine<>::
state_base_type::custom_dynamic_type_ptr() const;
These allow us to directly associate arbitrary state type information with each state ...
// ... int main() { NumLockOn::custom_static_type_ptr( "NumLockOn" ); NumLockOff::custom_static_type_ptr( "NumLockOff" ); CapsLockOn::custom_static_type_ptr( "CapsLockOn" ); CapsLockOff::custom_static_type_ptr( "CapsLockOff" ); ScrollLockOn::custom_static_type_ptr( "ScrollLockOn" ); ScrollLockOff::custom_static_type_ptr( "ScrollLockOff" ); // ... }
... and rewrite the display function as follows:
void DisplayStateConfiguration( const Keyboard & kbd ) { char region = 'a'; for ( Keyboard::state_iterator pLeafState = kbd.state_begin(); pLeafState != kbd.state_end(); ++pLeafState ) { std::cout << "Orthogonal region " << region << ": "; std::cout << pLeafState->custom_dynamic_type_ptr< char >() << "\n"; ++region; } }
Exceptions can be propagated from all user code except from state
destructors. Out of the box, the state machine framework is configured for
simple exception handling and does not catch any of these exceptions, so
they are immediately propagated to the state machine client. A scope guard
inside the state_machine<>
ensures that all state
objects are destructed before the exception is caught by the client. The
scope guard does not attempt to call any exit
functions (see
Two stage exit below) that states might define
as these could themselves throw other exceptions which would mask the
original exception. Consequently, if a state machine should do something
more sensible when exceptions are thrown, it has to catch them before they
are propagated into the Boost.Statechart framework. This exception handling
scheme is often appropriate but it can lead to considerable code
duplication in state machines where many actions can trigger exceptions
that need to be handled inside the state machine (see Error handling in the Rationale).
That's why exception handling can be customized through the
ExceptionTranslator
parameter of the
state_machine
class template. Since the out-of-the box
behavior is to not translate any exceptions, the default argument
for this parameter is null_exception_translator
. A
state_machine<>
subtype can be configured for advanced
exception handling by specifying the library-supplied
exception_translator<>
instead. This way, the following
happens when an exception is propagated from user code:
exception_thrown
event is
allocated on the stackexception_thrown
event is attempted. That is, possibly
remaining events in the queue are dispatched only after the exception has
been handled successfullyOn platforms with buggy exception handling implementations users would probably want to implement their own model of the ExceptionTranslator concept (see also Discriminating exceptions).
An exception is considered handled successfully, if:
exception_thrown
event
has been found, andThe second condition is important for scenarios 2 and 3 in the next
section. In these scenarios, the state machine is in the middle of a
transition when the exception is handled. The machine would be left in an
invalid state, should the reaction simply discard the event without doing
anything else. exception_translator<>
simply rethrows
the original exception if the exception handling was unsuccessful. Just as
with simple exception handling, in this case a scope guard inside the
state_machine<>
ensures that all state objects are
destructed before the exception is caught by the client.
exception_thrown
event?Short answer: If the state machine is stable when the exception is thrown, the state that caused the exception is first tried for a reaction. Otherwise the outermost unstable state is first tried for a reaction.
Longer answer: There are three scenarios:
react
member function propagates an exception
before calling any of the reaction functions or the action
executed during an in-state reaction propagates an exception. The state
that caused the exception is first tried for a reaction, so the following
machine will transit to Defective after receiving an EvStart event:As with a normal event, the dispatch algorithm will move outward to find
a reaction if the first tried state does not provide one (or if the
reaction explicitly returned forward_event();
). However, in
contrast to normal events, it will give up once it has unsuccessfully tried
an outermost state, so the following machine will not transit to
Defective after receiving an EvNumLockPressed event:
Instead, the machine is terminated and the original exception rethrown.
Because the exception_thrown
event is dispatched from
within the catch block, we can rethrow and catch the exception in a custom
reaction:
struct Defective : sc::simple_state< Defective, Purifier > {}; // Pretend this is a state deeply nested in the Purifier // state machine struct Idle : sc::simple_state< Idle, Purifier > { typedef mpl::list< sc::custom_reaction< EvStart >, sc::custom_reaction< sc::exception_thrown > > reactions; sc::result react( const EvStart & ) { throw std::runtime_error( "" ); } sc::result react( const sc::exception_thrown & ) { try { throw; } catch ( const std::runtime_error & ) { // only std::runtime_errors will lead to a transition // to Defective ... return transit< Defective >(); } catch ( ... ) { // ... all other exceptions are forwarded to our outer // state(s). The state machine is terminated and the // exception rethrown if the outer state(s) can't // handle it either... return forward_event(); } // Alternatively, if we want to terminate the machine // immediately, we can also either rethrow or throw // a different exception. } };
Unfortunately, this idiom (using throw;
inside a
try
block nested inside a catch
block) does not
work on at least one very popular compiler. If you have to use one of
these platforms, you can pass a customized exception translator class to
the state_machine
class template. This will allow you to
generate different events depending on the type of the exception.
If a simple_state<>
or state<>
subtype declares a public member function with the signature void
exit()
then this function is called just before the state object is
destructed. As explained under Error
handling in the Rationale, this is useful for two things that would
otherwise be difficult or cumbersome to achieve with destructors only:
A few points to consider before employing exit()
:
exit()
will be called:
terminate()
beforehand then the currently active states
are destructed without calling exit()
. This is necessary
because an exception that is possibly thrown from exit()
could not be propagated on to the state machine clientexit()
is not called when a previously executed
action propagated an exception and that exception has not (yet) been
handled successfully. This is because a new exception that could
possibly be thrown from exit()
would mask the original
exceptionexit
function
propagated an exception. That is, the state object is inevitably
destructed right after calling exit()
, regardless of whether
exit()
propagated an exception or not. A state machine
configured for advanced exception handling is therefore always unstable
while handling an exception propagated from an exit
functionexit()
are analogous to the ones defined for
exceptions propagated from state constructors. That is, the outermost
unstable state is first tried for a reaction and the dispatcher then
moves outward until an appropriate reaction is foundSubmachines are to event-driven programming what functions are to procedural programming, reusable building blocks implementing often needed functionality. The associated UML notation is not entirely clear to me. It seems to be severely limited (e.g. the same submachine cannot appear in different orthogonal regions) and does not seem to account for obvious stuff like e.g. parameters.
Boost.Statechart is completely unaware of submachines but they can be implemented quite nicely with templates. Here, a submachine is used to improve the copy-paste implementation of the keyboard machine discussed under Orthogonal states:
enum LockType { NUM_LOCK, CAPS_LOCK, SCROLL_LOCK }; template< LockType lockType > struct Off; struct Active : sc::simple_state< Active, Keyboard, mpl::list< Off< NUM_LOCK >, Off< CAPS_LOCK >, Off< SCROLL_LOCK > > > {}; template< LockType lockType > struct EvPressed : sc::event< EvPressed< lockType > > {}; template< LockType lockType > struct On : sc::simple_state< On< lockType >, Active::orthogonal< lockType > > { typedef sc::transition< EvPressed< lockType >, Off< lockType > > reactions; }; template< LockType lockType > struct Off : sc::simple_state< Off< lockType >, Active::orthogonal< lockType > > { typedef sc::transition< EvPressed< lockType >, On< lockType > > reactions; };
As the name suggests, a synchronous state machine processes each event
synchronously. This behavior is implemented by the
state_machine
class template, whose process_event
function only returns after having executed all reactions (including the
ones provoked by internal events that actions might have posted). This
function is strictly non-reentrant (just like all other member functions,
so state_machine<>
is not thread-safe). This makes it
difficult for two state_machine<>
subtype objects to
communicate via events in a bi-directional fashion correctly, even in a
single-threaded program. For example, state machine A
is
in the middle of processing an external event. Inside an action, it decides
to send a new event to state machine B
(by calling
B::process_event()
). It then "waits" for B to send back an
answer via a boost::function<>
-like call-back, which
references A::process_event()
and was passed as a data member
of the event. However, while A
is "waiting" for B
to send back an event, A::process_event()
has not yet returned
from processing the external event and as soon as B
answers
via the call-back, A::process_event()
is unavoidably
reentered. This all really happens in a single thread, that's why "wait" is
in quotes.
The asynchronous_state_machine
class template has none of
the member functions the state_machine
class template has.
Moreover, asynchronous_state_machine<>
subtype objects
cannot even be created or destroyed directly. Instead, all these operations
must be performed through the Scheduler
object each
asynchronous state machine is associated with. All these
Scheduler
member functions only push an appropriate item into
the schedulers' queue and then return immediately. A dedicated thread will
later pop the items out of the queue to have them processed.
Applications will usually first create a
fifo_scheduler<>
object and then call
fifo_scheduler<>::create_processor<>()
and
fifo_scheduler<>::initiate_processor()
to schedule the
creation and initiation of one or more
asynchronous_state_machine<>
subtype objects. Finally,
fifo_scheduler<>::operator()()
is either called directly
to let the machine(s) run in the current thread, or, a
boost::function<>
object referencing
operator()()
is passed to a new boost::thread
.
Alternatively, the latter could also be done right after constructing the
fifo_scheduler<>
object. In the following code, we are
running one state machine in a new boost::thread
and the other
in the main thread (see the PingPong example for the full source code):
struct Waiting; struct Player : sc::asynchronous_state_machine< Player, Waiting > { // ... }; // ... int main() { // Create two schedulers that will wait for new events // when their event queue runs empty sc::fifo_scheduler<> scheduler1( true ); sc::fifo_scheduler<> scheduler2( true ); // Each player is serviced by its own scheduler sc::fifo_scheduler<>::processor_handle player1 = scheduler1.create_processor< Player >( /* ... */ ); scheduler1.initiate_processor( player1 ); sc::fifo_scheduler<>::processor_handle player2 = scheduler2.create_processor< Player >( /* ... */ ); scheduler2.initiate_processor( player2 ); // the initial event that will start the game boost::intrusive_ptr< BallReturned > pInitialBall = new BallReturned(); // ... scheduler2.queue_event( player2, pInitialBall ); // ... // Up until here no state machines exist yet. They // will be created when operator()() is called // Run first scheduler in a new thread boost::thread otherThread( boost::bind( &sc::fifo_scheduler<>::operator(), &scheduler1, 0 ) ); scheduler2(); // Run second scheduler in this thread otherThread.join(); return 0; }
We could just as well use two boost::threads:
int main() { // ... boost::thread thread1( boost::bind( &sc::fifo_scheduler<>::operator(), &scheduler1, 0 ) ); boost::thread thread2( boost::bind( &sc::fifo_scheduler<>::operator(), &scheduler2, 0 ) ); // do something else ... thread1.join(); thread2.join(); return 0; }
Or, run both machines in the same thread:
int main() { sc::fifo_scheduler<> scheduler1( true ); sc::fifo_scheduler<>::processor_handle player1 = scheduler1.create_processor< Player >( /* ... */ ); sc::fifo_scheduler<>::processor_handle player2 = scheduler1.create_processor< Player >( /* ... */ ); // ... scheduler1(); return 0; }
In all the examples above,
fifo_scheduler<>::operator()()
waits on an empty event
queue and will only return after a call to
fifo_scheduler<>::terminate()
. The Player
state machine calls this function on its scheduler object right before
terminating.
Revised 03 December, 2006
Copyright © 2003-2006 Andreas Huber Dönni
Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)


Toggle navigation
Websites
Website-list
Add
Name
Created
Accessed
Bloging APP
1/1/2017
2/2/2017
Address Book App
1/1/2017
2/2/2017
Script Test App
1/1/2017
2/2/2017


The incident happened in Dambridge area Mtshogwe Village under Chief Malisa Silobela last Monday. Police confirmed the death of a 19-year-old teenager when the object which was picked by one of the children while playing, later detonated and left the rest of the family members injured.
“For now, we do not have finer details as to what exactly happened, our officers are still on the ground but I can confirm that there is a suspected case of a grenade that exploded in Silobela area.
“More details will come as investigations continue,” said Midlands police spokesman Inspector Joel Goko.
Kwekwe Civil Protection Unit (CPU) chairperson who is also Acting Kwekwe District Development Co-ordinator Mr Fortune Mpungu also confirmed the incident.
“It is true, we received reports of a grenade that exploded within a homestead killing a 19-year-old student on the spot.
“Three other family members who were injured were rushed to Silobela Hospital while others were rushed to Gweru Provincial Hospital depending on the magnitude of the injuries,” said Mr Mpungu.

“I am told that it was a child who was playing who then brought the explosive home which later exploded causing the unfortunate loss of life. As the CPU we therefore urge villagers to avoid picking up strange things and bringing them home.
“Children should be closely monitored when playing,” he said.
sunday news


{% include og-tags.html %} {% include twitter-card.html %} {% include schema-org.html %} {% include schema-article.html %}


built.io
JavaScript Reference
Classes
Built
ACL
Analytics
Application
Cache
Cloud
Delta
File
Object
Promise
Query
Role
User
Util
Built
Version 1.0.0.
Hierarchy
Built
Static members
Namespace
Built
Contains all Built API classes and functions.
Static members
Static Methods
Defined By
getHeaders
( )
Static
Built
Get the common headers set for built.io rest calls .
Returns
unknown
Headers JSON Object.
init
(
String
appKey,
String
appUid )
Static
Built
Call this method to Initialize Built SDK using your application tokens for built.io You can get your api key and app uid from
https://manage.built.io
website.
Parameters
appKey :
String
Your Built Application API Key.
appUid :
String
Your Built Application UID.
setHeaders
(
String
Key,
String
Value )
Static
Built
Set the common headers for built.io rest calls .
Parameters
Key :
String
like extraHeaders OR JSON object with multiple headers like ({extraHeaders:"hello"}) .
Value :
String
like hello .
setURL
(
String
HostName,
String
Protocol )
:
Built
Static
Built
Set the host server for built.io .
Parameters
HostName :
String
Host for built.io server like api.built.io.
Protocol :
String
Protocol for built.io server connection like https.
Returns
Built
Return Built object, so you can chain this call.


--- layout: default title: Ariato --- media CSS elements/media.css audio element Your browser does not support the audio element. video element Your browser does not support the video tag. embedded content YouTube video (iframe):
CSS elements/media.css
YouTube video (iframe):


Previous: Unspecific Components of a Logical Pathname, Up: Logical Pathname Components
The null string, "", is not a valid value for any component of a logical pathname.


This installation, presented at National Gallery of Modern Art, Mumbai, was a part of the “Nature Embedded” exhibition. The exhibition was inaugurated by Paola Antonelli .
Mid Day reports about the exhibition :
“To develop an understanding one has to look at things from other’s perspectives”. Through the means of this exhibit we tried to recreate an experience for the visitor to see the world from the point of view of a bird, dog and a fish. The view is not just a physical sensation but a perception of the world. In our design, we incorporated the unbiased, natural and permanent physical features of the eye like the shape of the vision cone and color sensitivity. Further, there was an attempt to showcase the world as perceived by a dog travelling down an alley, a fish inside a sea of pollution and a bird flying in the sky. These perceptions were biased human reflections which seem to affect these characters.
The narratives and visuals were precisely designed by experts. I am grateful to have worked with them.
My contribution was largely towards designing the interactions with the game and implementing them using electronics.
The environment was designed similar to a traditional Indian street. We tried to capture the hustle bustle and festivities using audio and visuals.
The physical device made using teak wood. It contains an IMU which computes the suggested gestures and moves the character in the games.
The interaction technique was found after conducting a small internal study. It was similar for all the characters to all quick, easy and intuituve transfer of control by the user at the site.
The environment of the fish showcased a narrative in which a fish explores the area.It finds pollution and garbage while moving along a path. Then a giant whale is seen being captured by hunters which the fish along with other smaller fishes sets free. There was a dreamy treatment given to the visuals.
The bird environment depicts a bird flying back from its quest to gather food to its nest. She sees chimneys, electric lines, fountains and lands from far above.
We received great response and feedback from kids and other audiences. People loved the quality of the visuals and idea of exploring the world through the “animals”.
The project was a part of my work done under Prof. Ravi and Prof. Ajanta at IDC. The super talented team at dsource and ekalpa project made the project possible. They include Vajra, Pranisha, Deep, Shyam, Herold, Ravi, Malay, Swati, Vinaya, RamP (Audio) and other folks whose name I intermittently forgot.
Cheers,
Rohit
Read more48 hours to do something fun and then go to Japan ? Hai(はい)!! :)
Let us make dancing passwords !
It was a funny moment when I and Rishabh decided to participate in this hackathon. Designers in an engineering hackathon. I packed all my electronics in a bag, I got at another hackathon and reported at the venue. It was though to decide what to make.
Boredom struck us hard and we decided to make something that you could use to dance and operate the computer. Dance moves as a password? It was pretty random. Wishful thinking, of sorts.
We started working on a mat kind of a thing that one could place under his/her feet when using a computer. Hopping on it, one could do some moves to login. The mat would double up as a foot controller to operate websites like Youtube to do things like- play/pause, volume +/- and next/prev. We even built a chrome app for that. The whole thing was driven by an Arduino Leonardo acting happily as a USB-Keyboard.
And yeah ! We won the hackathon and got a chance to visit Tokyo :) #TamasHack
Cheers,
Rohit
Read moreThis post describes a commissioned installation on the occasion of Women’s Day. We use the metaphor of “being gentle” to create a series of breath driven interactive sketches.
The client came up with a requirement of quick turn around interactive installation for Women’s day to engage the audience while shopping. We wanted to explore the realm of love and socially undermined role of women in our lives. After some rounds of brainstorming, we decided to work on the idea of a “gentle love”.
We thought of connecting breath to gentleness. What is gentleness in nature? Feathers, Flowers, Bubbles, Vapour, Leaves. They all get aboard the gentle wind and spread their color and happiness wherever they go. Women do the same for us all. We wanted the depiction to be “as-is”. Further, breath based interfaces seem an interesting modality to experiment with.
So, we used several particles systems to make digitally manipulated flowers, flames and bubbles.
Quite simple and effective ; the audiences seem to have liked the idea. :)
Cheers,
Rohit
Read more


Ordinals, Cardinals and Dates
Posing questions and creating sentences
Self Introductions and Greetings, Talking about the Weather
Questions about physical characteristics and your children
Questions About Your Economic Status
Questions about your immigration history
Questions Before the Naturalization Interview
Understanding Commands


| DOSE: |
50 mg |
insufflated |
DPT |
(powder / crystals) |
One night my two friends and I decided to snort 50mg, each, of DPT in my basement. I tried to prep them for what they were in store for, but there really is no way to do that for this drug.
There was immediate effects setting in just 5 minutes after use. We proceeded to watch THE ROAD WARRIOR on my big screen with surround sound. Nearly 10 minutes after use, one of my friends started vomiting pretty heavily.  Our reaction time to this drug was about 5 to 10 minutes with no coming up interval.
When I entered this heavy beginning I saw my basement in a warped vision with some blurred sight. When I stood over my friend, trying to comfort him through the vomiting, I saw scales growing and peeling off his back. This was a little disturbing but I calmed myself knowing that it was just in my head. I then had to help my brother, who was our sober buddy, with the cleaning up of the vomit. I didn't even care about the vomit, it looked like bugs crawling around so I picked them up and threw them away. There was also a constant buzzing, like that of a Chinese gong, but continuously ringing.
My other friend was saying phrases like 'I don't like this' and 'quite frankly'. Both my friends, never having tried DPT before, decided to fight the experience. To better put it, they tried to stay clear-headed.
Those phrases my friend was saying repeated in my head over and over again. At this time it felt like I was going through a cycle repeating itself over and over again, it was very intense almost too intense.
We finally ended up in a bedroom with bunkbeds, in which we all laid down on. The intense part of the 'cycle' was slowing down. At this moment my body felt warm and comfortable. The feelings all over my body were almost erotic. This was strange compared to before, because in the earlier stages I felt cold and chilly.
I decided to turn the lights out in the room, which had no windows. My visuals then started quite quickly. To update the time, this was probably about an hour or so after use, oh yeah, I almost completely lose time perception when on DPT. One hour can feel like 4 or the other way around. Anyway back to the visuals. There was many closed-eye and open-eye imagery. At first I closed my eyes for a very long time. I attempted to fall asleep because I knew that in the morning awaited my mom's question 'Who threw up on the carpet last night?'
Anyway back to the visuals. I closed my eyes and saw purple clouds. I was moving threw them like an airplane and as I was gliding through the clouds I saw random images. I saw a peace sign, a long curved guitar that almost looked like a vase/bong. May I also add that the Chinese gong sound was still ringing. Then my visual switched to a view of the room I was in. The room turned to a garden which grew extremely fast, as if in a science video they show you at school. Every vine, flower, branch, and shrub was growing toward the one ceiling light at the center of the room. I then saw my brother in a green Chinese dress , with his hair gelled into a small mo-hawk, still scrubbing the vomit.
I decided to open my eyes and saw a black room, with purple, green, and dark red/blue shapes moving along the wall. All the colors we neon tone. My brother then flicked the lights one which ended the experience.
It was about three hours later and it was a nice coming down. The room felt warm and sound. This went on for another hour. My friends and I then started talking up a storm about what we had seen and felt. And they eventually went to bed, but I couldn't sleep and caught up on my sleep the next day.
Experience Reports are the writings and opinions of the individual authors who submit them.
Some of the activities described are dangerous and/or illegal and none are recommended by Erowid.


This web app was developed by Owen Falculan. All the information stored in this website were encrypted. Dont you worry.
This site was made to get on practice using Python Flask which is a microframework in building web applications. Feel free to suggest for some improvements.


This animation depends on component inputs and their change detection. Animation input parameters for element opacity and animation duration have a continuous state space, but the animation uses only one "named" discrete state data. The component also accepts a color input, which is not animated.
While opacity changes trigger the animation, duration changes do not trigger the animation. A changed duration will only take effect for the next animation.


| Category: functors | Component type: overview |
Function objects that return bool are an important special case. A Unary Function whose return type is bool is called a Predicate, and a Binary Function whose return type is bool is called a Binary Predicate.
There is an important distinction, but a somewhat subtle one, between function objects and adaptable function objects. [1] In general, a function object has restrictions on the type of its argument. The type restrictions need not be simple, though: operator() may be overloaded, or may be a member template, or both. Similarly, there need be no way for a program to determine what those restrictions are. An adaptable function object, however, does specify what the argument and return types are, and provides nested typedefs so that those types can be named and used in programs. If a type F0 is a model of Adaptable Generator, then it must define F0::result_type. Similarly, if F1 is a model of Adaptable Unary Function then it must define F1::argument_type and F1::result_type, and if F2 is a model of Adaptable Binary Function then it must define F2::first_argument_type, F2::second_argument_type, and F2::result_type. The STL provides base classes unary_function and binary_function to simplify the definition of Adaptable Unary Functions and Adaptable Binary Functions. [2]
Adaptable function objects are important because they can be used by function object adaptors: function objects that transform or manipulate other function objects. The STL provides many different function object adaptors, including unary_negate (which returns the logical complement of the value returned by a particular AdaptablePredicate), and unary_compose and binary_compose, which perform composition of function object.
Finally, the STL includes many different predefined function objects, including arithmetic operations (plus, minus, multiplies, divides, modulus, and negate), comparisons (equal_to, not_equal_to greater, less, greater_equal, and less_equal), and logical operations (logical_and, logical_or, and logical_not). It is possible to perform very sophisticated operations without actually writing a new function object, simply by combining predefined function objects and function object adaptors.
vector<int> V(100); generate(V.begin(), V.end(), rand);
Sort a vector of double by magnitude, i.e. ignoring the elements' signs. In this example, the function object is an object of a user-defined class.
struct less_mag : public binary_function<double, double, bool> { bool operator()(double x, double y) { return fabs(x) < fabs(y); } }; vector<double> V; ... sort(V.begin(), V.end(), less_mag());
Find the sum of elements in a vector. In this example, the function object is of a user-defined class that has local state.
struct adder : public unary_function<double, void> { adder() : sum(0) {} double sum; void operator()(double x) { sum += x; } }; vector<double> V; ... adder result = for_each(V.begin(), V.end(), adder()); [3] cout << "The sum is " << result.sum << endl;
Remove all elements from a list that are greater than 100 and less than 1000.
list<int> L; ... list<int>::iterator new_end = remove_if(L.begin(), L.end(), compose2(logical_and<bool>(), bind2nd(greater<int>(), 100), bind2nd(less<int>(), 1000))); L.erase(new_end, L.end());
[1] The reason for the name "adaptable function object" is that adaptable function objects may be used by function object adaptors.
[2] The unary_function and binary_function bases are similar to the input_iterator, output_iterator, forward_iterator, bidirectional_iterator, and random_access_iterator bases: they are completely empty, and serve only to provide type information.
[3] This is an example of how to use function objects; it is not the recommended way of calculating the sum of elements in a vector. The accumulate algorithm is a better way of calculating a sum.


Popcorn SAMI parser 1.0 Plug-in Demo
Your user agent does not support the HTML5 Video element.
Expected Output
From 0 to 1 seconds, "SAMI 0000 text" is shown in the video.
From 1 to 2 seconds, "SAMI 1000 text" is shown in the video.
From 2 to 3 seconds, "SAMI 2000 text" is shown in the video.
From 3 to 6 seconds, "SAMI 3000 text" is shown in the video.
Subtitle Source


| Package | Description |
|---|---|
| javax.swing.plaf.basic |
Provides user interface objects built according to the
Basic look and feel.
|
| javax.swing.plaf.metal |
Provides user interface objects built according to
the Java look and feel (once codenamed Metal),
which is the default look and feel.
|
| javax.swing.plaf.nimbus |
Provides user interface objects built according to the cross-platform
Nimbus look and feel.
|
| javax.swing.plaf.synth |
Synth is a skinnable look and feel in which all painting is
delegated.
|
| javax.swing.text |
Provides classes and interfaces that deal with editable
and noneditable text components.
|
| Class and Description |
|---|
| BasicBorders.ButtonBorder |
| BasicButtonListener
Button Listener
|
| BasicButtonUI
BasicButton implementation
|
| BasicComboBoxEditor
The default editor for editable combo boxes.
|
| BasicComboBoxRenderer
ComboBox renderer
|
| BasicDirectoryModel
Basic implementation of a file list.
|
| BasicEditorPaneUI
Provides the look and feel for a JEditorPane.
|
| BasicInternalFrameTitlePane
The class that manages a basic title bar
|
| BasicLabelUI
A Windows L&F implementation of LabelUI.
|
| BasicMenuItemUI
BasicMenuItem implementation
|
| BasicMenuUI
A default L&F implementation of MenuUI.
|
| BasicRadioButtonUI
RadioButtonUI implementation for BasicRadioButtonUI
|
| BasicScrollBarUI.ArrowButtonListener
Listener for cursor keys.
|
| BasicScrollBarUI.ModelListener
A listener to listen for model changes.
|
| BasicScrollBarUI.ScrollListener
Listener for scrolling events initiated in the
ScrollPane . |
| BasicScrollBarUI.TrackListener
Track mouse drags.
|
| BasicSeparatorUI
A Basic L&F implementation of SeparatorUI.
|
| BasicSliderUI.ScrollListener
Scroll-event listener.
|
| BasicSliderUI.TrackListener
Track mouse movements.
|
| BasicSplitPaneDivider
Divider used by BasicSplitPaneUI.
|
| BasicSplitPaneDivider.DragController
Handles the events during a dragging session for a
HORIZONTAL_SPLIT oriented split pane.
|
| BasicSplitPaneDivider.MouseHandler
MouseHandler is responsible for converting mouse events
(released, dragged...) into the appropriate DragController
methods.
|
| BasicSplitPaneUI
A Basic L&F implementation of the SplitPaneUI.
|
| BasicSplitPaneUI.BasicHorizontalLayoutManager
LayoutManager for JSplitPanes that have an orientation of
HORIZONTAL_SPLIT.
|
| BasicTextFieldUI
Basis of a look and feel for a JTextField.
|
| BasicTextUI
Basis of a text components look-and-feel.
|
| BasicToggleButtonUI
BasicToggleButton implementation
|
| BasicToolBarUI.DragWindow |
| ComboPopup
The interface which defines the methods required for the implementation of the popup
portion of a combo box.
|
| Class and Description |
|---|
| BasicArrowButton
JButton object that draws a scaled Arrow in one of the cardinal directions.
|
| BasicButtonListener
Button Listener
|
| BasicButtonUI
BasicButton implementation
|
| BasicComboBoxEditor
The default editor for editable combo boxes.
|
| BasicComboBoxUI
Basic UI implementation for JComboBox.
|
| BasicComboBoxUI.ComboBoxLayoutManager
This layout manager handles the 'standard' layout of combo boxes.
|
| BasicComboBoxUI.PropertyChangeHandler
This listener watches for bound properties that have changed in the
combo box.
|
| BasicComboPopup
This is a basic implementation of the
ComboPopup interface. |
| BasicDesktopIconUI
Basic L&F for a minimized window on a desktop.
|
| BasicFileChooserUI
Basic L&F implementation of a FileChooser.
|
| BasicInternalFrameTitlePane
The class that manages a basic title bar
|
| BasicInternalFrameUI
A basic L&F implementation of JInternalFrame.
|
| BasicLabelUI
A Windows L&F implementation of LabelUI.
|
| BasicLookAndFeel
A base class to use in creating a look and feel for Swing.
|
| BasicMenuBarUI
A default L&F implementation of MenuBarUI.
|
| BasicProgressBarUI
A Basic L&F implementation of ProgressBarUI.
|
| BasicRadioButtonUI
RadioButtonUI implementation for BasicRadioButtonUI
|
| BasicRootPaneUI
Basic implementation of RootPaneUI, there is one shared between all
JRootPane instances.
|
| BasicScrollBarUI
Implementation of ScrollBarUI for the Basic Look and Feel
|
| BasicScrollPaneUI
A default L&F implementation of ScrollPaneUI.
|
| BasicSeparatorUI
A Basic L&F implementation of SeparatorUI.
|
| BasicSliderUI
A Basic L&F implementation of SliderUI.
|
| BasicSliderUI.PropertyChangeHandler |
| BasicSplitPaneDivider
Divider used by BasicSplitPaneUI.
|
| BasicSplitPaneUI
A Basic L&F implementation of the SplitPaneUI.
|
| BasicTabbedPaneUI
A Basic L&F implementation of TabbedPaneUI.
|
| BasicTabbedPaneUI.TabbedPaneLayout
This class should be treated as a "protected" inner class.
|
| BasicTextFieldUI
Basis of a look and feel for a JTextField.
|
| BasicTextUI
Basis of a text components look-and-feel.
|
| BasicToggleButtonUI
BasicToggleButton implementation
|
| BasicToolBarUI
A Basic L&F implementation of ToolBarUI.
|
| BasicToolBarUI.DockingListener
This class should be treated as a "protected" inner class.
|
| BasicToolBarUI.PropertyListener |
| BasicToolBarUI.ToolBarContListener |
| BasicToolTipUI
Standard tool tip L&F.
|
| BasicTreeUI
The basic L&F for a hierarchical data structure.
|
| ComboPopup
The interface which defines the methods required for the implementation of the popup
portion of a combo box.
|
| Class and Description |
|---|
| BasicLookAndFeel
A base class to use in creating a look and feel for Swing.
|
| Class and Description |
|---|
| BasicButtonUI
BasicButton implementation
|
| BasicColorChooserUI
Provides the basic look and feel for a JColorChooser.
|
| BasicComboBoxUI
Basic UI implementation for JComboBox.
|
| BasicDesktopIconUI
Basic L&F for a minimized window on a desktop.
|
| BasicDesktopPaneUI
Basic L&F for a desktop.
|
| BasicEditorPaneUI
Provides the look and feel for a JEditorPane.
|
| BasicInternalFrameUI
A basic L&F implementation of JInternalFrame.
|
| BasicLabelUI
A Windows L&F implementation of LabelUI.
|
| BasicListUI
An extensible implementation of
ListUI . |
| BasicLookAndFeel
A base class to use in creating a look and feel for Swing.
|
| BasicMenuBarUI
A default L&F implementation of MenuBarUI.
|
| BasicMenuItemUI
BasicMenuItem implementation
|
| BasicMenuUI
A default L&F implementation of MenuUI.
|
| BasicOptionPaneUI
Provides the basic look and feel for a
JOptionPane . |
| BasicPanelUI
BasicPanel implementation
|
| BasicPopupMenuUI
A Windows L&F implementation of PopupMenuUI.
|
| BasicProgressBarUI
A Basic L&F implementation of ProgressBarUI.
|
| BasicRootPaneUI
Basic implementation of RootPaneUI, there is one shared between all
JRootPane instances.
|
| BasicScrollBarUI
Implementation of ScrollBarUI for the Basic Look and Feel
|
| BasicScrollPaneUI
A default L&F implementation of ScrollPaneUI.
|
| BasicSliderUI
A Basic L&F implementation of SliderUI.
|
| BasicSliderUI.TrackListener
Track mouse movements.
|
| BasicSpinnerUI
The default Spinner UI delegate.
|
| BasicSplitPaneDivider
Divider used by BasicSplitPaneUI.
|
| BasicSplitPaneUI
A Basic L&F implementation of the SplitPaneUI.
|
| BasicTabbedPaneUI
A Basic L&F implementation of TabbedPaneUI.
|
| BasicTableHeaderUI
BasicTableHeaderUI implementation
|
| BasicTableUI
BasicTableUI implementation
|
| BasicTextAreaUI
Provides the look and feel for a plain text editor.
|
| BasicTextFieldUI
Basis of a look and feel for a JTextField.
|
| BasicTextUI
Basis of a text components look-and-feel.
|
| BasicToolBarUI
A Basic L&F implementation of ToolBarUI.
|
| BasicToolTipUI
Standard tool tip L&F.
|
| BasicTreeUI
The basic L&F for a hierarchical data structure.
|
| ComboPopup
The interface which defines the methods required for the implementation of the popup
portion of a combo box.
|
| Class and Description |
|---|
| BasicTextUI
Basis of a text components look-and-feel.
|
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2015, Oracle and/or its affiliates. All rights reserved.


Module ctinstrument
Creator Tools LUA Instrument Utilities File
Author: Native Instruments Written by: Yaron Eshkar
This file includes useful functions for usage in Creator Tools Lua scripts.
Simply include this line in any script (if running a script from another location that users this file, make sure to point to the correct path): local ctInstrument = require("CtInstrument") Then you can simply call any function like: ctInstrument.test_function()
It is also possible of course to copy entire specific functions from this list directly into your script. In that case remove the CtFile part from the function name, and then simply call it normally like: test_function()
Functions
| CtInstrument.test_function () | Test Function. |
| CtInstrument.apply_script (script_or_file, name, slot, bypass, link) | Applies a KSP Script. |
Functions
- CtInstrument.test_function ()
- Test Function. Takes no arguments, prints to console when called.
- CtInstrument.apply_script (script_or_file, name, slot, bypass, link)
-
Applies a KSP Script.
Takes no arguments, prints to console when called.
Parameters:
- script_or_file string KSP script in string form or a path to the script file. If link param is true, must be a path.
- name string set the script name.
- slot int set the script slot, defaults to zero if not set.
- bypass bool when true the script will be applied but set to bypass.
- link bool link to the given path or to apply the script as a string.
Returns:
-
bool


In this first term of SPOC, you have learnt alot of HTML/CSS basics and can make a great deal of websites from it. Listed below are some of those skills.


Contact
Send a mail
<EMAIL_ADDRESS>We are
Africa based worldwide focused
call here
(+234)<PHONE_NUMBER>


the and for dengue that with The ZIKV vaccine was are {background virus DENV []. from Aedes which [], has have infection margin {border-style been px;} #ffffff;} spread were also clinical can arboviral fever not other public years yellow only reported Zika control health urban Phase cases diseases effective global mosquitoes surveillance will could during such Brazil, but epidemic epidemics Brazil DENV- Dengue against age associated diagnostic major most px; should where {font-family developed disease efficacy even first font-size had including observed past risk they â€" â€"Â CYD-TDV Med WHO Wolbachia aegypti after all arbovirus being detect dose double; evidence found increased laboratory pregnant prevention than these those transmission vaccination vaccine, vaccines vector world America Brazilian Duane Health West albopictus areas attenuated between border-color border-width countries developing development diseases. emerged emergence infection, infections into introduced may more mosquito mutation need now prM research safe safety solid; tetravalent there threat three trial trials tropics use viruses {font-style {font-weight Africa Asia Gubler Latin Nile Rio South World YFV Yellow ZIKV, and, anti-DENV appropriate arboviruses, around audience babies blood bold candidates cohort courier; dengue, described disease. em; emerging endemic enhanced example, fever, followed genes individuals infected infectious its less licensed live many microcephaly microcephaly. mosquitoes, neurological new populations prevent program protein pt;} readily recently reminded results reviewed seen seropositive serotypes severe some study tests that, their this tools transmitted used viral well year â€",


Change Language Options
Change the translation language mannually programmatically or through URL by adding language code in URL.
English French


Social Rebirth. But . . .
First, a summary: great time, minor psychedelia, MDMA-like effects (or so I assume, never having tried MDMA), tremendous social-skills improvement. However, it's 85 hours after injestion as I write this and I still don't feel like I've really come down. Which (apart from my good mood, and frustration at being unable to concentrate properly or relax -- I've slept 8 hours in the past four days and my eyes are glassy) is concerning.
I got home from work (making pitas for college kids) around 3 a.m. My housemate (henceforth P) and his girlfriend, it was revealed, had taken 2CI about an hour before. I was tired, bored, and in the mood to get impulsively fucked up on something, and dimly aware that that wasn't the best state to be in when using psychadelics; nevertheless, I decided to take some myself.
P opened a 20 mg capsule and divided the powder into 2 fairly-equal piles (on top of Neal Stephenson's
Quicksilver, which seemed appropriate); one, he poured into a water-filled teacup for me. I joked that I'd drink it when the zen nature of the situation impelled me to, but the zen nature was taking its time (stupid zen nature. hmph.); I smoked a cigarette to cut through the nervousness and went to the living room, where I felt more comfortable, and drank it.
Within 40 minutes I felt a smoth wave of . . . something. I was more alert and conversation was eaiser; a bit like the low (15 mcg?) doses of LSD I've tried only calmer and clearer (and feeling less like my mind was being pushed in a random direction). I talked with another friend of mine about his old trips ('so I was popping mushrooms all morning, just to get through work. . .') and intellectual things I can't remember. I do remember badly wanting physical human contact, and seriously contemplating asking him for a platonic hug before deciding that was absurd.
By 4:45 P and his girlfriend were shagging and we decided to visit some other friends downtown; we stopped at a tiny diner on the way there. Conversation was great; I was much less inhibited than usual ('damn you!' in a british accent out to car window to the closed pizza place we'd been heading for) and more empathetic and inclined to say things. By the end of my hot dog I had borrowed a pen from the waitress and was excitedly explaining the difficulty of distinguishing between a generalized tautology and a proper ontology, using the ketchup and mustard dispensers as props.  How's it going?')
Most of the way downtown, I got out of the minivan to walk the last 5 minutes through the empty pre-dawn streets. The sky was amazingly dark-bright blue and the white blossoms on the trees were beautiful.
My downtown friend's housemate, D, is (like most of the people mentioned thus far) a friend from middle school; but we'd drifted apart. Backstory: at age 14 I was a fairly well-adjusted kid. By a couple years later, through some quirk of neurochemestry or psychology, I was a panic-striken suicidal mess, failing my classes, unable to interact with anyone on even a fairly basic level, and convinced against all available evidence that my respiratory system wasn't working properly. I managed for the most part to keep my problems from anyone else, and didn't get much help at the time. I've been recovering (therapy, yeah) for the past several years and living a fairly normal life for the past couple.
D, from painful personal experience, is hypersensitive to personality changes, drug-induced or otherwise. By the time I got there I was (in retrospect) peaking, and had to fight off the urge to hug him, or tell him what a cool guy I thought he was and how I wished we could have stayed better friends, or something; I made normal (if much-more-excited-than-usual) conversation and actually connected with him; we joked about his cell-phone's corny sounds and other epherema and I wondered vaguely about what he was thinking about and his self-image. Mostly-normal social interaction, the kind of thing I hadn't done (with anyone) for a really, really long time, since 1997 or so. I could look at people directly when I talked to them and genuinely felt all the inflections I gave my speech; I realized I'd been mostly faking it for I don't know how long.
We left; it was around 7:30. I got dropped off at home 20 min later and was by myself (P otherwise engaged, still). I really needed someone to hang out with, so I looked for the housecat. What I wrote the next day:
I was expecting this to be another depressed ending. 'I just wanted to pet the cat, damnit, and it ran away from me,' and insert several paragraphs exposition above about housemate's traumatized ex-shelter cat and its crashing into walls running away from me. But I did manage to pet, in fact, the cat. Fatty. I still can't help thinking of him as 'the cat'.
After making friends with Fatty, feeling great, I sat in the living room and wrote this:
No cool patterns but things are warm -- colors a lot richer. My hand [arrow to the side of the page, pointing at it] The kind of splendid oil-paint excess of of a 18th century sea painting. Golden, fading to blue with the shadow from the lamp, a scarlet sunrise.
I noticed how nice the letters looked on the page -- cleanlined, more than usual, and wrote this:
Is this what's going to happen? Have an experience that can be written about and then not be motivated to write anything meaningful? 'Yeah, empathogen. Connected, there.' Is this the ultimate dichotomy: pretty, intellectually empty empathy/page design vs. ugly, tortured philosophical insight?
I messed around for a couple more hours (tried mastrubating, which was only fractionally more enjoyable than usual and significantly more difficult), then spent most of the afternoon and evening in bed, trying unsuccessfully to sleep, finding shapes in the patterned wall-plaster. At 2 a.m. I was supposed to start driving with some friends (aforementioned and otherwise) to a pro-choice rally in Washington, D.C. (10 hours each way) but in no condition to do so; I wasn't as hyperkinetic as before but still, to be blunt, fucked up. D and another kid alternated driving my car while I kept trying to sleep; at this point I'd been awake 36 hours. I managed to get 2 hours or so through southern pennsylvania and woke up to the kind of blank, slightly fuzzy feeling that apparently often follows MDMA nights -- but I was still smiling from the sheer 'wow I feel good' every time I closed my eyes and conversing easily.
 It's striking how I never realized it was gone until it came back these past couple few days. Sitting in a room with a friend is almost like having two sets of eyes. Reading and watching movies are infinitely better -- empathy is necessary to feel like you're there, to get into the story and not just be sitting in your living room, looking at moving colors on a screen.)
The rally was fun. T, D, and I successfully pursuaded the others not to smoke marijuana in the national mall (
the fuck??) and I got 6 or 7 hours of sleep in the hotel that night. In the morning I still wasn't back to normal, but rested enough to drive.
I was also more and more worried, contemplating the possibility that I was a genetic freak who lacked the enzymes to break down 2CI and wondering what its continued presence, and accompanying serotinin (?), would do to me. 70 hours is the equivalent of 10 MDMA doses; would I have dementia within a week, consigned to e-tardation?
When I got home (newly rebonded, to some extent, with D) I called P in as much of a panic as my neurochemestry would allow and asked for the number of his brother, biochemestry graduate student and general pyschadelic guru, who reassured me: it was a small possibility, he conceded (and this is heavily paraphrased, so any scientific mistakes are likely mine), that I couldn't break down the 2CI, but more likely, it had triggered a neurochemical cascade that was self-perpetuating even after the initial trigger was gone -- I had more neurotransmitters (active ones, at least) and was 'operating at a higher level' (I took that part with a grain of salt). As long as I felt fine, he said, things were probably alright. But 'it's temporary -- everything's temporary.'
I told him I felt great, if a bit spaced out, and headed to a co-op I'd lived in during the summer, where, freer of the fear that what I was feeling was slowly damaging me, I had more conversation in 2 hours than in my entire couple months living there. I played the piano there as well (I usually do) but this time it was great -- I was able to connect with the emotions the chords and notes carried much more than usual and made, consequentially, much, much better music. Then I came back and finished writing this.
I don't know what's going to happen. If I'm permanently injured, or permanently helped, I'll submit an update. These are extremely powerful, relatively untested chemicals, not to be trifled with. For better or worse, temporarily or permanently, they alter the mechanics of your brain, your
self. It'll be amazing if this helps me, but suck tremendously if it does the opposite. Thanks for your time.
Experience Reports are the writings and opinions of the individual authors who submit them.
Some of the activities described are dangerous and/or illegal and none are recommended by Erowid.


Setting up Rails application with Unicorn and NGINX in Ubuntu, Ruby, Rails,NGINX
Difficulty: 2
Time: 30 minutes
In this article, we will be configuring a multi-layer deployment installation to host Rails-based Ruby web applications. To do this, we will use the powerful, flexible, and extremely successful Unicorn application server running behind NGINX.
We assume that you are logged in as a sudo
user.
We assume that you have gone through the articles: Install Ruby on Rails with rbenv - Ubuntu and Use PostgreSQL with your Ruby on Rails Application - Ubuntu.
host: localhost
production
section at the bottom of the file.
username: HelloWorld password: <%= ENV[HelloWorld_DATABASE_PASSWORD'] %>
If our production username and the database user are not the same, then make the required changes to make them the same.
Bundle install
, then type:
gem install pg
, then type:
SECRET_KEY_BASE=your_generated_secret HelloWorld_DATABASE_PASSWORD=prod_db_pass
To terminate a user, press Control/CTRL+C.
unicorn.rb
document.
# set path to application app_dir = File.expand_path("../..", __FILE__) shared_dir = "#{Application directory}/shared" working_directory Application directory # Set unicorn options worker_processes 2 preload_app true timeout 30 # Set up socket location listen "#{shared_dir}/sockets/unicorn.sock", :backlog => 64 # Logging stderr_path "#{shared_dir}/log/unicorn.stderr.log" stdout_path "#{shared_dir}/log/unicorn.stdout.log" # Set master PID location pid "#{shared_dir}/pids/unicorn.pid"
#!/bin/sh ### BEGIN INIT INFO # Provides: unicorn # Required-Start: $all # Required-Stop: $all # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts the unicorn app server # Description: starts unicorn using start-stop-daemon ### END INIT INFO set -e USAGE="Usage: $0 <start|stop|restart|upgrade|rotate|force- stop>" # app settings USER="HelloWorld" APP_NAME="HelloWorld" APP_ROOT="/home/$USER/$APP_NAME" ENV="production" # environment settings PATH="/home/$USER/.rbenv/shims:/home/$USER/.rbenv/bin:$PATH" CMD="cd $APP_ROOT && bundle exec unicorn -c config/unicorn.rb - E $ENV -D" PID="$APP_ROOT/shared/pids/unicorn.pid" OLD_PID="$PID.oldbin" # make sure the app exists cd $APP_ROOT || exit 1 sig () { test -s "$PID" && kill -$1 `cat $PID` } oldsig () { test -s $OLD_PID && kill -$1 `cat $OLD_PID` } case $1 in start) sig 0 && echo >&2 "Already running" && exit 0 echo "Starting $APP_NAME" su - $USER -c "$CMD" ;; stop) echo "Stopping $APP_NAME" sig QUIT && exit 0 echo >&2 "Not running" ;; force-stop) echo "Force stopping $APP_NAME" sig TERM && exit 0 echo >&2 "Not running" ;; restart|reload|upgrade) sig USR2 && echo "reloaded $APP_NAME" && exit 0 echo >&2 "Couldn't reload, starting '$CMD' instead" $CMD ;; rotate) sig USR1 && echo rotated logs OK && exit 0 echo >&2 "Couldn't rotate logs" && exit 1 ;; *) echo >&2 $USAGE exit 1 ;; esac
This script will allow to run unicorn_HelloWorld that will run and stop both the unicorn and Rails application.
default.conf
and leave nginx.conf
.
Replace the files contents with the following lines:
upstream app { # Path to Unicorn SOCK file, as defined previously server unix:/home/UserName/HelloWorld/shared/sockets/unicorn.sock fail_timeout=0; } server { listen 80; server_name localhost; root /home/UserName/HelloWorld/public; try_files $uri/index.html $uri @app; location @app { proxy_pass http://app; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; } error_page 500 502 503 504 /500.html; client_max_body_size 4G; keepalive_timeout 10; }
By using all the above steps, you will be able to deploy our Rails application with Unicorn and NGINX on Ubuntu.


{% extends 'layout.html' %} {% load fr_display %} {% block content %} {% include 'snippets/covers_shelf.html' with shelves=shelves user=request.user %}
Previous
Next


| About Dailyrotten |
|
Feedback
If you like this page, hate it, or would like to suggest changes,
<EMAIL_ADDRESS>is listening. This page
is experimental and somewhat different from what we usually offer, so please
do send your feedback.
Adding Stories
If you are a rotten newshound and you would like to suggest a story,
visit our submit page to
send us the URL. Stories that are accepted will have your name credited.
Viewership
On the first full day this page went live, 100,000 people visited this Rotten
News page. Of course that was the day after the WTC attacks, so that number is
somewhat distorted. Right now this page gets between 50,000 and 75,000 people
every day.
Linking
We encourage everyone to link to this page; if you like it, others probably
will as well.

MSNBC | Submitted by: MissCandi
"Oppenheim came back with the blue shirt design, a concept that left some residents and officials decidedly unimpressed and troubled that the work insults Milwaukee's blue collar history... Walker doesn't want the sculpture anywhere near Milwaukee County public land. He believes it will overwhelm the parking garage and clash with the rest of the airport's design."  A big one, apparently, though there are no pictures yet. His handlers sound pretty fed up, they reckon he's off his meds again: "The tat is being described as an "African tribal scroll" shaped like the numeral 3, extending from above the eyebrow to the jaw line."
|
|
Read article...
|
|
Police seek Eminem lookalike in NJ bank robberies
Entertainment Tonight | Submitted by: Tank's Grrl
"The FBI and the New Jersey state police are asking the public for help in finding an Eminem look-alike who has robbed 10 banks in the state since October 2002... "He's the most prolific in the shortest amount of time we've had in recent memory," FBI Special Agent Stephen Siegel told the Bergen County, New Jersey Record."
|
|
Read article...
|
|
It's a fish-eat-fish world
CNN | Submitted by: D.Rango
Another reason to grill a juicy steak tonight: "Fish farms are a mounting threat to depleted world stocks because more and more wild fish are being fed to their caged cousins, the WWF conservation group said... Without reform, it said the fast-growing industry could be consuming all the world's fish oil and half of its fishmeal by 2010... Four kilos of wild caught fish are needed to produce one kilo of farmed fish."
|
|
Read article...
|
|
Wild pigs threaten Somali peace talks
BBC | Submitted by: jo666py
"Warlord Mawlid Maane is extremely unhappy at the change of venue... threatening to go home. He was charged last month for assaulting a professor at the talks but he denied that other delegates would be pleased to see him go. "I am an important person... My fellow Somalis will miss me if I go." Somalis are supposed to be badasses, but all this smacks of whimpering.
|
|
Read article...
|
|
Thai Elephants to be fitted with microchips
e-insite | Submitted by: anonymous
"The Thai Agriculture Ministry will spend 2.5 million baht putting microchips in another 700 domesticated elephants to monitor and control their movement.
Deputy Agriculture Minister Newin Chidchob said yesterday it was part of a systematic plan to solve the elephant problem, especially those that roam the streets with their handlers in large cities."
|
|
Read article...
|
|
UK facists get makeover
Searchlight | Submitted by: Tobermory
"But as the BNP reinvents itself, its danger will also grow. Right-wing extremism is not what it once was. Where it was once a tribal subculture, now it is slick and understated. While there is nothing subtle about Griffin's thesis that Jews control the media, there is something almost bland about his bluster. Griffin sees his appeal as being rooted in intelligence and charisma. But he is also decidedly banal. As Adorno... succinctly put it, 'Hitler posed as a composite of King Kong and the suburban barber'. A far-right leader needs charisma, but he must also appear to be like an ordinary follower. It is in this ordinariness that danger lies."
|
|
Read article...
|
|
Peter, Peter, Pumpkin Puker
News Corporation | Submitted by: Dirty Sammy
"Ben Boyton started growing pumpkins about a year ago "as a bit of a hobby", but it soon turned into an obsession that has taken over the back yard of his western Sydney home... The Bligh Park landscaper has spent $5000 on manure and gardening equipment over the past four months growing his latest, and biggest, pumpkin."
|
|
Read article...
|
|
Marine wins Darwin Award
Savannah Morning News | Submitted by: Egg
"A Beaufort Marine died early Monday after deciding to lay down in the middle of a highway to snooze after leaving a party. "They had a really long walk ahead of them," said Beaufort County Coroner Curt Copeland. "He, for whatever reason, just lay down in the middle of the road. She yelled at him to get up and about that time a car came along and hit him." All those government dollars gone to waste, shame.
|
|
Read article...
|
|
Students bring pot brownies to class
Wire Services | Submitted by: anonymous
"Five students at an El Dorado County High School are in trouble after school officials say they brought pot-laced brownies to school to share with their classmates. The students' homework assignment in health class at Oak Ridge High School last Friday was to bring in a healthy snack. Instead, they allegedly brought in a dessert made with marijuana."
|
|
Read article...
|
|
She told us it was a lovely day... then SPLAT
ic North Wales | Submitted by: Taco Vender
"I thanked her for moving and she replied, 'It's a lovely day, isn't it?'. Then she moved for us again when we came back at about 11.30am... "She seemed fine, like she was waiting for someone, enjoying her day and the view. But a few minutes later the train came out of Deganwy and hit her." Suicide.
|
|
Read article...
|
|
No dibs on cleared parking spaces
ABC TV affiliates | Submitted by: Razor
A cracked barstool. An armless armchair. A beat-up storage trunk emblazoned with a sticker that read "Deathwish"... Those were the items seen occupying city parking spots recently as residents tried to hold on to the spots they'd shoveled out, a reservation, of sorts, that can raise tempers." One man was killed over such a parking space.
|
|
Read article...
|
|
Cologne quarantine
ABC TV affiliates | Submitted by: Razor
"A Saudi Arabian traveler sparked a scare at Philadelphia International Airport on Wednesday when he innocently sprayed three guards with cologne while trying to demonstrate that the liquid wasn't dangerous... Hospital officials, unsure whether they had a biological attack on their hands, ordered a full quarantine."
|
|
Read article...
|
|
Teacher chased by fake alien sues
CNN | Submitted by: Rockpile
Kara Blanc thought she was being chased by a space alien on her way to a posh Hollywood party and was terrified. But the alien turned out to be an actor in a monster suit and the party was phony as well... So now the Los Angeles grade school teacher and aspiring actress is fighting back, suing the new reality TV series Scare Tactics, claiming she suffered severe emotional damage." Umm, she's a teacher, shouldn't she have known there are no aliens? If the suit is succesful, perhaps a revokation of credentials is in order.
|
|
Read article...
|
|
Foot fondler nabbed
Baton Rouge Advocate | Submitted by: joelvis
"New Iberia police believe they've caught the serial foot-feeler who's been haunting women in the aisles of area retail stores. Monday, one victim fingered 27 year old Christopher Briley in a lineup as the man who approached her, asked about her shoes, then started massaging her feet, Sgt. Chad Hazelwood said."
|
|
Read article...
|
|
Bird puts up heroic fight, then used as evidence
Wire Services | Submitted by: Poots Brownhole
"According to evidence presented in court, Torres and another suspect, who has yet to stand trial, broke into Butler's home. During a struggle in Butler's living room, the white-crested cockatoo named Bird after basketball great Larry Bird, swooped down on the attackers, clawed at their skin and pecked at their heads, said prosecutor George West."
|
|
Read article...
|
|
Fat and Stupid not just an expression
BBC | Submitted by: Rev. Soror Lucy Cannon
A recent study (of rats, so make of it what you will) show a correlation between consuming more calories than needed and accelerated brain cell death. Researchers are hoping this could lead to dietary recommendations for humans that would not only reduce cardiovascular disease, but Alzheimer's and Parkinson's. With obesity on the rise in the general US population as well as other countries, one has to wonder whether the percentage of idiots will rise with it.
|
|
Read article...
|
|
Hare-brained solution to global warming?
CNN | Submitted by: Mikya
"Researchers at a government funded science organization are investigating the possibility of burying up to 1 million metric tons of carbon dioxide to help solve the problem of greenhouse gas emissions." Never mind that CO2 is a gas nor the logistical problems of transportation and securing the gas to bury.
|
|
Read article...
|
|
Lesbian monkeys vs. Darwin
London Telegraph | Submitted by: Crazy Quagga
"In some populations, female Japanese macaques sometimes prefer same-sex partners," he told the American Association for the Advancement of Science in Denver. "That occurs even when they are presented with sexually motivated, opposite-sex alternatives." You go (monkey) girls!
|
|
Read article...
|
|
|
|
|


| HYTOOL Function Reference |
Calculates the input vector for grf
grf_pre( r, rw) r = distance between the observation well and the pumping well rw = radius of the pumping well
grf stands for Barker (1988) solution for a general radial flow pumping test. The function grf_pre must be used to initialize the pumping rate history before making any call to grf_dim or grf_rpt.
grf_dmo, grf_dim, grf_rpt, grf_gss Published output in the Help browser showdemo grf_pre
| Hytool |
© 1998-2017 Philppe Renard and Co. Terms of Use Acknowledgments


Which of these do you think is @KomodoPlatform's Crown Jewel? Do you think its atomic swap powered DEX/dICOs? Federated multichain MoMoM scaling? dPoW securing scaling chains & 3rd party coins? or Zk-snarks & 5.1% rewards? or comment what you think it is below.
#kmd #btc ...


ship to
$15
+
?
=
What You Pay
Purchase With Credit Card
Enter the number 'X' that you want printed on your shirt
and we will send you the shirt for 15 + 'X' dollars
processing...
thankyou
click here to start a new order


This demo of the Twilio Verify API shows how to set up two-factor authentication (2FA) with a third-party authenticator app like Authy or Google Authenticator using the time-based one-time password (TOTP) standard.
Or enter this code into your authentication app:
Create a New Factor | What's happening here:
The API is
creating a new TOTP
Factor
when you click "Set up two-factor authentication". This is how the
Verify API connects a user (
identity
), the
TOTP channel, and your app. Each Factor returns the secret seed and URI used
to create a QR code.
For this demo, we're asking for a username that will be displayed in the account name for the authenticator app.
Verify a Factor | What's happening here:
Before you can use this channel for ongoing authentication, the user must verify the Factor to ensure that setup was successful.
After sharing the seed via a QR code or secret key, this authentication channel is available offline.
Note: unverified Factors will be deleted between 1 and 24 hours after being created.
Ongoing Authentication | What's happening here:
After the Factor has been verified you can collect a token from the user at any time for ongoing authentication. On the backend, this will create a challenge with the token provided.


In Real Time.
Light is fast. It travels 229,792 km (or 299,792,458 m) every second, or 186,282 miles per second. But space is also large. Our own galaxy would take 200,000 years to cross at the speed of light. Once a photon leaves the Sun, on average it will take more than 4 hours to cross the orbit of Nepture. Click the button below to run a simulated journey of a beam of light as it leaves the Sun and crosses the Solar System.


Contents Design
Media Design
3D Design
Liberal Arts
Visual Design
UIUX Design
Web Republishing
Project Studio