{% extends "layout_unbranded.html" %} {% block pageTitle %} Data cleared - GOV.UK Prototype Kit {% endblock %} {% block content %}
The session data has been cleared.
Start another check in with the latest version (default) | Green buttons | White buttons
{% endblock %}


We are a group of students from Imperial College London and our aim is to
help the visually impaired explore new areas without the need of a guide.
Our solution is the Magic Map. Magic Map combines tactile and audio
feedback to allow the user to get a better understanding of any area without
the need of sight. We believe that Magic Map is user friendly, affordable and transportable.
STEP 1
STEP 2
STEP 3
STEP 4
STEP 5


You cal telnet to a server and do basic functions TODO expand
Alternative, pass data through USER / PASS variables
Scenario:
Victim has data CC/SSN/PII
Hacker has telnet server/nc listen
Victim: telnet hacker IP PORT
user: user1
pass: SSN-NU-MBER
Hacker now has a log of usernames and SSNs or any other data


HGVS documentation has moved permanently to
http://hgvs.readthedocs.org/
Hang tight... you will be forwarded automatically.


Release Notes
Because there are two versions of Stellarmap, one for general Dead Souls use and one with Stellarmass-specific features,
some updates may apply only to one or the other. In such cases the symbols <DS> and <SM> will be used to signify
which appropriately.
Back to Dowload Page
June 1, 2010
- Mappings can now take arrays as a key. Finally, QCS-generated rooms can be imported without editing!
- Mappings and arrays now perform some extra formatting checks to ensure any trailing commas are removed (the parser will choke on it). Unfortunately this means code that was nicely formatted by people or QCS will become somewhat mangled after being imported and saved in Stellarmap.
- Fixed a bug that would not allow you to move rooms down and to the right when the viewport was scrolled too far above and to the left of the origin.
- Probably a few other things over the last couple months that I can't remember now.
March 20, 2010
- Changed the room properties box so that it uses a list defined in the configuration file
- Added 'login' property for rooms
- <SM> Added 'hospital' property for rooms
- Added function controls for SetTerrainType() and SetMedium() for rooms
- Function controls now have the ability to specify an additional header file they might require to be included.
- Fixed a bug that was causing data to not save correctly
- Fixed a bug with imported rooms clearing their data after selecting a different room (at least, I think I fixed it... that is to say.. it just went away magically after a couple weeks of not doing anything on this project)
- Fixed another bug that would cause a crash if a room were removed from the project (deleted) and then re-imported back in without first saveing and reloading the workspace.
- Fixed item generators so that they properly output their data. Whoops.
February 20, 2010
- Integrated a spell checker into the basic text editor. Also added the standard cut/copy/paste context menu items.
- text editor is now (approximately) 80 characters wide (getting it spot on is tougher than I thought it would be though)
- fixed npc inventory crasher due to bad parameter type
- fixed bad output for vendor storage room due to bad parameter type
- external domains can now have their inventory and room names imported into a workspace. Just place the master .XML file in the /assets/domainreferences folder and they will show up on the import list
- many internal refactorings of code will hopefully make life easier down the road
- added access to text editor to all textbox-related function controls
- Npcs can now be given points for other languages
- <SM> Added flag to signal if an NPC should drop its inventory on death or just destroy it
- <SM> Added a map of item drops rates on npc death
- <SM> Added spacesuit option for armor
- Ok, npc inventories work for real this time
- Added one more encoding choice. A non-signature version of UTF8. Mostly for backwards compatibility. It has been set as the default encoding
- fixed a crasher when canceling openning a domain for the first time
- fixed a bug that was causing enters to be mapped to exits
- fixed a bug that could cause a crash when assigning exits or enters to rooms just after loading a domain but before selecting any rooms that did not previously have exits or enters
- fixed a bug where if a room had multiple exits going to the same desination all exits would be removed if any one was removed
- changed item/armor generators' calls from 'SetValue()' to 'SetBaseCost()'
- Added cost generators (however, prices are based on Stellarmass)
- Renaming rooms is difficult and error prone so I took the lazy way out. There are now two ways to create a room. The old way (quick) where a name is assigned and the new way (slow) where you have to fill in a textbox with the new name
- Added the ability to import items into the workspace. You can now reference them in the inventories lists
- Added meals to the generator
- Redesigned the config file to allow arbitrary lists to be added. This allows users to define their own custom lists within the config file that can then be accessed by the dynamic item generators. I've also appended many default lists from Dead Souls that weren't available before including: build types, bodytypes, mouth types, vision, resperation types, size types, meal types, mediums, terrain types, motion, and booby traps. See the config file for examples of how to add new types using the <list> tag
- Added support for multi-parameter dynamic function controls. See inheriteditems.xml and the entry for meals for an example
February 2, 2010
- Fixed a couple more show stoppers that appeared in the last release due to a bad config file for Sentient NPCs. Be sure to delete any old version of the file inheritednpcs.xml so that the new executable can create a new version without the errors in it.
- Made the font bigger in the text editor windows for strings. I must be gettin' old
January 30, 2010
- The location of the last project you opened or created is now saved in the config file
- The currently selected room's name is now displayed above the Domain Map View rather than on the room edior panel
- Door generator now creates an array of Ids rather than a single string. It also tries to create default ids for most common doors
- Npcs' inventory lists now works
- Added Sentient Npcs (LIB_SENTIENT), Vendors, Barkeeps to the NPC generator
- Added support for text file encoding/decoding choice (found in Domain Options in the menu)
- Added support for line ending choice (found in Domain Options in the menu)
- Removed some of the features that were relevant only to our mud (firearms and ammo generators)
- There are now two disinct binaries generated. One with Stellarmass-only features and one for general Dead Souls users
- <SM> Added 'mechs allowed' property to rooms
- <DS> Removed the native Windows API call to MessageBeep(). Hopefully this will make Stellarmap more Mono compatible
- Found and fixed a couple show stoppers in the function controls used for processing mappings.


When scaling user management using an external user management system is preferable to managing directly via Puppet.
user { 'bob': password => 'changeme', }


Provides implementations of
SnacCommand
s and associated command factories for SNAC family
0x08
, which gives the AIM server a means of popping up an arbitrarily sized dialog containing arbitrary text on a user's screen.


ACTION & SHOOTING
RACING
ARCADE
BATTLE ROYALE
FANTASY
HORROR
PUZZLES & CLASSICS
THE RIGHT BYTE!
Dying Light
A 2015 survival horror
video game developed by
Techland.
Trailer
₹1499
Add to Cart!
Outlast
A first-person survival horror
video game developed by
Red Barrels.
Trailer
₹1999
Add to Cart!
Five Nights at Freddy's 3
An indie survival horror
video game developed by
Scott Cawthon.
Trailer
₹399
Add to Cart!
Amnesia:The Dark Descent
A 2010 survival horror
adventure video game by
Frictional Games.
Trailer
₹789
Add to Cart!
The Walking Dead
An episodic adventure video
game developed by
Telltale Games.
Trailer
₹2199
Add to Cart!
Resident Evil:Village
A survival horror game
developed and published by
Capcom.
Trailer
₹3799
Add to Cart!


"""
All kinds of nodes in the graphical architecture
"""
from abc import ABC, abstractmethod
from collections.abc import Iterable
import torch
from ..defs import VariableMetatype, Variable, MessageType, Message
from ..utils import compatible_shape
"""
Basic data structures and abstract node classes
- LinkData
- Node
- FactorNode
- VariableNode
"""
[docs]class LinkData:
"""Identifies the data of a directed link between a factor node and a variable node. Stores intermediate messages in
its message memory.
Note that links are directional, and two of such links should be specified with opposite directions to represent
a bidirectional link between a factor node and a variable node.
During construction of the graph, its instance should be passed to NetworkX methods as the edge data to instantiate
an edge.
Parameters
----------
vn : VariableNode
VariableNode instance that this link is incident to.
fn : FactorNode
FactorNode instance that this link is incident to.
to_fn : bool
True if this link is pointing toward the factor node.
msg_shape : tuple of torch.Size
The shape of the message to carry. Used for sanity check of message shapes. Should be in the format
``(batch_shape, param_shape, sample_shape, event_shape)``. An empty shape ``torch.Size([])`` should be used as
the default none shape.
epsilon : float, optional
Epsilon upper bound for checking message difference.
Attributes
----------
memory : Message or None
The message memory buffer.
new : bool
Indicates if this link-data has received a new message in the current decision phase.
vn : VariableNode
The incident variable node.
fn : FactorNode
The incident factor node.
msg_shape : tuple of torch.Size
The allowable message shape, in the format ``(batch_shape, param_shape, sample_shape, event_shape)``.
to_fn : bool
Indicates if this link-data is pointing towards a factor node.
epsilon : float
Epsilon upper bound for checking message difference.
attr : dict
Additional special attributes specified via `kwargs` in the constructor.
pretty_log : dict
Pretty logging for front-end visualization.
"""
def __init__(self, vn, fn, to_fn, msg_shape, epsilon=10e-5, **kwargs):
"""
:param vn: VariableNode instance that this link is incident to
:param fn: FactorNode instance that this link is incident to
:param to_fn: True/False indicating whether this link is pointing toward a factor node
:param msg_shape Fixed message shape that this linkdata will carry. Used for checking dimensions
For Parameter message, should be (batch_shape + param_shape)
For particles message, should be (sample_shape + batch_shape + event_shape)
:param epsilon: epsilon upper bound for checking message difference using KL divergence
"""
assert isinstance(vn, VariableNode)
assert isinstance(fn, FactorNode)
assert isinstance(msg_shape, tuple) and len(msg_shape) == 4 and \
all(isinstance(s, torch.Size) for s in msg_shape)
assert isinstance(to_fn, bool)
assert isinstance(epsilon, float)
# Message memory. Initialized to the identity message
self.memory = Message.identity()
# Whether this message is new, and haven't been read by recipient node. Of type bool
self.new = False
# Incident nodes and their variable list
self.vn = vn # Of type VariableNode
self.fn = fn # Of type FactorNode
self.msg_shape = msg_shape
# Link direction. Whether pointing toward a factor node. Of type bool
self.to_fn = to_fn
# Threshold of KL-divergence metric to measure whether a candidate message is different from the existing one
self.epsilon = epsilon
# Reserved field for additional attributes. Arbitrary type
self.attr = kwargs
# Pretty log
self.pretty_log = {}
def __str__(self):
# Override for pretty debugging and printing
fn_name = self.fn.name
vn_name = self.vn.name
if self.to_fn:
return vn_name + " --> " + fn_name
return fn_name + " --> " + vn_name
[docs] def reset_shape(self, msg_shape):
"""Reset shape for the Message
Parameters
----------
msg_shape : tuple of torch.Size
The target message shape, in the format ``(batch_shape, param_shape, sample_shape, event_shape)``. An empty
shape ``torch.Size([])`` should be used as the default none shape.
Warnings
--------
This method will clear the memory buffer ``self.memory`` and set ``self.new`` to False.
"""
assert isinstance(msg_shape, tuple) and len(msg_shape) == 4 and \
all(isinstance(s, torch.Size) for s in msg_shape)
self.msg_shape = msg_shape
self.memory = None
self.new = False
[docs] def write(self, new_msg, check_diff=True, clone=False):
"""Writes to the link message memory with the new message specified via `new_msg`. Once a new message is
written, ``self.new`` will be set to ``True``.
The message shape ``new_msg.shape`` will first be checked against ``self.msg_shape`` to ensure that the message
is compatible in shape. See `compatible_shape()` for more details.
If `check_diff` is ``True``, will check if the new message is different from the existing one before
replacing the existing with the new one.
If `clone` is ``True``, then will first clone `new_msg` and store the cloned message in the memory buffer.
Parameters
----------
new_msg : Message
The new message to be stored in this link-data.
check_diff : bool, optional
Whether to compare the difference between stored message against `new_msg` and decide whether to receive
the new message and set ``self.new`` to ``True``.
clone : bool, optional
Whether to clone `new_msg` before storing it in the memory buffer.
Raises
------
AssertionError
If new message's shape is not compatible.
Notes
-----
Messages will be deemed different in the following cases:
1. If they are of different types,
2. If new message has ``MessageType.Undefined`` type,
3. If they both have parameters and the batch average L2 distance between the two parameter tensors
is larger than ``epsilon``,
4. If they both have particles and either their particle value tensors or their particle log sampling
tensors are different.
5. If they both have particles, and they possess the same particles value tensors and same sampling log
density tensors, but the batch average cosine similarity distance between the two particle weight tensors
is larger than ``epsilon``.
.. note::
When `self` and `other` have type ``MessageType.Both``, the parameters will be chosen over the particles to
compare message difference.
.. note::
If want to set a new message of a different message type than the current memory, make sure reset_shape()
is first called so that shape check works for the new message.
"""
assert isinstance(new_msg, Message)
# Check new message shape
assert compatible_shape(self.msg_shape, new_msg.shape), \
"At {}: Attempt to write a message with incompatible shape. Expect message shape {}, instead encountered " \
"{}".format(str(self), self.msg_shape, new_msg.shape)
# Will replace the memory immediately if any one of the following conditions is met:
# - self.memory is None
# - check_diff is False
# - new message has different type
# - new message has Undefined type
# - messages have particles and new message has different particle values and/or sampling log densities
if self.memory is None or check_diff is False or new_msg.type != self.memory.type or \
new_msg.type == MessageType.Undefined or\
(MessageType.Particles in new_msg.type and not self.memory.same_particles_as(new_msg)):
self.memory = new_msg.clone() if clone is True else new_msg
self.new = True
return
# Otherwise, check difference by KL-divergence
if MessageType.Parameter in self.memory.type:
# For Parameter message, compare batch average L2 distance
# Parameter tensor has shape (batch_shape + param_shape), with param_shape of length 1
# L2 distance is computed along param_shape dimension, i.e., the -1 dimension
val = self.memory.diff_param(new_msg)
else:
# For Particles message, compare batch average cosine similarity distance
# Particle weights has shape (batch_shape + sample_shape)
# cosine similarity distance is computed along sample_shape dimension. i.e., the 0 dimension
val = self.memory.diff_weight(new_msg)
# Compare distance value with epsilon
if val > self.epsilon:
self.memory = new_msg.clone() if clone is True else new_msg
self.new = True
[docs] def read(self, clone=False):
"""Returns the current content stored in memory. Set ``self.new`` to ``False`` to indicate this link message
has been read in the current decision phase.
Parameters
----------
clone : bool
Whether to return a cloned message of the memory.
Returns
-------
The current memory message.
"""
self.new = False
msg = self.memory.clone() if clone is True else self.memory
return msg
[docs]class Node(ABC):
"""The base class for all nodes in PySigma graphical architecture.
Declares common attributes between `FactorNode` and `VariableNode`, for example a flag indicating whether this node
has reach quiescence, i.e., whether no new message shall be sent via adjacent links in current cycle. During
construction of the graph, its instance should be passed to `NetworkX` methods to instantiate a node.
Parameters
----------
name : str
Name of the node.
device : str
The device on which the node should be processing the messages. Defaults to 'cpu'
Attributes
----------
name
device
visited : bool
Indicates whether this node has been visited at all, i.e., `compute()` method being called at the current cycle.
Default to ``False`` at the start of the cycle.
in_linkdata : list of LinkData
List of incoming linkdata.
out_linkdata : list of LinkData
List of outgoing linkdata.
log : dict
Internal log
pretty_log : dict
Pretty log for beautiful front-end visualization.
"""
def __init__(self, name, device='cpu'):
self.name = name
self.device = device
# Flag indicating whether this node has been visited (compute() method called) during a decision cycle
self.visited = False
# List of LinkData of those link connecting to this node, incoming and outgoing ones respectively, from
# which we retrieve messages
self.in_linkdata = []
self.out_linkdata = []
# Global logging info
self.log = {}
self.pretty_log = {} # Log info to display at the GUI
def __str__(self):
# override to provide the node's name as its string representation
return self.name
@property
def quiescence(self):
"""Indicates whether this node has reached quiescence state, and no further message update computations, i.e.,
`compute()`, is necessary at the decision phase of the current cognitive cycle. This property thus plays an
important role in deciding the node traversing schedule of the graphical architecture.
The default behavior is to check whether any incoming linkdata contains a new unread message. If so, it is
decided that this node has breached quiescence and should carry out `compute()`, otherwise this nodes stays
quiesced.
This property should be overridden by subclass that desires a different quiescence checking behavior. For
example for certain nodes, `compute()` may only be called once *all* incoming linkdata contain new messages, not
*any*, and for other nodes their quiescence states depend only on whether `compute()` has ever been called
within the current decision phase.
"""
return any(in_ld.new for in_ld in self.in_linkdata)
[docs] @abstractmethod
def add_link(self, linkdata):
"""Adding linkdata connecting to this node.
"""
raise NotImplementedError
[docs] @abstractmethod
def compute(self):
"""Compute method to be called to propagate messages during decision phases.
Note that ``super()`` must be called within `compute()` method in any child class, because all abstract
node-level statistics logging is taken care of herein.
The default quiescence behavior for `compute()` is to return directly if `self.quiescence` is ``True``,
without logging anything or performing any further computation. Note that such behavior may or may not be
desired by child node class.
"""
# Return directly if quiesced
if self.quiescence:
return
# General logging regarding node computation statistics to be added here
self.visited = True
[docs] def reset_state(self):
"""Clears and resets the node's message propagation statistics to prepare logging for the imminent decision
phase computation.
.. note:: This method should be called prior to the first call to compute() at every cognitive cycle.
"""
# Clears visited state
self.visited = False
[docs]class FactorNode(Node, ABC):
"""Factor node abstract base class.
Guarantees that all incident nodes are variable nodes.
"""
[docs] def add_link(self, linkdata):
"""Add a linkdata connecting to a variable node
Parameters
----------
linkdata : LinkData
The incident linkdata to be registered.
"""
assert isinstance(linkdata, LinkData)
assert linkdata.fn is self
if linkdata in self.in_linkdata + self.out_linkdata:
return
if linkdata.to_fn:
self.in_linkdata.append(linkdata)
else:
self.out_linkdata.append(linkdata)
[docs]class VariableNode(Node, ABC):
"""Variable node abstract base class.
Guarantees that all incident nodes are factor nodes
Parameters
----------
name : str
Name of this variable node.
rel_var_list : iterable of Variable
Iterable of relational variables. Corresponds to the batch dimensions. Used to check ``b_shape`` attribute of
incoming messages.
param_var : Variable, optional
The parameter variable. Corresponds to the parameter dimension. Used to check ``p_shape`` attribute of incoming
messages.
index_var_list : iterable of Variable, optional
Iterable of indexing variables. Corresponds to the sample dimensions. Used to check ``s_shape`` attribute of
incoming messages. Must specify if `ran_var_list` is specified.
ran_var_list : iterable of Variable, optional
Iterable of random variables. Corresponds to the event dimensions. Used to check ``e_shape`` attribute of
incoming messages. Must specify if `index_var_list` is specified.
Attributes
----------
rel_vars : tuple of Variable
Tuple of relational variables, specified by `rel_var_list`.
param_var : Variable
Parameter variable, specified by `param_var`. Defaults to ``None`` if `param_var` is not specified.
index_vars : tuple of Variable
Tuple of indexing variables, specified by `index_var_list`. Defaults to ``None`` if `index_var_list` is not
specified.
ran_vars : tuple of Variable
Tuple of random variables, specified by `ran_var_list`. Default sto ``None`` if `ran_var_list` is not specified.
b_shape : torch.Size
Batch dimension sizes. Inferred from `rel_vars`.
p_shape : torch.Size
Parameter dimension sizes. Inferred from `param_var`. Defaults to ``torch.Size([])``.
s_shape : torch.Size
Sample dimension sizes. Inferred from `index_vars`. Defaults to ``torch.Size([])``.
e_shape : torch.Size
Event dimension sizes. Inferred from `ran_vars`. Defaults to ``torch.Size([])``.
"""
def __init__(self, name, rel_var_list, param_var=None, index_var_list=None, ran_var_list=None, **kwargs):
super(VariableNode, self).__init__(name, **kwargs)
assert isinstance(rel_var_list, Iterable) and \
all(isinstance(v, Variable) and v.metatype is VariableMetatype.Relational for v in rel_var_list)
assert param_var is None or \
(isinstance(param_var, Variable) and param_var.metatype == VariableMetatype.Parameter)
assert index_var_list is None or \
(isinstance(index_var_list, Iterable) and
all(isinstance(v, Variable) and v.metatype == VariableMetatype.Indexing) for v in index_var_list)
assert ran_var_list is None or \
(isinstance(ran_var_list, Iterable) and
all(isinstance(v, Variable) and v.metatype == VariableMetatype.Random) for v in ran_var_list)
assert (index_var_list is None) is (ran_var_list is None)
self.rel_vars = tuple(rel_var_list)
self.param_var = param_var
self.index_vars = tuple(index_var_list) if index_var_list is not None else None
self.ran_vars = tuple(ran_var_list) if ran_var_list is not None else None
self.b_shape = torch.Size([v.size for v in self.rel_vars])
self.p_shape = torch.Size([self.param_var.size]) if self.param_var is not None else torch.Size([])
self.s_shape = torch.Size([v.size for v in self.index_vars]) if self.index_vars is not None else torch.Size([])
self.e_shape = torch.Size([v.size for v in self.ran_vars]) if self.ran_vars is not None else torch.Size([])
[docs] def add_link(self, linkdata):
"""Register the LinkData connecting a factor node to this variable node.
Checks that the preset message shape specified in `linkdata` agrees with the inferred message shape at this
variable node.
Parameters
----------
linkdata : LinkData
The incident linkdata to be registered.
Raises
------
AssertionError
If the linkdata to be added does not impose the same message shape restriction as this variable node does.
"""
assert isinstance(linkdata, LinkData)
assert linkdata.vn is self
assert linkdata.msg_shape == (self.b_shape, self.p_shape, self.s_shape, self.e_shape), \
"At {}: The linkdata to be registered with the current node does not impose the same message shape " \
"restriction as this node does. Current node's shape: (batch_shape, param_shape, sample_shape, " \
"event_shape) = {}. Found linkdata's shape: {}"\
.format(self.name, (self.b_shape, self.p_shape, self.s_shape, self.e_shape), linkdata.msg_shape)
if linkdata in self.in_linkdata + self.out_linkdata:
return
if linkdata.to_fn:
self.out_linkdata.append(linkdata)
else:
self.in_linkdata.append(linkdata)
"""
Utility structural nodes
- DFN
- DVN
"""
[docs]class DFN(FactorNode):
"""Default (Dummy) Factor Node.
No special computation. Simply relays message to one or multiple incident variable nodes. Requires that incident
variable nodes share the same variables. Only admits one incoming link but can connect with multiple outgoing links.
Since all incident variable nodes should share the same variables, these variables will also be registered in the
attributes.
Parameters
----------
name : str
Name of this node.
Attributes
----------
rel_vars : tuple of Variable
Tuple of relational variables.
param_var : Variable
Parameter variable.
index_vars : tuple of Variable
Tuple of indexing variables.
ran_vars : tuple of Variable
Tuple of random variables.
"""
def __init__(self, name, **kwargs):
super(DFN, self).__init__(name, **kwargs)
self.pretty_log["node type"] = "Default Factor Node"
# Since all incident nodes should have the same variable list, we can therefore log it here as an attribute
self.rel_vars = None
self.param_var = None
self.index_vars = None
self.ran_vars = None
[docs] def add_link(self, linkdata):
"""Checks that all variable nodes on the other side of the linkdata share the same set of variables. Infer
attribute values from the connected variable nodes' variables.
.. note::
Only one incoming linkdata can be registered.
Parameters
----------
linkdata : LinkData
The linkdata to be registered.
Raises
------
AssertionError
If attempting to register more than one incoming linkdata.
AssertionError
If the variable node on the other side of the specified linkdata do not share the same set of variables as
other variable nodes in those linkdata that are already registered.
"""
assert isinstance(linkdata, LinkData)
# Make sure no more than on incoming link
assert not linkdata.to_fn or len(self.in_linkdata) == 0
# Also make sure incident variable nodes' var_list agree with each other
if self.rel_vars is None:
self.param_var = linkdata.vn.param_var
self.index_vars = linkdata.vn.rel_vars
self.ran_vars = linkdata.vn.ran_vars
else:
assert self.rel_vars == linkdata.vn.rel_vars
assert self.param_var == linkdata.vn.param_var
assert self.index_vars == linkdata.vn.index_vars
assert self.ran_vars == linkdata.vn.ran_vars
super(DFN, self).add_link(linkdata)
[docs] def compute(self):
"""Relay untempered message to downstream variable nodes.
"""
super(DFN, self).compute()
in_ld = self.in_linkdata[0]
msg = in_ld.read()
for out_ld in self.out_linkdata:
out_ld.write(msg)
[docs]class DVN(VariableNode):
"""Default (Dummy) Variable Node.
No special computation. Simply relay message to one or multiple factor nodes. Only admits one incoming link but can
connect with multiple outgoing links.
Parameters
----------
name : str
Name of this variable node.
rel_var_list : iterable of Variable
Iterable of relational variables. Corresponds to the batch dimensions. Used to check ``b_shape`` attribute of
incoming messages.
param_var : Variable, optional
The parameter variable. Corresponds to the parameter dimension. Used to check ``p_shape`` attribute of incoming
messages.
index_var_list : iterable of Variable, optional
Iterable of indexing variables. Corresponds to the sample dimensions. Used to check ``s_shape`` attribute of
incoming messages. Must specify if `ran_var_list` is specified.
ran_var_list : iterable of Variable, optional
Iterable of random variables. Corresponds to the event dimensions. Used to check ``e_shape`` attribute of
incoming messages. Must specify if `index_var_list` is specified.
"""
def __init__(self, name, rel_var_list, param_var=None, index_var_list=None, ran_var_list=None, **kwargs):
super(DVN, self).__init__(name, rel_var_list, param_var, index_var_list, ran_var_list, **kwargs)
self.pretty_log["node type"] = "Default Variable Node"
[docs] def add_link(self, linkdata):
"""Guarantees that no more than on incoming link is registered.
Parameters
----------
linkdata : LinkData
The linkdata to be registered.
Raises
------
AssertionError
If attempting to register more than one incoming linkdata.
"""
assert isinstance(linkdata, LinkData)
# Make sure no more than on incoming link
assert linkdata.to_fn or len(self.in_linkdata) == 0
super(DVN, self).add_link(linkdata)
[docs] def compute(self):
"""Relay untempered message to downstream factor nodes.
"""
super(DVN, self).compute()
in_ld = self.in_linkdata[0]
msg = in_ld.read()
for out_ld in self.out_linkdata:
out_ld.write(msg)


{% extends 'base.html' %} {% block app_content %} This is the home page of the example "main" blueprint. {% endblock %}


| DOSE: T+ 0:00 |
200 mg |
oral |
Vitamins / Supplements |
| T+ 4:00 |
10 mg |
oral |
2C-D |
| T+ 8:00 |
0.5 tablets |
oral |
MDE |
| T+ 9:00 |
0.5 tablets |
oral |
MDMA |
Here's a report to signify the dangers of unknowns - unknown constituents of street drugs and their unknown interactions with research chemicals. I wish I had found a report like this before I made myself guinea pig.
One night I decided to consume no more than 10 mg of 2C-D (maybe less). About 4 hours earlier, I had taken 200mg of l-theanine (free-form amino acid which is supposed to increase dopamine levels in some regions of the brain and promote relaxation) on an empty stomach. I had also had a few beers throughout the day, to very little effect.
The 2C-D, which I'm familiar with in low doses only, produced a +1 experience, much like a very low dose of mescaline. Anyway, after about 4 hours, the drug had said its goodbyes, and I decided to be reckless.
Knowing full-well the potential dangers in mixing with/and or taking research chemicals, I decided to take a half of a mediocre 'JJ' MDE pill I had laying around.
I had read in PIHKAL that LE-25 (2C-D), in German therapy research, has been used to boost the waning action of another therapeutic psychedelic (likely MDMA or similar). Therefore, I felt that the low-dose-after-low-dose combination would be okay. It was. It was also weak.  I was unhappy and my decision-making skills were impaired.
After about an hour, I decided to ingest another, different half pill of street 'ecstasy'. I had seen one other person take this pill before, and he seemed speedy and wanted to drink alcohol all night; but he still exhibited some empathogenic effects. Knowing this, I had some real misgivings about experimenting with it. I'd been hanging onto this pill for several months because I wasn't sure of it. So much for clarity and caution though... down the hatch it went.
I went outside to take a walk and look at stars in the <30 degree night. Within 10 minutes, I started feeling hot, edgy, pumped up, and worried. I debated whether or not to vomit, and decided to ride it out. I wish I'd vomited.>
After another five minutes, my heart was POUNDING at roughly 200 bpm, skipping beats, I was feeling faint and short of breath periodically, and I was PUMPED UP and HOT outside in the mid-20's F. Realizing the severity of this, I just walked, and walked, and walked - kept talking myself down, breathing deeply, trying to calm down and keep control, etc. I had panicked visions of being in a daze in the back of an ambulance with medics urgently shouting, 'What did you take... what did you take?!?' Being without health insurance, I blocked the thought out of my mind and kept walking. If it had gotten worse, I probably would have called an ambulance.
This lasted at peak intensity for about 45 minutes total. By then, whatever MDx drug that was in that pill kicked in, and I suddenly felt an odd sense of comfort in the midst of a near-crisis. I went back inside, but only for a moment. I took some vitamin C, B vitamins, and water, looked in the mirror at my entirely black eyes, and went back outside to chill out. My heart was still pounding rapidly, and I still had frightening palpitations. My body temperature was closer to normal from here on out though.
Overall, this intense experience lasted about 5 hours, after which I still had heart palpitations for 3 DAYS - ie: waking up in the morning with a racing heart, feeling skipped beats in my chest and throat, etc.
I'd guess that the combination had something to do with the intensity of the ill effects. 2C-D has a very noticeable amphetamine-like effect on me. I'd imagine it was still doing things in my brain and/or affecting my metabolism, even though I no longer felt the effects. Another thought is that the l-theanine somehow played into the equation. I'm no stranger to pre-loading with free-form amino acids, and I only do because it *does* make a difference.
It is safe to say that I won't be trying any undocumented combinations in the future. Nor will I be taking any street 'ecstasy' anymore. The risk of adulterants has grown so high that it's just too unpredictable and dangerous. Had I been in a hot club and not outside in freezing weather, I most probably would have woken up in a hospital bed - if I were that lucky.
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.


12 September 2005
This document describes the XML Schema namespace. It also contains a directory of links to these related resources, using Resource Directory Description Language.
A (non-normative) DTD XMLSchema.dtd for XML Schema. It incorporates an auxiliary DTD, datatypes.dtd.
An XML Schema schema document for XML Schema schema documents. Last updated with release of XML Schema 2nd edition in July 2004.


Start chatting by clicking "Chat Now"
Mary : Hi Nicholas this is Mary from Abank. How may I help you today?


Calendar Date handling. Uses joda-time, will switch to java.time at a later date. Joda-time is not exposed.


EC2ModifyInstanceAttributeRequest Class Reference
| Inherits from | AmazonServiceRequestConfig : NSObject |
| Declared in | EC2ModifyInstanceAttributeRequest.h |
Tasks
-
instanceId
The ID of the instance whose attribute is being modified.
property -
attribute
The name of the attribute being modified.
Available attribute names:
instanceType
,kernel
,ramdisk
,userData
,disableApiTermination
,instanceInitiatedShutdownBehavior
,rootDevice
,blockDeviceMapping
Constraints:
property
Allowed Values: instanceType, kernel, ramdisk, userData, disableApiTermination, instanceInitiatedShutdownBehavior, rootDeviceName, blockDeviceMapping, productCodes, sourceDestCheck, groupSet, ebsOptimized -
value
The new value of the instance attribute being modified.
Only valid when
propertykernel
,ramdisk
,userData
,disableApiTermination
orinstanceInitiateShutdownBehavior
is specified as the attribute being modified. -
blockDeviceMappings
The new block device mappings for the instance whose attributes are being modified.
Only valid when blockDeviceMapping is specified as the attribute being modified.
property -
sourceDestCheck
Boolean value
property -
disableApiTermination
Boolean value
property -
instanceType
String value
property -
kernel
String value
property -
ramdisk
String value
property -
userData
String value
property -
instanceInitiatedShutdownBehavior
String value
property -
groups
The value of the Groups property for this object.
property -
ebsOptimized
Boolean value
property -
– init
Default constructor for a new ModifyInstanceAttributeRequest object. Callers should use the property methods to initialize this object after creating it.
-
– initWithInstanceId:andAttribute:
Constructs a new ModifyInstanceAttributeRequest object. Callers should use properties to initialize any additional object members.
-
– addBlockDeviceMapping:
Adds a single object to blockDeviceMappings. This function will alloc and init blockDeviceMappings if not already done.
-
– addGroup:
Adds a single object to groups. This function will alloc and init groups if not already done.
-
– description
Returns a string representation of this object; useful for testing and debugging.
Properties
attribute
The name of the attribute being modified.
Available attribute
names: instanceType
, kernel
,
ramdisk
, userData
,
disableApiTermination
,
instanceInitiatedShutdownBehavior
,
rootDevice
, blockDeviceMapping
Constraints:
Allowed Values: instanceType, kernel, ramdisk, userData, disableApiTermination, instanceInitiatedShutdownBehavior, rootDeviceName, blockDeviceMapping, productCodes, sourceDestCheck, groupSet, ebsOptimized
@property (nonatomic, retain) NSString *attribute
Discussion
The name of the attribute being modified.
Available attribute
names: instanceType
, kernel
,
ramdisk
, userData
,
disableApiTermination
,
instanceInitiatedShutdownBehavior
,
rootDevice
, blockDeviceMapping
Constraints:
Allowed Values: instanceType, kernel, ramdisk, userData, disableApiTermination, instanceInitiatedShutdownBehavior, rootDeviceName, blockDeviceMapping, productCodes, sourceDestCheck, groupSet, ebsOptimized
Declared In
EC2ModifyInstanceAttributeRequest.h
blockDeviceMappings
The new block device mappings for the instance whose attributes are being modified.
Only valid when blockDeviceMapping is specified as the attribute being modified.
@property (nonatomic, retain) NSMutableArray *blockDeviceMappings
Discussion
The new block device mappings for the instance whose attributes are being modified.
Only valid when blockDeviceMapping is specified as the attribute being modified.
Declared In
EC2ModifyInstanceAttributeRequest.h
disableApiTermination
Boolean value
@property (nonatomic) bool disableApiTermination
Discussion
Boolean value
Declared In
EC2ModifyInstanceAttributeRequest.h
ebsOptimized
Boolean value
@property (nonatomic) bool ebsOptimized
Discussion
Boolean value
Declared In
EC2ModifyInstanceAttributeRequest.h
groups
The value of the Groups property for this object.
@property (nonatomic, retain) NSMutableArray *groups
Discussion
The value of the Groups property for this object.
Declared In
EC2ModifyInstanceAttributeRequest.h
instanceId
The ID of the instance whose attribute is being modified.
@property (nonatomic, retain) NSString *instanceId
Discussion
The ID of the instance whose attribute is being modified.
Declared In
EC2ModifyInstanceAttributeRequest.h
instanceInitiatedShutdownBehavior
String value
@property (nonatomic, retain) NSString *instanceInitiatedShutdownBehavior
Discussion
String value
Declared In
EC2ModifyInstanceAttributeRequest.h
instanceType
String value
@property (nonatomic, retain) NSString *instanceType
Discussion
String value
Declared In
EC2ModifyInstanceAttributeRequest.h
kernel
String value
@property (nonatomic, retain) NSString *kernel
Discussion
String value
Declared In
EC2ModifyInstanceAttributeRequest.h
ramdisk
String value
@property (nonatomic, retain) NSString *ramdisk
Discussion
String value
Declared In
EC2ModifyInstanceAttributeRequest.h
sourceDestCheck
Boolean value
@property (nonatomic) bool sourceDestCheck
Discussion
Boolean value
Declared In
EC2ModifyInstanceAttributeRequest.h
userData
String value
@property (nonatomic, retain) NSString *userData
Discussion
String value
Declared In
EC2ModifyInstanceAttributeRequest.h
value
The new value of the instance attribute being modified.
Only valid
when kernel
, ramdisk
, userData
,
disableApiTermination
or
instanceInitiateShutdownBehavior
is specified as the
attribute being modified.
@property (nonatomic, retain) NSString *value
Discussion
The new value of the instance attribute being modified.
Only valid
when kernel
, ramdisk
, userData
,
disableApiTermination
or
instanceInitiateShutdownBehavior
is specified as the
attribute being modified.
Declared In
EC2ModifyInstanceAttributeRequest.h
Instance Methods
addBlockDeviceMapping:
Adds a single object to blockDeviceMappings. This function will alloc and init blockDeviceMappings if not already done.
- (void)addBlockDeviceMapping:(EC2InstanceBlockDeviceMappingSpecification *)blockDeviceMappingObject
Discussion
Adds a single object to blockDeviceMappings. This function will alloc and init blockDeviceMappings if not already done.
Declared In
EC2ModifyInstanceAttributeRequest.h
addGroup:
Adds a single object to groups. This function will alloc and init groups if not already done.
- (void)addGroup:(NSString *)groupObject
Discussion
Adds a single object to groups. This function will alloc and init groups if not already done.
Declared In
EC2ModifyInstanceAttributeRequest.h
description
Returns a string representation of this object; useful for testing and debugging.
- (NSString *)description
Return Value
A string representation of this object.
Discussion
Returns a string representation of this object; useful for testing and debugging.
Declared In
EC2ModifyInstanceAttributeRequest.h
init
Default constructor for a new ModifyInstanceAttributeRequest object. Callers should use the property methods to initialize this object after creating it.
- (id)init
Discussion
Default constructor for a new ModifyInstanceAttributeRequest object. Callers should use the property methods to initialize this object after creating it.
Declared In
EC2ModifyInstanceAttributeRequest.h
initWithInstanceId:andAttribute:
Constructs a new ModifyInstanceAttributeRequest object. Callers should use properties to initialize any additional object members.
- (id)initWithInstanceId:(NSString *)theInstanceId andAttribute:(NSString *)theAttribute
Parameters
- theInstanceId
The ID of the instance whose attribute is being modified.
- theAttribute
The name of the attribute being modified.
Available attribute names:
instanceType
,kernel
,ramdisk
,userData
,disableApiTermination
,instanceInitiatedShutdownBehavior
,rootDevice
,blockDeviceMapping
Discussion
Constructs a new ModifyInstanceAttributeRequest object. Callers should use properties to initialize any additional object members.
Declared In
EC2ModifyInstanceAttributeRequest.h


|
Herkulex_English
v1
C++ API for Herkulex English version
|
#include <herkulex_driver.hpp>
Public Member Functions | |
| HerkulexDriver (std::string valid_com_name) | |
| Connect to the USB serial device and configure the port settings. More... | |
| void | setAcknowledgePolicy (char pID, int policy=1) |
| set the acknowledge policy More... | |
| void | setControlMode (char pID, int controlmode=0) |
| set the control mode More... | |
| void | setTorqueControl (char pID, int mode=0) |
| set the Torque Control More... | |
| float | getAbsoluteAngle (char pID) |
| float | getCalibratedAngle (char pID) |
| int | getError (char pID) |
| int | clearError (char pID) |
| void | runMotor (S_JOG_TAG *sjog, char num_sjog) |
Private Member Functions | |
| int | getValidComPort (std::string valid_com_name) |
| Get all the connected IMU on windows machine. More... | |
Uses serial_stream.hpp to send comamnds to herkulex
This class is written to mimic the SerialStream.h member functions. Hence, the member functions name are all the same, and not following google style guide
basics on usb read write using Win32 API http://xanthium.in/Serial-Port-Programming-using-Win32-API For using Overlapped (Multithread). i.e. non blocking read/write https://www.dreamincode.net/forums/topic/165693-microsoft-working-with-overlapped-io/
Created by:
| HerkulexDriver::HerkulexDriver | ( | std::string | valid_com_name | ) |
Connect to the USB serial device and configure the port settings.
This function will search all connected comport for a matching comport name and connect to it.
| [in] | valid_com_port | the com port name to match |
| int HerkulexDriver::clearError | ( | char | pID | ) |
clear the status error and status detail
| [in] | pID | id of the motor |
return returns nothing
| float HerkulexDriver::getAbsoluteAngle | ( | char | pID | ) |
gets the absolute angle Absolute position Raw Data (60) Angle = r(Absolute Position) X 0.325
| [in] | pID | id of the motor |
| float HerkulexDriver::getCalibratedAngle | ( | char | pID | ) |
gets the calibrated angle Calibrated position Data (58)
| [in] | pID | id of the motor |
| int HerkulexDriver::getError | ( | char | pID | ) |
gets the status error and status detail
Status Error: Bit Value Comment 0 0X01 Exceed Input Voltage limit 1 0X02 Exceed allowed POT limit 2 0X04 Exceed Temperature limit 3 0X08 Invalid Packet 4 0X10 Overload detected 5 0X20 Driver fault detected 6 0X40 EEP REG distorted 7 0X80 reserved
Status Detail: Bit Value Comment 0 0X01 Moving flag 1 0X02 Inposition flag 2 0X04 Checksum Error 3 0X08 Unknown Command 4 0X10 Exceed REG range 5 0X20 Garbage detected 6 0X40 MOTOR_ON flag 7 0X80 reserved
| [in] | pID | id of the motor |
return integer of combined status_error<<8 & status_detail
|
private |
Get all the connected IMU on windows machine.
This function is only necessary on windows.
The name of the comport device must match the stated name of "USB Serial Device" to be considered an IMU
| [out] | valid_com_port | a pointer to store all the discovered comport |
| void HerkulexDriver::runMotor | ( | S_JOG_TAG * | sjog, |
| char | num_sjog | ||
| ) |
runs the Motor using S_JOG protocol
| [in] | *sjog | array of S_JOG_TAG structure |
| [in] | num_sjog | number of sjog elements in sjog array |
return returns nothing
| void HerkulexDriver::setAcknowledgePolicy | ( | char | pID, |
| int | policy = 1 |
||
| ) |
set the acknowledge policy
Sets ACK Packet reply policy(1) when Request Packet is received.
ACK Policy(RAM Register Address 1)
0 : No reply to any Request Packet
1 : Only reply to Read CMD
(default) 2 : Reply to all Request Packet
| [in] | pID | id of the motor |
| [in] | policy | the acknowledge policy |
| void HerkulexDriver::setControlMode | ( | char | pID, |
| int | controlmode = 0 |
||
| ) |
set the control mode
Sets control mode (56):
0 : Position control (default) 1 : Turn/Velocity Control(Continuous rotation)
| [in] | pID | id of the motor |
| [in] | controlmode | the control mode |
| void HerkulexDriver::setTorqueControl | ( | char | pID, |
| int | mode = 0 |
||
| ) |
set the Torque Control
Sets torque control (52):
0 (0x00) : Torque free 1 (0x40) : Brake on 2 (0x60) : Torque On
| [in] | pID | id of the motor |
| [in] | controlmode | the control mode |


Andrew Maxwell breaks down on I'm a Celeb
by Ian BrennanLast night's I'm a Celeb was a tough one for Irish comedian Andrew Maxwell.
After choking on camel meat, the Dubliner was talking to James Haskell, the camp leader, and Jaqueline Jossa as the emotional toll of I'm a Celeb started to hit him.
"I honestly thought that I was gonna walk out, but I haven’t, when you’re tired, you just say 'have I done the right thing,'" Maxwell said.
Jossa spoke words of encouragement, saying: "You can never leave, I can tell that you're just tired" before going on to say that he's spent six days sleeping on the floor and that he was just worn out.
Haskell also offered a consoling hand as Maxwell started to cry, explaining that everyone has a bad day.
"You're an important part of the group and we need you," Haskell said, with the former England Rugby star promising to keep an eye on him.
"You're brilliant, you bring so much energy and laughter."
Maxwell, speaking to the camera on the reality show, explained his feelings saying: "You know, it's those sort of things when you're tired and you get down, then all of the thoughts that you don't care about normally sort of get into your head."


Bacon ipsum dolor amet burgdoggen kevin rump short loin pastrami andouille beef ribs flank prosciutto biltong doner meatball spare ribs.   Spare ribs jowl alcatra tri-tip landjaeger capicola. Shank cow hamburger biltong andouille ham pork loin filet mignon sausage bacon tenderloin short loin.
Beef ribs andouille flank fatback t-bone jowl picanha. Short ribs andouille kevin cupim kielbasa chicken ham hock sirloin boudin shank beef ribs strip steak tri-tip. Pork salami fatback shank, swine pork loin rump.


A-Rod Is A Very Confused Sportscaster In Game With Jimmy Fallon
by Corey AtadAlex Rodriguez might want to think twice before picking his next career move.
On Thursday’s “The Tonight Show”, the former professional baseball player joined host Jimmy Fallon for a game of “Teleprompter Tango”.
The game had the duo getting into character as sportscasters calling a baseball game with a teleprompter feeding them some pretty ridiculous lines.
 Wait, juicy fruit booty,” Rodriguez introduced himself.
 “Clean my little kitty cat and meow, meow, bish,” and “You know, baseball actually reminds me a lot of making love. It’s slow, boring, and you always leave early to beat the traffic.”
Also on the show, Rodriguez talked about his upcoming wedding to Jennifer Lopez.
“I would say it’s stressful, but it’s really not,” Rodriguez admitted. “You just let Jennifer plan everything and you just say, ‘Alright.'”
Rodriguez also warns fans not to expect any kind of choreographed dance from him at his wedding.
“Anything to do with dance, I kind of just try to take a back seat, she’s a professional dancer,” he joked.
The former New York Yankee also talked about his series “Back in the Game” and helping give sports and entertainment stars a second chance at establishing their careers.


Space rocket with requestAnimationFrame Create the space rocket animation with stars in different perspective.


We’ll be back soon!
Sorry for the inconvenience but we’re performing some maintenance at the moment. If you need to you can always contact us, otherwise we’ll be back online shortly!
— The Trustroots Team
Follow us on Twitter and Facebook
Check our status page


Hi, I'm Edmund and I just started coding last week and I love it.
First things first, I am profoundedly surprised to be seriously talented in:
I also love coming up with cool science projects with friends.I just added coding to my list of the things I love. I've always wanted to know how websites are created and I am happy to see that I can create one on my own.
Here are a few coding projects I have worked on during my learning experience. I think of them as experimental websites where I tryout something new I learn.
I have also posted some of my artworks here.Hope you'll like it.
I drew some of my inspirations from VectorStock.com.
Feel free to contact me at:


Quick sort is a common sort method for objects stored contiguously, such as arrays. Recently, while implement a list template, I trying to migrate quick sort method to doubly linked list. The basic ideas of implementing quicksort in arrays and in lists are same, also based on partition, but there's one thing different: The list does not support random access based on index. This essay will discuss how to implement quicksort in the list.
Swap List Nodes
When comes to sorting, it will involve the exchange of data between two objects in sequence to be ordered. In the list, this is the exchange of data between two list nodes. There are two methods for swaping list nodes.
By Swaping Data of Nodes
This is the simplest, most common method: Exchange datas stored in list nodes. C/C++ codes for
swap
function like this:template <class T> void List<T>::Swap(T *data1, T *data2) { if (*data1 == *data2) return; T tmp = *data1; *data1 = *data2; *data2 = tmp; }
By Manipulating Pointers of Nodes in List
Sometimes, The cost of copying data of nodes is large. In this circumstance, we can operate pointers of nodes to achieve exchange of two nodes. C/C++ codes for
swap
function like this:
Function Description:template <class T> BOOL List<T>::Swap(ListNode<T> *pos1, ListNode<T> *pos2) { if (pos1 == NULL || pos2 == NULL) { return FALSE; } if(pos1 == pos2) { return TRUE; } ListNode<T> *temp, *temp1; if(pos1 == m_pHead && pos2 == m_pTail) /* swap the head node and the tail node */ { if(pos1->m_pNext==pos2)/*only two nodes in list*/ { pos2->m_pNext=pos1; pos2->m_pPrev=NULL; pos1->m_pPrev=pos2; pos1->m_pNext=NULL; m_pHead = pos2; m_pTail = pos1; } else { pos1->m_pNext->m_pPrev=pos2; pos2->m_pPrev->m_pNext=pos1; pos2->m_pNext=pos1->m_pNext; pos1->m_pPrev=pos2->m_pPrev; pos2->m_pPrev = pos1->m_pNext = NULL; m_pHead = pos2; /* assign new head node */ m_pTail = pos1; /* assign new tail node */ } } else if(pos2 == m_pTail) /* swap the tail node and any other node */ { if(pos1->m_pNext==pos2) /* swap the last two nodes */ { pos1->m_pPrev->m_pNext=pos2; pos2->m_pPrev=pos1->m_pPrev; pos2->m_pNext=pos1; pos1->m_pPrev=pos2; pos1->m_pNext=NULL; m_pTail = pos1; /* assign new tail node */ } else { temp=pos2->m_pPrev; temp->m_pNext=pos1; pos1->m_pPrev->m_pNext=pos2; pos1->m_pNext->m_pPrev=pos2; pos2->m_pPrev=pos1->m_pPrev; pos2->m_pNext=pos1->m_pNext; pos1->m_pPrev=temp; pos1->m_pNext=NULL; m_pTail = pos1; /* assign new tail node */ } } else if(pos1 == m_pHead) /* swap the head node and any other node */ { if(pos1->m_pNext==pos2) /* swap the first two nodes */ { pos2->m_pNext->m_pPrev=pos1; pos1->m_pNext=pos2->m_pNext; pos1->m_pPrev=pos2; pos2->m_pNext=pos1; pos2->m_pPrev=NULL; m_pHead=pos2; /* assign new head node */ } else { temp=pos1->m_pNext; temp->m_pPrev=pos2; pos1->m_pPrev=pos2->m_pPrev; pos1->m_pNext=pos2->m_pNext; pos2->m_pPrev->m_pNext=pos1; pos2->m_pNext->m_pPrev=pos1; pos2->m_pNext=temp; pos2->m_pPrev=NULL; m_pHead=pos2; /* assign new head node */ } } else /* swap any other two nodes except the head and tail node */ { if(pos1->m_pNext==pos2) /* swap two adjacent nodes */ { temp=pos1->m_pPrev; pos1->m_pPrev->m_pNext=pos2; pos1->m_pNext->m_pPrev=pos2; pos1->m_pPrev=pos2; pos1->m_pNext=pos2->m_pNext; pos2->m_pNext->m_pPrev=pos1; pos2->m_pNext=pos1; pos2->m_pPrev=temp; } else { temp1 = pos1->m_pPrev; pos1->m_pPrev->m_pNext=pos2; pos1->m_pNext->m_pPrev=pos2; pos1->m_pPrev=pos2->m_pPrev; temp=pos1->m_pNext; pos1->m_pNext=pos2->m_pNext; pos2->m_pPrev->m_pNext=pos1; pos2->m_pNext->m_pPrev=pos1; pos2->m_pNext=temp; pos2->m_pPrev=temp1; } } return TRUE; };
- According to the position of two nodes, pointer operation has been processed for different circumstances.
- In this function, parameter
pos1
must be located in front ofpos2
.
Implementation Quicksort in List
Quicksort is a classic sort algorithm, the main step[refer wikipedia] of sorting is:
- Pick an element, called a pivot, from the array.
- Reorder the array so that all elements with values less than the pivot come before the pivot, while all elements with values greater than the pivot come after it (equal values can go either way). After this partitioning, the pivot is in its final position. This is called the partition operation.
- Recursively apply the above steps to the sub-array of elements with smaller values and separately to the sub-array of elements with greater values.
Applying above steps in list has serveral difference from applying in an array. The list doesn't support random access, can't random access the K-th element, so select the first node as pivot every time when sort sub-sequence objects.
Implementation Steps
The list to be sorted is split into two sub-lists. For simplicity, select the first node as a pivot, and then comparing all the nodes with the pivot, pick the nodes with smaller values than pivot to the left sub-list, pick the nodes with greater values than pivot to the right sub-list. After that, insert the pivot into list, as a bridge connecting the two sub-lists. Finally, recursively apply these steps to the left sub-list, right sub-list.
There is a little trick in partition
step. In fact, Implementing partition
just need traverse once the linked list. The methods is: Define two pointers pslow
, pfast
, pslow
initialized to the head node of the list, pfast
initialized to the next node after the head node; Using pslow
as pointer to the last node of sub-list with smaller values than pivot , using pfast
traverse the list. Every time encounter a smaller node than pivot, move pslow
to the next node, then swap the pslow
node and pfast
node.
Swap Data of Nodes Version
This version of quicksort is using swap method by swaping data of nodes. C/C++ codes for
quicksort
function like this:template <class T> void List<T>::__sort_list(ListNode<T> *begin, ListNode<T> *end) /* begin pointer to the fisrt node of list, end pointer to the last node of list */ { if(begin == NULL || end == NULL) return; if(begin == end) return; ListNode<T> *pslow = begin; ListNode<T> *pfast = begin->m_pNext; while(true) { if(pfast->m_tData < begin->m_tData) /* select the first node as a pivot */ { pslow = pslow->m_pNext; /* pslow always pointer to the last node of sub-list with smaller values than pivot */ Swap(&pslow->m_tData, &pfast->m_tData); } pfast = pfast->m_pNext; } /* pslow pointer to the proper position of list which pivot should stored at this moment */ Swap(&pslow->m_tData , &begin->m_tData); /* recursively apply __sort_list function to the left sub-list, right sub-list */ __sort_list(begin, pslow); __sort_list(pslow->next, end); };
Manipulate Pointers of Nodes Version
This version use swap method by manipulating pointers of nodes in List. C/C++ codes for
quicksort
function like this:template <class T> void List<T>::__swap_ptr(ListNode<T> **pos1, ListNode<T> **pos2) /* swap two pointer of list nodes */ { if (*pos1 == *pos2) { return; } ListNode<T> *tmp = *pos1; *pos1 = *pos2; *pos2 = tmp; }; template <class T> void List<T>::__sort_list(ListNode<T> *begin, ListNode<T> *end) { if(begin == NULL || end == NULL) return; if(begin == end) return; ListNode<T> *pslow = begin; ListNode<T> *pfast = begin->m_pNext; ListNode<T> *ptemp = NULL, *ptemp1 = NULL, *pEndFlag = NULL; pEndFlag = end; while(true) { ptemp = pfast; ptemp1 = pfast->m_pNext; if(pfast->m_tData < begin->m_tData) /* select the first node as a pivot */ { pslow = pslow->m_pNext; /* pslow always pointer to the last node of sub-list with smaller values than pivot */ Swap(pslow, pfast); __swap_ptr(&pslow, &pfast); /* attention! */ } if (ptemp == pEndFlag || ptemp == NULL) { break; } pfast = ptemp1; } BOOL32 bIsPivotLeft = FALSE, bIsPivotRight = FALSE; if (pslow == begin) { /* the proper postion pivot stored is leftmost of the list, so there is no need to sort left sub-list */ bIsPivotLeft = TRUE; } if (pslow == end) { /* the proper postion pivot stored is rightmost of the list, so there is no need to sort right sub-list */ bIsPivotRight = TRUE; end = begin; } /* pslow pointer to the proper position of list which pivot should stored at this moment */ Swap(pslow, begin); __swap_ptr(&pslow, &begin); /* attention! */ /* recursively apply __sort_list function to the left sub-list, right sub-list */ ListNode<T> *pLeftEnd = pslow->m_pPrev; ListNode<T> *pRightBegin = pslow->m_pNext; if (bIsPivotLeft == FALSE) { __sort_list(begin, pLeftEnd); } if (bIsPivotRight == FALSE) { __sort_list(pRightBegin, end); } };
Points for Attention
Swap
function just operates pointers inside list nodes, such as m_pPrev
, m_pNext
, it dosen't modify the value of two nodes pointers passed by function. It meams pos1
,pos2
still pointer to the nodes with origin value. Therefore, after calling Swap
, we must swap two pointers' value using __swap_ptr
function.
I implemented quicksort in doubly linked list, you can see C/C++ codes in file.


# Copyright (c) 2016, Xilinx, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION). HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
__author__ = "Yun Rock Qu"
__copyright__ = "Copyright 2016, Xilinx"
__email__ =<EMAIL_ADDRESS>from time import sleep
from pynq.iop import iop_const
from pynq.iop import DevMode
from pynq.iop import PMODA
from pynq.iop import PMODB
I2C_DELAY = .001
[docs]class Pmod_IIC(object):
"""This class controls the Pmod IIC pins.
Note
----
The index of the Pmod pins:
upper row, from left to right: {vdd,gnd,3,2,1,0}.
lower row, from left to right: {vdd,gnd,7,6,5,4}.
Attributes
----------
iop : _IOP
The _IOP object returned from the DevMode.
scl_pin : int
The SCL pin number.
sda_pin : int
The SDA pin number.
iic_addr : int
The IIC device address.
sr_addr : int
The IIC device SR address (base address + 0x104).
dtr_addr : int
The IIC device DTR address (base address + 0x108).
cr_addr : int
The IIC device CR address (base address + 0x100).
rfd_addr : int
The IIC device RFD address (base address + 0x120).
drr_addr : int
The IIC device DRR address (base address + 0x10C).
"""
def __init__(self, if_id, scl_pin, sda_pin, iic_addr):
"""Return a new instance of a Pmod IIC object.
Parameters
----------
if_id : int
The interface ID (1, 2) corresponding to (PMODA, PMODB).
scl_pin : int
The SCL pin number.
sda_pin : int
The SDA pin number.
iic_addr : int
The IIC device address.
"""
if not if_id in [PMODA, PMODB]:
raise ValueError("No such IOP for Pmod device.")
if (scl_pin not in range(8)):
raise ValueError("Valid SCL pin numbers are 0 - 7.")
if (sda_pin not in range(8)):
raise ValueError("Valid SDA pin numbers are 0 - 7.")
switchconfig = []
for i in range(8):
if i == sda_pin:
switchconfig.append(iop_const.PMOD_SWCFG_IIC0_SDA)
elif i == scl_pin:
switchconfig.append(iop_const.PMOD_SWCFG_IIC0_SCL)
else:
switchconfig.append(iop_const.PMOD_SWCFG_DIO0)
self.iop = DevMode(if_id, switchconfig)
self.iop.start()
self.iop.load_switch_config(switchconfig)
self.iic_addr = iic_addr
# Useful IIC controller addresses
self.sr_addr = iop_const.PMOD_XIIC_0_BASEADDR + \
iop_const.PMOD_XIIC_SR_REG_OFFSET
self.dtr_addr = iop_const.PMOD_XIIC_0_BASEADDR + \
iop_const.PMOD_XIIC_DTR_REG_OFFSET
self.cr_addr = iop_const.PMOD_XIIC_0_BASEADDR + \
iop_const.PMOD_XIIC_CR_REG_OFFSET
self.rfd_addr = iop_const.PMOD_XIIC_0_BASEADDR + \
iop_const.PMOD_XIIC_RFD_REG_OFFSET
self.drr_addr = iop_const.PMOD_XIIC_0_BASEADDR + \
iop_const.PMOD_XIIC_DRR_REG_OFFSET
def _iic_enable(self):
"""This method enables the IIC drivers.
The correct sequence to enable the drivers is:
1. Disale the IIC core.
2. Set the Rx FIFO depth to maximum.
3. Reset the IIC core and flush the Tx FIFO.
4. Enable the IIC core.
Note
----
This function is only required during initialization.
Parameters
----------
None
Returns
-------
None
"""
# Disable the IIC core
self.iop.write_cmd(self.cr_addr, 0x00)
# Set the Rx FIFO depth to maximum
self.iop.write_cmd(self.rfd_addr, 0x0F)
# Reset the IIC core and flush the Tx FIFO
self.iop.write_cmd(self.cr_addr, 0x02)
# Enable the IIC core
self.iop.write_cmd(self.cr_addr, 0x01)
sleep(I2C_DELAY)
[docs] def send(self, iic_bytes):
"""This method sends the command or data to the driver.
Parameters
----------
iic_bytes : list
A list of 8-bit bytes to be sent to the driver.
Returns
-------
None
Raises
------
RuntimeError
Timeout when waiting for the FIFO to be empty.
"""
# Enable IIC Core
self._iic_enable()
# Transmit 7-bit address and Write bit (with START)
self.iop.write_cmd(self.dtr_addr, 0x100 | (self.iic_addr << 1))
# Iteratively write into Tx FIFO, wait for it to be empty
for tx_cnt in range(len(iic_bytes)):
timeout = 100
# Construct the TX word
if (tx_cnt == len(iic_bytes) - 1):
tx_word = (0x200 | iic_bytes[tx_cnt])
else:
tx_word = iic_bytes[tx_cnt]
# Write data
self.iop.write_cmd(self.dtr_addr, tx_word)
while ((timeout > 0) and \
((self.iop.read_cmd(self.sr_addr) & 0x80) == 0x00)):
timeout -= 1
if (timeout == 0):
raise RuntimeError("Timeout when writing IIC.")
sleep(I2C_DELAY)
[docs] def receive(self, num_bytes):
"""This method receives IIC bytes from the device.
Parameters
----------
num_bytes : int
Number of bytes to be received from the device.
Returns
-------
iic_bytes : list
A list of 8-bit bytes received from the driver.
Raises
------
RuntimeError
Timeout when waiting for the RX FIFO to fill.
"""
# Reset the IIC core and flush the Tx FIFO
self.iop.write_cmd(self.cr_addr, 0x02)
# Set the Rx FIFO depth to one byte
self.iop.write_cmd(self.rfd_addr, 0x0)
# Transmit 7-bit address and Read bit
self.iop.write_cmd(self.dtr_addr, 0x101 | (self.iic_addr << 1))
# Enable the IIC core
cr_reg = 0x05
if num_bytes == 1:
cr_reg |= 0x10
self.iop.write_cmd(self.cr_addr,cr_reg)
sleep(I2C_DELAY)
# Program IIC Core to read num_bytes bytes and issue STOP
self.iop.write_cmd(self.dtr_addr, 0x200 + num_bytes)
# Read num_bytes from RX FIFO
iic_bytes = list()
while(len(iic_bytes) < num_bytes):
# Special condition for last two bytes
if (num_bytes - len(iic_bytes)) == 1:
self.iop.write_cmd(self.cr_addr,0x1)
elif (num_bytes - len(iic_bytes)) == 2:
self.iop.write_cmd(self.cr_addr, \
self.iop.read_cmd(self.cr_addr) | 0x10)
# Wait for data to be available in RX FIFO
timeout = 100
while(((self.iop.read_cmd(self.sr_addr) & 0x40) == 0x40) and \
(timeout > 0)):
timeout -= 1
if(timeout == 0):
raise RuntimeError("Timeout when reading IIC.")
# Read data
iic_bytes.append((self.iop.read_cmd(self.drr_addr) & 0xff))
sleep(I2C_DELAY)
return iic_bytes


---
layout: post
title: monkey sleeping like a baby at pashupatinath
date: '2015-08-18T00:59:45+02:00'
tags:
- Instagram
- PhotoOfTheDay
tumblr_url: http://deepredsky.tumblr.com/post/126930509874/monkey-sleeping-like-a-baby-at-pashupatinath
---
monkey sleeping like a baby at Pashupatinath temple in Kathmandu #nepal #monkey #pashupatinaath #temple #photooftheday


{% extends "global/Page.html" %} {% load otree static %} {% block title %} MTURK CODE - FIND THE KEY BELOW {% endblock %} {% block scripts %} {% endblock %} {% block styles %} {% endblock %} {% block content %}
To receive credit on MTurk, you must copy and paste the secret key below into your HIT.
YOUR SECRET KEY is {{ code }}
If we do not receive the correct key, you will not be credited.


Train Schedule
Train Schedule
Train Name
Destination
Frequency(min)
Next Arrival
Minutes Away
Add Train
Train Name
Please enter a Train Name
Destination
Please enter a Destination
First Train Time
Please enter a train time
Frequency
Please enter a Monthly Rate
Submit


Web Developer
A husband and father I have been building websites since 1995. My HTML5 and CSS skills propelled me to hone skills in JavaScript, React.js, MySQL, Mongo, Handlebars, Node.js and more.
Organizations depend on me to deliver high-quality customer experiences. My positivity, attention to detail, and pro-action help to inspire people. I consider feedback a breakfast of champions and continually strive to increase my usefulness to others.
I value resourcefulness, optimism and dependability. I caught the travel-bug in 2016 and enjoy posting video highlights of my travels on YouTube. I have a great Instant Pot recipe for garlic chicken. My mission is to inspire others and help them enjoy life more.


| # | Tag | Δ | Elo |
|---|---|---|---|
| ${player.rank} | ${player.name} | % if player.previous_rank != -1: <% rank_diff = player.previous_rank - player.rank %> % if rank_diff < 0: ${rank_diff} % elif rank_diff > 0: +${rank_diff} % else: - % endif % else: + % endif | ${'{:.2f}'.format(player.elo())} |
Source for how rankings are calculated can be found here.
Created by Max Timkovich