|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface JMXConnectorServerMBean
MBean interface for connector servers. A JMX API connector server is attached to an MBean server, and establishes connections to that MBean server for remote clients.
A newly-created connector server is inactive, and does
not yet listen for connections. Only when its start
method has been called does it start listening for connections.
| Method Summary | |
|---|---|
JMXServiceURL |
getAddress()
The address of this connector server. |
Map<String,?> |
getAttributes()
The attributes for this connector server. |
String[] |
getConnectionIds()
The list of IDs for currently-open connections to this connector server. |
boolean |
isActive()
Determines whether the connector server is active. |
void |
setMBeanServerForwarder(MBeanServerForwarder mbsf)
Adds an object that intercepts requests for the MBean server that arrive through this connector server. |
void |
start()
Activates the connector server, that is, starts listening for client connections. |
void |
stop()
Deactivates the connector server, that is, stops listening for client connections. |
JMXConnector |
toJMXConnector(Map<String,?> env)
Returns a client stub for this connector server. |
| Method Detail |
|---|
void start() throws IOException
Activates the connector server, that is, starts listening for
client connections. Calling this method when the connector
server is already active has no effect. Calling this method
when the connector server has been stopped will generate an
IOException
.
IOException
- if it is not possible to start listening
or if the connector server has been stopped.
IllegalStateException
- if the connector server has
not been attached to an MBean server.void stop() throws IOException
Deactivates the connector server, that is, stops listening for client connections. Calling this method will also close all client connections that were made by this server. After this method returns, whether normally or with an exception, the connector server will not create any new client connections.
Once a connector server has been stopped, it cannot be started again.
Calling this method when the connector server has already been stopped has no effect. Calling this method when the connector server has not yet been started will disable the connector server object permanently.
If closing a client connection produces an exception, that
exception is not thrown from this method. A JMXConnectionNotification
with type JMXConnectionNotification.FAILED
is emitted from this MBean
with the connection ID of the connection that could not be
closed.
Closing a connector server is a potentially slow operation. For example, if a client machine with an open connection has crashed, the close operation might have to wait for a network protocol timeout. Callers that do not want to block in a close operation should do it in a separate thread.
IOException
- if the server cannot be closed cleanly.
When this exception is thrown, the server has already attempted
to close all client connections. All client connections are
closed except possibly those that generated exceptions when the
server attempted to close them.boolean isActive()
Determines whether the connector server is active. A connector
server starts being active when its start
method
returns successfully and remains active until either its
stop
method is called or the connector server
fails.
void setMBeanServerForwarder(MBeanServerForwarder mbsf)
Adds an object that intercepts requests for the MBean server
that arrive through this connector server. This object will be
supplied as the MBeanServer
for any new connection
created by this connector server. Existing connections are
unaffected.
If this connector server is already associated with an
MBeanServer
object, then that object is given to
mbsf.setMBeanServer
. If doing so produces an exception, this
method throws the same exception without any other effect.
If this connector is not already associated with an
MBeanServer
object, or if the
mbsf.setMBeanServer
call just mentioned succeeds,
then mbsf
becomes this connector server's
MBeanServer
.
mbsf
- the new MBeanServerForwarder
.
IllegalArgumentException
- if the call to mbsf.setMBeanServer
fails
with IllegalArgumentException
. This includes the
case where mbsf
is null.String[] getConnectionIds()
The list of IDs for currently-open connections to this connector server.
JMXServiceURL getAddress()
The address of this connector server.
Map<String,?> getAttributes()
The attributes for this connector server.
JMXConnector toJMXConnector(Map<String,?> env) throws IOException
Returns a client stub for this connector server. A client
stub is a serializable object whose connect
method can be used to make
one new connection to this connector server.
A given connector need not support the generation of client stubs. However, the connectors specified by the JMX Remote API do (JMXMP Connector and RMI Connector).
env
- client connection parameters of the same sort that
can be provided to JMXConnector.connect(Map)
. Can be null, which is equivalent
to an empty map.
UnsupportedOperationException
- if this connector
server does not support the generation of client stubs.
IllegalStateException
- if the JMXConnectorServer is
not started (see isActive()
).
IOException
- if a communications problem means that a
stub cannot be created.
|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2004, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.


|
Table 1
|
Responses to open-ended questions on EIDs |
|
Table 2
|
Key barriers and proposed solutions relating to EIDs |
|
Table 3
|
Responses to open-ended questions on antimicrobial resistanc ... |
|
Table 4
|
Key barriers and proposed solutions relating to AMR and anti ... |
|
Table 5
|
Processes and activities proposed to move the National Emerg ... |


|
The Red Matrix
|
Functions | |
| check_account_email ($email) | |
| check_account_password ($password) | |
| check_account_invite ($invite_code) | |
| check_account_admin ($arr) | |
| account_total () | |
| create_account ($arr) | |
| send_reg_approval_email ($arr) | |
| send_verification_email ($email, $password) | |
| user_allow ($hash) | |
| user_deny ($hash) | |
| account_total | ( | ) |
Referenced by create_account(), and zfinger_init().
| check_account_admin | ( | $arr | ) |
Referenced by create_account().
| check_account_email | ( | ) |
Referenced by create_account(), and register_init().
| check_account_invite | ( | $invite_code | ) |
Referenced by create_account(), and register_init().
| check_account_password | ( | $password | ) |
Referenced by create_account(), and register_init().
| create_account | ( | $arr | ) |
Referenced by create_dir_account(), and register_post().
| send_reg_approval_email | ( | $arr | ) |
Referenced by register_post().
| send_verification_email | ( | $email, | |
| $password | |||
| ) |
Referenced by register_post().
| user_allow | ( | $hash | ) |
Referenced by admin_page_users_post(), and regmod_content().
| user_deny | ( | $hash | ) |
Referenced by admin_page_users_post(), and regmod_content().


Vipul Munot
Data Visualization
Lab 07
Desired Output:
1D scatterplot
Jittered one-dimensional scatterplot


Digital Navigation System
Online Banking
BMB
Pingit
Support
Contact
Welcome to the
Digital Navigation System
please select an option from the menu above.


Lorem ipsum dolor site amet con, sectetur adipiscing elit.
Lorem ipsum dolor site amet con, sectetur adipiscing elit.
Lorem ipsum dolor site amet con, sectetur adipiscing elit.
Lorem ipsum dolor site amet con, sectetur adipiscing elit.
Lorem ipsum dolor site amet con, sectetur adipiscing elit.
Lorem ipsum dolor site amet con, sectetur adipiscing elit.
Lorem ipsum dolor site amet con, sectetur adipiscing elit.
Lorem ipsum dolor site amet con, sectetur adipiscing elit.
Lorem ipsum dolor site amet con, sectetur adipiscing elit.
Lorem ipsum dolor site amet con, sectetur adipiscing elit.
Lorem ipsum dolor site amet con, sectetur adipiscing elit.
Lorem ipsum dolor site amet con, sectetur adipiscing elit.
My name is Johnny Doe. I am a web designer and graphic artist. I have a passion for creating beautiful designs. I'm always building new and exciting things for the web. I help companies and clients build successful online identities using creativity and innovation.
Created design solutions that had a high visual impact. Design decisions involved listening to clients and understanding their needs before making design decisions. Produced variety of graphics to communicate a better corporate identity.
Created design solutions that had a high visual impact. Design decisions involved listening to clients and understanding their needs before making design decisions. Produced variety of graphics to communicate a better corporate identity.
Created design solutions that had a high visual impact. Design decisions involved listening to clients and understanding their needs before making design decisions. Produced variety of graphics to communicate a better corporate identity.
Created design solutions that had a high visual impact. Design decisions involved listening to clients and understanding their needs before making design decisions. Produced variety of graphics to communicate a better corporate identity.
John Doe
222-222-2222
123 Street, City Address
<EMAIL_ADDRESS>facebook.com/JohnDoe
@MyTwitter


Stock charts are used to display data values where one is interested in 4 different values for each data point. This could for example be used to display a stocks open,close, min and max value during a specific day. Hence the name Stock chart (or Stock plot).
Stock plots are created as an instance of class StockPlot
so the
module "jpgraph_stock.php
" must first be included in the
script.
Figure 15.62. A stock graph (
illustrates a sample Stock chart plotstockex1.php
)
For this type of plot the y-data array must be consist of a number of quadruples of data where each quadruple consists of (open,close,min,max). The open and close values determine the min max for the middle bar and the min,max determine the end points of the "error-lines" at the top and bottom of each bar as shown in ??.
|
|
For this type of plot the y-data array must be consist of a number of quadruples of data where each quadruple consists of an even number of (open,close,min,max). The open and close values determine the min max for the middle bar and the min,max determine the end points of the "error-lines" at the top and bottom of each bar as shown in Figure 15.63. Explaining stock graphs. Note that the data follows the rules
|
To separate the two cases where "open > close" or "open < close " two different colors are used.
These colors are specified with the method
StockPlot::SetColor($aFrame, $aFill='white',
$aFrameNeg='darkred', $aFillNeg='darkred')
$aFrame
, $aFill
, The frame and fill color
when open <= close
$aFrameNeg
, $aFillNeg
, The frame and fill
color when open > close
StockPlot::SetColor()
method. By default a positive bar (close >
open) have a fill color of white and for the negative case where (close < open)
the bars have a red color.
The final possible variation of stock plots is the option to determine whether or not the end point for the min,max lines should have the horizontal line marking the end of the line or not. This can be adjusted with a call to method
StockPlot::HideEndLines($aHide=true)
A minor variation of stock charts is the BoxPlot
plot type. this
is almost the same as StockPlot
but with the very small difference
that in addition to the open,close,min, max values it is also possible to
specify a fifth, median value .
A box plot is created as in instance of class BoxPlot
which is
defined in "jpgraph_stock.php
"
The median lies between the open and close value and is illustrated as a horizontal line within the bar. An example of this is shown in
The color of the median line can be modified with a call to
BoxPlot::SetMedianColor($aColor)
In the same way as for other plots it is possible to associate an image map with these plots. The "hot" area for each plot is the mid "bar" section. In the same way as other plot types the method
BoxPlot::SetCSIMTargets($aTargets,$aAlts='',$aWinTargets='')
is used to set the URL:s for the hot areas


Toggle navigation
Tinsel
Your Stories
Language Reference
Publishing Your Game
Log Out
You are editing the story '
'.
Rename
Delete
Save


Lithuania pardons Russian spies
by AFPVilnius―Lithuanian President Gitanas Nauseda on Friday pardoned two Russians jailed by Vilnius for espionage, an official statement said, paving the way for a possible spy swap with Moscow.
Nauseda signed the decree to pardon Nikolai Filipchenko and Sergei Moisejenko who are serving prison terms for espionage in the Baltic EU and NATO state, according to the statement published on his official website.
Both Russians were sentenced by Lithuanian courts in 2017. They could be exchanged for two Lithuanian citizens, Yevgeny Mataitis and Aristidas Tamosaitis, convicted of spying in Russia in 2016, the Baltic News Service said.
A Norwegian, Frode Berg, convicted of spying and jailed in Russia could also be part of the swap, BNS said, quoting senior officials who requested anonymity.
Nauseda’s decree said the Russians were pardoned in line with a new law on spy swaps.
Presidential spokesman Antanas Bubnelis declined further comment when contacted by AFP on Friday.
Lithuanian officials said Filipchenko worked for the FSB Russian federal security service and was trying to recruit senior officials in the Baltic state, which was under Moscow’s thumb during the Soviet era.
He was sentenced to 10 years behind bars and did not appeal.
Moisejenko was jailed for 10 years and six months after a Vilnius court ruled he recruited a Lithuanian army captain who served at the country’s Siauliai military air base. He had pleaded innocent.
The two Lithuanians were sentenced in Russia in 2016 for allegedly sharing Russian military intelligence with Lithuania.


PHP REST API !
The application back-end is built in PHP using Laravel 5 framework. The front-end is built in Angular 2 using TypeScript.!
To run the php server goto the root of the folder and in terminal type php artisan serve.
Mysql configuration is required to access the database.
The .env file has DB_CONNECTION=mysql , DB_NAME=mydb,DB_USERNAME = root, DB_PASSWORD=
After configuring the mysql, run php artisan migrate followed by php artisan serve.
To run the Angular 2 front-end , dependencies are needed to be installed which can be done by running tthe command npm install.
ng serve spins up the Angular 2 development server.
The CRUD REST API uses a Customer model having fields such as id, email and title. The Customer Controller handles the various GET, POST, UPDATE AND DELETE requests.


Forgot Password?
New User? Register
Already Registered?
© 2019 Slide Login Form . All rights reserved | Design by W3layouts


Denard's Backyard BBQ Restaurant is an amazing place to take the family to satisfy your BBQ craving with some of our Memphis style BBQ, watch a an exciting game, and enjoy our entertainment. Call us at<PHONE_NUMBER>


Ruling: ${ruling.short_name}
Ruling: ${ruling.short_name}
Source
Alternate
Author: ${ruling.author}
Date: ${ruling.date_of_ruling}
Added By: ${ruling.added_by} at ${ruling.time}
Invalidates:
${inv}
References:
${ref}
Content:
${ruling.content}
Submit new ruling


| name | The name of the function as it will appear in Python. |
| fn | The function to wrap. |
| MIN_ARGS | The minimum number of arguments this function can accept. For use with functions with default arguments. Defaults to the maximum number of arguments this function supports. |
| fn_t | The function type of the function to wrap. This must be specified if more than one function shares the same name, otherwise the first one defined lexically will be used. |
import pyd.pyd; char[] foo(int i) { if (i > 10) { return "It's greater than 10!"; } else { return "It's less than 10!"; } } extern (C) export void inittestdll() { def!("foo", foo); module_init("testdll"); }And in Python:
>>> import testdll >>> print testdll.foo(20) It's greater than 10!


From version 4.2 unblu offers the option to use the Java Naming and Directory Interface (JNDI) when setting up the unblu collaboration server. JNDI is an interface that allows you to bind names to objects (or references to objects) and to look up those objects by name. JNDI allows you to minimize the number of people who need to know the credentials for accessing a production database. Only the Java EE app server needs to know if you use JNDI. See below for an example set up.
Up until release 4.2 it was necessary to use local system properties to configure the unblu collaboration server. We would strongly recommend that JNDI is used instead of local system properties.
You can set any allowed unblu property via JNDI. JNDI configuration should be performed as per your Java Application Server and it will then be applied to the running unblu product.
JNDI will work with any application server. When unblu starts it reads the JNDI properties; no matter how they are defined within the applications server. This is done using com.unblu.propertyoverlay which then references a configuration file.
You may still use configuration files when using JNDI but you must tell unblu where the configuration files are. This can be done using JNDI properties or system properties.
We cannot offer exact examples as the way JNDI is declared is non-standard but, purely for reference, here is a Tomcat example JNDI configuration for root context path installation:
Stored at:
$CATALINA_BASE_DIR/conf/Catalina/localhost/ROOT.xml
<Context> <Environment name="product" value="product.com.unblu.enterprise.universe.sso" type="java.lang.String" override="false"/> <Environment name="com.unblu.propertyoverlay" value"42x-sso.properties" type="java.lang.String" override="false"/> <Environment name="com.unblu.textoverlay" value="42x-sso-text.properties" type="java.lang.String" override="false"/> </Context>
For more on configuring JNDI for your web application server see the following (external) links:


What portions of this feed would you like to review?
{% if my_new_review_form %}
You have an active GTFS feed
You may only have one active GTFS feed at a time. If you have any reviews in progress you may not
be able to complete them. Are you sure you want to upload a new GTFS feed?


[SYMBOL]
[A]
[B]
[C]
[D]
[E]
[F]
[G]
[H]
[I]
[J]
[K]
[L]
[M]
[N]
[O]
[P]
[Q]
[R]
[S]
[T]
[U]
[V]
[W]
[X]
[Y]
[Z]
backend servers boxes, surrogate configuration and
content negotiation
IP addresses and
server acceleration and
bandwidth application layer
transport layer
bandwidth buckets
Basic authentication
2nd
auth_param directive, parameters supported
Basic Auth API
getpwnam helper
LDAP helper
MSNT helper
multi-domain NTLM helper
NCSA helper
PAM helper
SASL helper
SMB helper
winbind helper
YP helper
basicauthenticator, cache manager page
benchmarks filesystem disk spindles
FreeBSD
Linux
NetBSD
Solaris
filesystem performance configuration
hardware
Squid versions
I/O bottleneck and
blocking clients, access controls and
Bloom filters, Cache Digests
boot scripts
/etc/inittab scheme
/etc/rc.local
init.d scheme
rc.d scheme
broken_posts ACL
broken_posts directive
browser ACL type
BSD-based code, mbufs and
buffered I/O, redirectors
buffered_logs directive
access.log and
bus errors, debugging
byte hit ratio
|


Visible trigger that can activate observables ManualSwitchObj classes.
More...
#include <VisibleSensor.h>
|
|
std::list< ManualSwitchObj * > | observables |
| | list of observables objects
|
| |
|
std::vector< Action > | stages |
| | vector of stages(commands) through which observables objects should pass
|
| |
|
bool | repeat_allowed |
| | determines whether it is possible to send next command to the observables objects when they doesn't complete previous action: 'true' - possible; 'false' - impossible
|
| |
|
bool | is_keeping |
| | determines will be next command send afther end of the contact(end of the hold button): 'true' - will be; 'false' - won't be
|
| |
|
bool | non_run |
| | contain information about valid of the last contact: 'true' - sensor didn't respond; 'false' - sensor responded
|
| |
|
int | is_pressed |
| | number of active contacts
|
| |
|
int | stage_iter |
| | number of current stage from stages vector
|
| |
Visible trigger that can activate observables ManualSwitchObj classes.
- Author
- Vasily
- Version
- 1.0
- Date
- June 2017
◆ VisibleSensor()
| VisibleSensor::VisibleSensor |
( |
std::list< ManualSwitchObj *> |
_observables, |
|
|
bool |
_repeat_allowed, |
|
|
bool |
_is_keeping, |
|
|
b2Body * |
_body, |
|
|
Object * |
_object, |
|
|
std::vector< Action > |
_stages |
|
) |
| |
Defined constructor for this class.
- Parameters
-
| _observables | list of observables objects |
| _repeat_allowed | determines whether it is possible to send next command to the observables objects when they doesn't complete previous action: 'true' - possible; 'false' - impossible |
| _is_keeping | determines will be next command send afther end of the contact(end of the hold button): 'true' - will be; 'false' - won't be |
| _body | pointer to the box2d body assigned to this sensor |
| _object | pointer to the Object class assigned to this sensor |
| _stages | vector of stages(commands) through which observables objects should pass |
The documentation for this class was generated from the following files:


Great!
I'm modular Features. Like all modular page in grav. I was easy to create. Learn in here
I'm modular Features. Like all modular page in grav. I was easy to create. Learn in here
This is a globe icon as features item
HTML code, making it readable and pretty,
CSS describes how HTML elements are to be displayed
When three icons is not enough, you make into four
I am test text which called callout


Getting information about an album such as release date and the tracks on it is very easy.
album = Scrobbler::Album.new('Carrie Underwood', 'Some Hearts', :include_info => true) puts "Album: #{album.name}" puts "Artist: #{album.artist}" puts "Reach: #{album.reach}" puts "URL: #{album.url}" puts "Release Date: #{album.release_date.strftime('%m/%d/%Y')}" puts puts puts "Tracks" longest_track_name = album.tracks.collect(&:name).sort { |x, y| y.length <=> x.length }.first.length puts "=" * longest_track_name album.tracks.each { |t| puts t.name }
Would output:
Album: Some Hearts Artist: Carrie Underwood Reach: 18729 URL: http://www.last.fm/music/Carrie+Underwood/Some+Hearts Release Date: 11/15/2005 Tracks =============================== Wasted Don't Forget to Remember Me Some Hearts Jesus, Take the Wheel The Night Before (Life Goes On) Lessons Learned Before He Cheats Starts With Goodbye I Just Can't Live a Lie We're Young and Beautiful That's Where It Is Whenever You Remember I Ain't in Checotah Anymore Inside Your Heaven
Classes and Modules
- MODULE Scrobbler


Good morning.
You've come during Tuesday and Friday sale!
We are offering FREE shipping for a limited time.


Write an extension
Crosswalk extensions are written in Java, and have access to the standard Android APIs.
In addition, because Crosswalk on Android acts as an Activity and has access to a Context, an extension can make also use of those objects. However, the extension you'll develop in this tutorial doesn't use any Android APIs, as it only does simple string manipulation.
Even with the extensive Android APIs available to you, there may be some cases where you need to use other third-party libraries in your extension. This tutorial explains how to do this, with an example of using Gson to read and write JSON. (While the Android API has some JSON capabilities, Gson is much neater and easier to use.)
What does the extension do?
Here's an overview of how this extension works:
-
When the Crosswalk application (with extension) starts on the Android device, an instance of the
Echo
extension is instantiated. -
The web part of the application calls one of the methods exported by the JavaScript part of the extension; either
echo.echoAsync()
(asynchronous) orecho.echo()
(synchronous). Both take a single argument, representing the message to echo.In both cases, the JavaScript part of the extension creates a message object with this structure:
{ "id": "1", "content": "Hello world" }
Each message contains a unique request ID. This ID is used to ensure that the response is married up to the correct callback when the extension returns its results.
This message object is serialised to JSON and sent to the Java part of the extension.
-
Inside the
Echo
instance (Java), the JSON string received from the JavaScript part of the extension is deserialised to aMessage
object. -
Next, the private
echo()
method of theEcho
instance is invoked. Note that this method receives the request ID (from the JavaScript side).echo()
simply prefixes the string it was passed and returns it. -
The
Echo
instance then creates aMessage
object. This is serialised to a JSON string (via Gson) before being returned to the original caller.The JSON string is either returned immediately (synchronous) or posted back to the JavaScript side of the extension as a message (asynchronous).
-
On the JavaScript side, the JSON string is deserialised into an object with this structure:
{ "id": "1", "content": "You said: Hello world" }
The web application can do what it wants with the object; in this tutorial, it creates a DOM element containing the prefixed string held in the
content
property.
In the following sections, you'll create the Java and JavaScript sides of the extension and wire them together with a configuration file.
Set up the directory structure
cd ~/<my projects directory>/xwalk-echo-project
# top-level directory for extension code
mkdir xwalk-echo-extension-src
cd xwalk-echo-extension-src
# for the extension Java code; NB the Java classes
# will be in the package org.crosswalkproject.sample
# - adjust this for your own project
mkdir -p java/org/crosswalkproject/sample
# for extension JavaScript code
mkdir js
# for third party libs distributed with the project
mkdir tools
The build/
, lib/
and xwalk-echo-extension/
directories (shown in the project outline) will be created at build time.
Note that the following instructions assume you're in xwalk-echo-extension-src/
(the top-level directory for the extension project).
Add Java code for the extension
First, create a Java class which extends XWalkExtensionClient
.
java/org/crosswalkproject/sample/Echo.java
:
package org.crosswalkproject.sample;
import org.xwalk.app.runtime.extension.XWalkExtensionClient;
import org.xwalk.app.runtime.extension.XWalkExtensionContextClient;
import com.google.gson.Gson;
public class Echo extends XWalkExtensionClient {
private Gson gson = new Gson();
public Echo(String name, String jsApiContent, XWalkExtensionContextClient xwalkContext) {
super(name, jsApiContent, xwalkContext);
}
private String echo(String requestJson) {
Message request = gson.fromJson(requestJson, Message.class);
String reply = "You said: " + request.content;
Message response = new Message(request.id, reply);
return gson.toJson(response);
}
@Override
public void onMessage(int instanceId, String requestJson) {
postMessage(instanceId, echo(requestJson));
}
@Override
public String onSyncMessage(int instanceId, String requestJson) {
return echo(requestJson);
}
}
The two key methods in this class are the ones which override the default XWalkExtensionClient
methods. These provide the means for communicating between the JavaScript and Java parts of the extension:
onMessage()
: For asynchronous messages.onSyncMessage()
: For synchronous messages.
Internally, both methods invoke the private echo()
method, which:
- Deserialises the original request string to a
Message
object (see below). - Prefixes the content string (passed in the request) with "You said: ".
- Creates a new
Message
object as the response, with the prefixed string and the original request ID. - Serialises it back to JSON.
However, they return the result in different ways:
onSyncMessage()
returns the JSON string directly to the calling JavaScript code.onMessage()
indirectly returns the result by invokingpostMessage()
(a method on theXWalkExtensionClient
class). This posts a JSON string back to the JavaScript side of the API asynchronously, where it can be handled by a listener.
A supporting class is used to make these JSON operations easier, as shown below.
java/org/crosswalkproject/sample/Message.java
:
package org.crosswalkproject.sample;
public class Message {
public String id;
public String content;
public Message(String id, String content) {
this.id = id;
this.content = content;
}
}
(Gson provides methods for serialising to and deserialising from Java objects, providing they have public member variables, as the Message
class above does.)
Before you can build the extension, you will need to add the other required files, as explained below.
Add the extension configuration file
The configuration file tells the Crosswalk packaging tool (make_apk.py
) how the Java and JavaScript parts of the extension work together.
Create a JSON file xwalk-echo-extension.json
with this content:
{
"name": "echo",
"class": "org.crosswalkproject.sample.Echo",
"jsapi": "xwalk-echo-extension.js",
"permissions": []
}
The properties in the object defined in this file have the following roles:
name
: The extension's namespace, exposed to the web application's global scope. For example, as the namespace isecho
for your extension, the web application can use it as follows:// async echo.echoAsync("Hello world").then( function (result) { // ...process result... } ); // sync var message = echo.echo("Hello world");
Note that the web application doesn't have to import a JavaScript file: the extension's API is automatically made available in the global JavaScript scope when the extension is instantiated. The methods available on the API are the ones defined in the
xwalk-echo-extension.js
file you will create next.class
: The Java class which implements the extension; in your case, theorg.crosswalkproject.sample.Echo
class. Note that this should include the package name as well as the class name.jsapi
: The file which defines the JavaScript API. You will create this in the next section.permissions
: A list of additional permissions required by the extension. It's included here for completeness, but is empty in this case as this extension only requires Crosswalk's default permissions. If you are writing your own application, you may need to add extra permissions.The strings in the
permissions
array should match the corresponding Android permission; see the list of Android permissions for details. For example, if you needed access to theFLASHLIGHT
andGET_ACCOUNTS
permissions, your extension configuration file would have apermissions
property like this:"permissions": ["android.permission.FLASHLIGHT", "android.permission.GET_ACCOUNTS"]
At build time, make_apk.py
will combine this JSON file with configuration files for other extensions into a single extensions-config.json
file. This is the file that Crosswalk actually uses to load the extension class and its corresponding JavaScript API.
Add the JavaScript API file
Create js/xwalk-echo-extension.js
with this content:
/*
echoAsync() and echo() resolve to/return an object (respectively)
with the form:
{
id: '<request ID>',
content: '<content of reply from Java extension code>'
}
*/
// provides a unique ID for each call to the extension
var counter = 0;
// map from a request ID to a callback for the response
var successCbs = {};
// private method for building the message object and converting it
// to a JSON string for transfer to the Java part of the extension
var messageToJson = function (counter, message) {
var obj = {
id: '' + counter,
content: message
};
return JSON.stringify(obj);
};
// message listener for ALL messages; this invokes the correct
// callback depending on the ID in the message
extension.setMessageListener(function (message) {
var data = JSON.parse(message);
var cb = successCbs[data.id];
if (cb) {
cb(data);
delete successCbs[data.id];
}
});
// returns a promise which resolves to an array of file objects, or
// rejects with an error if the call to the extension fails
exports.echoAsync = function (message) {
counter += 1;
var messageJson = messageToJson(counter, message);
return new Promise(function (resolve, reject) {
successCbs[counter] = resolve;
// NB you MUST pass a string to postMessage()
try {
extension.postMessage(messageJson);
}
catch (e) {
reject(e);
}
});
};
// returns a Response object
exports.echo = function (message) {
counter += 1;
var messageJson = messageToJson(counter, message);
// NB you MUST pass a string to sendSyncMessage()
var result = extension.internal.sendSyncMessage(messageJson);
return JSON.parse(result);
};
A few notes on the content of this file:
The
counter
variable is incremented and passed as the request ID each time a call is made to thepostMessage()
method in the Java part of the extension. This is so that any messages returning from the extension can be married up to a corresponding callback. The counter is also passed to thesendSyncMessage()
method for the sake of consistency (the Java part of the extension always receives a JSON string with anid
andcontent
); this is despite the fact that there's no need to coordinate synchronous method calls with callbacks (as the result is returned immediately).When
echoAsync()
is invoked, a new Promise is created (see the next section). The function for handling a successful resolution of the Promise (resolve
) is associated with the unique ID for this request by adding it tosuccessCbs
.extension.setMessageListener()
sets a function to invoke for each message returned by the Java side of the extension. This function will be invoked for every message; but the handlers which will actually deal with the data are stored in thesuccessCbs
object: a map from request IDs to handlers. When a message is received, the correct handler is looked up fromsuccessCbs
and invoked with the message as an argument. The handler is deleted from thesuccessCbs
object after it has been invoked.Any properties (methods/objects/constants etc.) you want to expose as the JavaScript API for your extension should be appended to the
exports
object inside the JavaScript API file. This has a similar role to theexports
object in nodejs modules, defining the public face of the API. Any other variables not attached toexports
are only scoped to this file, and won't pollute the web application's global scope.The namespace the JavaScript API is exported to here (
echo
) is set in the extension configuration file,xwalk-echo-extension.json
, which you created in the previous section.The Java side of the extension is available via the
extension
object. Note that the code above invokes theextension.internal.sendSyncMessage()
andextension.postMessage()
functions, which communicate with the Java code you wrote earlier.
Promises, promises
The synchronous method defined for the extension's JavaScript API (echo()
) is straightforward, and has this signature:
echo.echo() : Message
where Message
has the shape described here.
By contrast, the asynchronous echoAsync()
method has this signature:
echo.echoAsync() : Promise
If you're not familiar with Promises (a relatively recent addition to the web application developer's toolkit), this might look odd. Why not just use callbacks? For example, replace the Promise-returning method with an async method which has this signature:
echo.echoAsync(callback) : undefined
and call callback(message)
when the Java side of the API returns its Message
object (serialised to JSON).
The problem with callbacks is that they have to be managed carefully: if callbacks are nested inside callbacks inside callbacks etc., it can lead to the so-called pyramid of doom. For example, imagine that you wanted to do some additional work on the response to set extra properties on it. You might have a couple of objects to do this, and invoke their methods once the initial result is passed to the callback:
echo.echoAsync(function (result) {
// decorate result with more properties
decorator1.decorate(result, function (decoratedResult) {
// decorate decoratedResult with even more properties
decorator2.decorate(decoratedResult, function (evenMoreDecoratedResult) {
displayData(evenMoreDecoratedResult);
});
});
});
In the code sample above, there are calls to two asynchronous functions, decorator1.decorate()
and decorator2.decorate()
, which decorate the response with additional properties. Note how the pyramid is already starting to emerge. Adding yet more decorators could make it even worse.
There are other ways to avoid the pyramid emerging here; but the point of using Promises is to codify those approaches with extra sugar on top, to simplify asynchronous code and avoid nested callbacks. For example, if echoAsync()
returns a Promise, and the *.decorate()
methods also return Promises, we could instead use this code:
echo.echoAsync()
.then(
function (result) {
return decorator1.decorate(result);
}
)
.then(
function (decoratedResult) {
return decorator2.decorate(decoratedResult);
}
)
.then(displayData);
The then()
method takes a function to apply to the value returned by the Promise when it is resolved (i.e. it successfully completes its asynchronous operation and "becomes" a value which is not an error). It can also optionally take a method to apply to any errors returned by the Promise if it is rejected (i.e. it fails in some way and "becomes" an error).
You can see that the pyramid effect has been avoided, and it's much clearer which processing steps are being applied to the data when.
Note that in the last then()
call, because we're not returning anything, we can just pass the displayData
function and the result of decorator2.decorate()
will be implicitly passed to that method.
In many environments, Promises are not natively available; the typical solution is to incorporate a library like Q to fill the gap. By contrast, in Crosswalk, you do have native access to Promises, which is what you're using in the JavaScript side of the extension (above); so there's less need for an external library.
Add build infrastructure
To use an extension in a Crosswalk application, you have to include it in the Android package for your application. The Crosswalk packaging tool has stringent requirements about how an extension should be structured to be included in a package. The layout of the extension must be like this:
myextension/
myextension.jar
myextension.js
myextension.json
All of the names must match: the directory name must match the prefix of the .jar
, .js
and .json
files, otherwise the extension won't be included in the package.
You would replace "myextension" with your extension's name. For the extension in this tutorial, the layout you need is:
xwalk-echo-extension/
xwalk-echo-extension.jar
xwalk-echo-extension.js
xwalk-echo-extension.json
However, you may notice that the files you have so far don't match this layout (e.g. the xwalk-echo-extension.js
is in a js
directory and you don't have a .jar
file at all). This is where the build infrastructure comes in. Rather than manually create these files and place them in the right directory, you'll set up an automatic build which will create a temporary xwalk-echo-extension
directory and copy/compile the three required files into it.
Ivy and Ant are common tools for working with Java projects, so you'll use them to build the extension: Ivy to download the Gson jar file at build time (as Echo
depends on it); and Ant to compile the Java code for the extension and copy files to the required locations. (If you are familiar with Eclipse, it's possible to use that as well as, or instead of, command-line tools.)
The next two sections explain how to set up Ivy and Ant.
Set up and configure Ivy
Follow the instructions below to install and configure Ivy:
Download the Apache Ivy distribution, which contains the Ivy tasks for Ant. It's available from the Apache Ivy download site. For example, to get Ivy 2.4.0-rc1:
$ wget http://www.mirrorservice.org/sites/ftp.apache.org/ant/ivy/2.4.0-rc1/apache-ivy-2.4.0-rc1-bin.zip
Unpack it and copy the Ivy jar file to the
tools/
directory:$ unzip apache-ivy-2.4.0-rc1-bin.zip $ cp apache-ivy-2.4.0-rc1/ivy-2.4.0-rc1.jar tools/
You can remove the zip file once you're done with it.
Add the Ivy configuration file,
ivy.xml
, to the top-level directory:<?xml version="1.0" encoding="UTF-8"?> <ivy-module version="2.3"> <info organisation="org.crosswalkproject.sample" module="xwalk-echo-extension" /> <dependencies> <dependency org="com.google.code.gson" name="gson" rev="2.2.4" conf="default->master" /> </dependencies> </ivy-module>
You only have one dependency here (
gson.jar
), but you could add other third-party libraries to this file.Note that Crosswalk is not in the Ivy repositories, and will be downloaded by Ant in the main buildfile.
Add an Ant buildfile
You should have already installed Ant as described in the Getting started instructions (Windows, Linux).
Once Ant is installed, add a buildfile, build.xml
, to the top-level directory of your project with this content:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="xwalk-echo-extension" default="dist">
<!-- Java source -->
<property name="src" value="java" />
<!-- downloaded third party libraries -->
<property name="lib" value="lib" />
<!-- Crosswalk Android version -->
<property name="crosswalk-version" value="${XWALK-STABLE-ANDROID-X86}" />
<!-- URL of Crosswalk Android bundle -->
<property name="crosswalk-download-url"
value="https://download.01.org/crosswalk/releases/crosswalk/android/stable/${crosswalk-version}/crosswalk-${crosswalk-version}.zip" />
<!-- location of downloaded Crosswalk Android file -->
<property name="crosswalk-zip" value="${lib}/crosswalk.zip" />
<!-- temporary build directory -->
<property name="build" value="build" />
<!-- final location for the built extension -->
<property name="dist" value="xwalk-echo-extension" />
<!-- classpath containing the Ivy Ant tasks jar file -->
<path id="ivy.lib.path">
<fileset dir="tools" includes="*.jar"/>
</path>
<!-- delete + make the temporary build directories -->
<target name="prepare">
<delete dir="${build}" quiet="true" />
<delete dir="${dist}" quiet="true" />
<mkdir dir="${build}" />
<mkdir dir="${lib}" />
<mkdir dir="${dist}" />
</target>
<!-- download dependencies using Ivy -->
<target name="download-deps" depends="prepare">
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant"
classpathref="ivy.lib.path" />
<ivy:retrieve pattern="${lib}/[artifact]-[revision].[ext]" />
</target>
<!-- check whether the Crosswalk zip file is present -->
<target name="check-crosswalk-present" depends="prepare">
<available file="${crosswalk-zip}" property="crosswalk-zip.present"/>
</target>
<!-- manually get crosswalk.zip if it's not already there -->
<target name="download-crosswalk" depends="prepare, check-crosswalk-present"
unless="crosswalk-zip.present">
<!-- fetch from the download site -->
<get src="${crosswalk-download-url}" dest="${crosswalk-zip}" />
<!-- unpack to lib/crosswalk-*/ -->
<unzip src="${crosswalk-zip}" dest="${lib}" />
</target>
<!-- compile the extension Java code -->
<target name="compile" depends="download-deps, download-crosswalk">
<first id="app_runtime_java">
<fileset dir="${lib}/crosswalk-${crosswalk-version}" includes="**/xwalk_app_runtime_java.jar" />
</first>
<javac srcdir="${src}" destdir="${build}"
encoding="utf-8" debug="true" verbose="true">
<classpath>
<fileset dir="${lib}" includes="*.jar" />
<file file="${toString:app_runtime_java}" />
</classpath>
</javac>
</target>
<!--
pack third party Java code and extension code into a single
jar, and copy supporting files to the xwalk-echo-extension/
directory; NB we don't need to pack any Crosswalk jars, as they
will be added by the packaging tool; and we don't need android.jar,
as that is on the Android target already
-->
<target name="dist" depends="compile">
<unjar dest="${build}">
<fileset dir="${lib}">
<include name="*.jar" />
</fileset>
</unjar>
<jar destfile="${dist}/xwalk-echo-extension.jar">
<fileset dir="${build}" excludes="META-INF/**" />
</jar>
<copy file="xwalk-echo-extension.json" todir="${dist}" />
<copy file="js/xwalk-echo-extension.js" todir="${dist}" />
</target>
</project>
This is a fairly standard Ant buildfile for a small project. The default task is dist
, which does the following:
- Deletes and recreates the
build/
andxwalk-echo-extension/
directories. - Downloads the Gson jar file dependency and puts it in the
lib/
directory (via Ivy). - Downloads Crosswalk Android (via HTTP) and unpacks it in the
lib/
directory. Note that if you want to use the beta or canary versions of Crosswalk, you will need to modify thecrosswalk-version
andcrosswalk-download-url
<property>
elements as follows:-
beta:
<property name="crosswalk-version" value="${XWALK-BETA-ANDROID-X86}" /> <property name="crosswalk-download-url" value="https://download.01.org/crosswalk/releases/crosswalk/android/beta/${crosswalk-version}/crosswalk-${crosswalk-version}.zip" />
-
canary:
<property name="crosswalk-version" value="...Crosswalk canary version..." /> <property name="crosswalk-download-url" value="https://download.01.org/crosswalk/releases/crosswalk/android/canary/${crosswalk-version}/crosswalk-${crosswalk-version}.zip" />
You can find the current canary version by consulting the downloads page.
-
- Compiles the extension Java source in the
src/
directory, placing the output.class
files into thebuild/
directory. - Unpacks the Gson jar file into the
build/
directory. This is so it can be included in the extension jar file. - Creates a jar file in
xwalk-echo-extension/
containing the extension.class
files and the content unpacked from the Gson jar file. - Copies the extension JSON configuration
xwalk-echo-extension.json
and the JavaScript API definitionjs/xwalk-echo-extension.js
into thexwalk-echo-extension/
directory.
The final output of this task, the xwalk-echo-extension/
directory, contains an extension with the correct layout to be included in a Crosswalk .apk
file, i.e.
xwalk-echo-extension/
xwalk-echo-extension.jar
xwalk-echo-extension.js
xwalk-echo-extension.json
Build the extension
As you added a standard Ant buildfile, building the extension is as simple as running this command in the xwalk-echo-extension-src/
directory:
$ ant
This runs the default dist
task (see above). (It may take a while the first time, as it will download the third party dependencies.)
Once the extension is built, the next step is to create the web application which can use it.


This is a pretty awesome website. It's editable in the browser using Anchor, a client-side static site generator. Don't know what a static site generator is? Doesn't matter. It's cool, it's hip, and it makes working with your website 110% easier. Try it. You can do cool stuff like set text bold using CTRL-B, or make it underlined using CTRL-U. You can probably figure out how to make it italics all on your own.
A Simple Blog Post #2
04/23/2018
This is a pretty awesome website. It's editable in the browser using Anchor, a client-side static site generator. Don't know what a static site generator is? Doesn't matter. It's cool, it's hip, and it makes working with your website 110% easier. Try it. You can do cool stuff like set text bold using CTRL-B, or make it underlined using CTRL-U. You can probably figure out how to make it italics all on your own.
A Simple Blog Post #3
04/23/2018
This is a pretty awesome website. It's editable in the browser using Anchor, a client-side static site generator. Don't know what a static site generator is? Doesn't matter. It's cool, it's hip, and it makes working with your website 110% easier. Try it. You can do cool stuff like set text bold using CTRL-B, or make it underlined using CTRL-U. You can probably figure out how to make it italics all on your own.
A Simple Blog Post #4
04/23/2018
This is a pretty awesome website. It's editable in the browser using Anchor, a client-side static site generator. Don't know what a static site generator is? Doesn't matter. It's cool, it's hip, and it makes working with your website 110% easier. Try it. You can do cool stuff like set text bold using CTRL-B, or make it underlined using CTRL-U. You can probably figure out how to make it italics all on your own.
A Simple Blog Post #5
04/23/2018
This is a pretty awesome website. It's editable in the browser using Anchor, a client-side static site generator. Don't know what a static site generator is? Doesn't matter. It's cool, it's hip, and it makes working with your website 110% easier. Try it. You can do cool stuff like set text bold using CTRL-B, or make it underlined using CTRL-U. You can probably figure out how to make it italics all on your own.
A Simple Blog Post #6
04/23/2018
This is a pretty awesome website. It's editable in the browser using Anchor, a client-side static site generator. Don't know what a static site generator is? Doesn't matter. It's cool, it's hip, and it makes working with your website 110% easier. Try it. You can do cool stuff like set text bold using CTRL-B, or make it underlined using CTRL-U. You can probably figure out how to make it italics all on your own.
A Simple Blog Post #7
04/23/2018
This is a pretty awesome website. It's editable in the browser using Anchor, a client-side static site generator. Don't know what a static site generator is? Doesn't matter. It's cool, it's hip, and it makes working with your website 110% easier. Try it. You can do cool stuff like set text bold using CTRL-B, or make it underlined using CTRL-U. You can probably figure out how to make it italics all on your own.
A Simple Blog Post #8
04/23/2018
This is a pretty awesome website. It's editable in the browser using Anchor, a client-side static site generator. Don't know what a static site generator is? Doesn't matter. It's cool, it's hip, and it makes working with your website 110% easier. Try it. You can do cool stuff like set text bold using CTRL-B, or make it underlined using CTRL-U. You can probably figure out how to make it italics all on your own.
Edit Me!
Edit Me!


What are you getting
Supportive
Community
Honest support can go a long way learning new skills and pushing through frustration.
Anywhere You
Go Access
Honest support can go a long way learning new skills and pushing through frustration.
Self-Paced
Video Courses
Honest support can go a long way learning new skills and pushing through frustration.


Axial proton density and T2, coronal proton density, and sagittal T1 and proton density images of the wrist were obtained.
Field strength: T
Site: Right wrist Left wrist
IV contrast (agent and volume):
None.
Ulnar variance: None. Positive ulnar variance. Negative ulnar variance.
Distal radioulnar joint
Carpal instability: None VISI DISI
Carpus effusion: None Mild Moderate Severe
Distal radioulnar joint effusion: None Mild Moderate Severe
Scapholunate ligament:
Lunotriquetral ligament:
Triangular fibrocartilage:
Lunate facet: Yes No
Hamate-lunate facet:
I: Normal. Mild tendinosis. Moderate tendinosis. Severe tendinosis.
II: Normal. Mild tendinosis. Moderate tendinosis. Severe tendinosis.
III: Normal. Mild tendinosis. Moderate tendinosis. Severe tendinosis.
IV: Normal. Mild tendinosis. Moderate tendinosis. Severe tendinosis.
V: Normal. Mild tendinosis. Moderate tendinosis. Severe tendinosis.
VI: Normal. Mild tendinosis. Moderate tendinosis. Severe tendinosis.
Carpal tunnel:
Median nerve:
Flexor retinaculum:
Flexor tendons:
Guyon canal:
Thumb carpometacarpal joint: Normal. Mild osteoarthritis. Moderate osteoarthritis. Severe osteoarthritis.
Scaphotrapezotrapezoidal joint: Normal. Mild osteoarthritis. Moderate osteoarthritis. Severe osteoarthritis.
Pisiform-triquetral joint: Normal. Mild osteoarthritis. Moderate osteoarthritis. Severe osteoarthritis.
Bones:
Muscles:
Vessels:


|
hcash
2.0.0
hcash
|
#include <AssetOperations.hpp>
Public Member Functions | |
| IssueAssetOperation (Asset a=Asset()) | |
| void | evaluate (TransactionEvaluationState &eval_state) const |
Public Attributes | |
| Asset | amount |
Static Public Attributes | |
| static const OperationTypeEnum | type = issue_asset_op_type |
Transaction must be signed by the active key on the issuer_name_entry.
The resulting amount of shares must be below the maximum share supply.
| void hsrcore::blockchain::IssueAssetOperation::evaluate | ( | TransactionEvaluationState & | eval_state | ) | const |
| Asset hsrcore::blockchain::IssueAssetOperation::amount |
|
static |


{% include 'header.html' %}
Heal network node by requesting the node rediscover their neighbors. Sends a ControllerCommand_RequestNodeNeighborUpdate to the node.
HealCauses the nodes data to be obtained from the Z-Wave network in the same way as if it had just been added. This method would normally be called automatically by OpenZWave, but if you know that a node has been changed, calling this method will force a refresh of the data held by the library. This can be especially useful for devices that were asleep when the application was first run.
RefreshUpdate the controller with network information from the SUC/SIS. Results of the RequestNetworkUpdate Command will be send as a Notification with the Notification type as Notification::Type_ControllerCommand
NetworkAsk a Node to update its Neighbor Tables This command will ask a Node to update its Neighbor Tables. Results of the RequestNodeNeighborUpdate Command will be send as a Notification with the Notification type as Notification::Type_ControllerCommand
NeighborRemove a Failed Device from the Z-Wave Network. This Command will remove a failed node from the network. The Node should be on the Controllers Failed Node List, otherwise this command will fail. You can use the HasNodeFailed function below to test if the Controller believes the Node has Failed. The Status of the Node Removal is communicated via Notifications. Specifically, you should monitor ControllerCommand Notifications. Results of the RemoveFailedNode Command will be send as a Notification with the Notification type as Notification::Type_ControllerCommand
Remove as Faulty


Chapter 3 OLS in Matrix Form
Setup
This will use the Duncan
data in a few examples.
3.1 Purpose
We can write regression model as, \[ y_i = \beta_0 + x_{i1} \beta_1 + x_{i2} \beta_2 + \cdots + x_{ik} \beta_k + u_k . \] It will be cleaner to write the linear regression as \[ y_i = \Vec{x}_{i} \Vec{\beta} + u_i \] where \(\Vec{x}_i\) is a \(1 \times (K + 1)\) row vector and \(\Vec{\beta}\) is a \((K + 1) \times 1\) column vector for a single observation \(i\).
Or we can write it as, \[ \Vec{y} = \Mat{X} \Vec{\beta} + \Vec{u} \] where \(\Vec{y}\) is a \(N \times 1\) row vector, \(\Mat{X}\) is a \(N \times (K + 1)\) matrix, and \(\Vec{\beta}\) is a \((K + 1) \times 1\) column vector for all \(N\) observations.
3.2 Matrix Algebra Review
3.2.1 Vectors
A vector is a list of numbers or random variables.
A \(1 \times k\) row vector is arranged \[ \Vec{b} = \begin{bmatrix} b_1 & b_2 & b_3 & \dots & b_k \end{bmatrix} \]
A \(1 \times k\) column vector is arranged \[ \Vec{a} = \begin{bmatrix} b_1 \\ b_2 \\ b_3\\ \dots \\ b_k \end{bmatrix} \]
Convention: assume vectors are column vectors
Convention: use lower-case bold Latin letters, e.g. \(\Vec{x}\).
Vector Examples
Vector of all covariates for a particular unit \(i\) as a row vector, \[ \Vec{x}_{i} = \begin{bmatrix} x_{i1} & x_{i2} & \dots & x_{ik} \end{bmatrix} \]
E.g. in the Duncan data, \[ \Vec{x}_{i} = \begin{bmatrix} \mathtt{education}_{i} & \mathtt{income}_{i} & \mathtt{type}_i \end{bmatrix} \]
Vector of the values of covariate \(k\) for all observations, \[ x_{.,k} = \begin{bmatrix} 1 \\ x_{i1} \\ x_{i2} \\ \dots \\ x_{ik} \end{bmatrix} \]
E.g. For the
education
variable in the column vector. \[ \Vec{x}_{i} = \begin{bmatrix} \mathtt{education}_{1} \\ \mathtt{education}_{2} \\ \dots & \vdots & \mathtt{education}_N \end{bmatrix} \]
3.2.2 Matrices
A matrix is a rectangular array of numbers
A matrix is \(n \times k\) (“\(n\) by \(k\)”) if it has \(n\) rows and \(k\) columns
A matrix \[ A = \begin{bmatrix} a_{11} & a_{12} & \dots & a_{1k} \\ a_{21} & a_{22} & \dots & a_{2k} \\ \vdots & \vdots & \ddots & \vdots \\ a_{n1} & a_{n2} & \dots & a_{nk} \end{bmatrix} \]
<IP_ADDRESS> Examples
The design matrix is the matrix of predictors/covariates in a regression: \[ X = \begin{bmatrix} 1 & x_{11} & x_{12} & \dots & a_{1k} \\ 1 & x_{21} & x_{22} & \dots & a_{2k} \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 1 & x_{n1} & a_{n2} & \dots & a_{nk} \end{bmatrix} \] The vector of ones is the constant.
In the Duncan data, for the regression
prestige ~ income + education + type
, the design matrix is,
\[
X = \begin{bmatrix}
1 & \mathtt{income}_{1} & \mathtt{education}_{1} & \mathtt{wc}_{1} & \mathtt{prof}_{1} \\
1 & \mathtt{income}_{2} & \mathtt{education}_{2} & \mathtt{wc}_{2} & \mathtt{prof}_{2} \\
\vdots & \vdots & \vdots & \vdots & \vdots \\
1 & \mathtt{income}_{N} & \mathtt{education}_{N} & \mathtt{wc}_{N} & \mathtt{prof}_{N} \\
\end{bmatrix}
\]
Use R function model.matrix
to create the design matrix from a formula and a data frame.
## (Intercept) income education typeprof typewc
## accountant 1 62 86 1 0
## pilot 1 72 76 1 0
## architect 1 75 92 1 0
## author 1 55 90 1 0
## chemist 1 64 86 1 0
## minister 1 21 84 1 0
## professor 1 64 93 1 0
## dentist 1 80 100 1 0
## reporter 1 67 87 0 1
## engineer 1 72 86 1 0
## undertaker 1 42 74 1 0
## lawyer 1 76 98 1 0
## physician 1 76 97 1 0
## welfare.worker 1 41 84 1 0
## teacher 1 48 91 1 0
## conductor 1 76 34 0 1
## contractor 1 53 45 1 0
## factory.owner 1 60 56 1 0
## store.manager 1 42 44 1 0
## banker 1 78 82 1 0
## bookkeeper 1 29 72 0 1
## mail.carrier 1 48 55 0 1
## insurance.agent 1 55 71 0 1
## store.clerk 1 29 50 0 1
## carpenter 1 21 23 0 0
## electrician 1 47 39 0 0
## RR.engineer 1 81 28 0 0
## machinist 1 36 32 0 0
## auto.repairman 1 22 22 0 0
## plumber 1 44 25 0 0
## gas.stn.attendant 1 15 29 0 0
## coal.miner 1 7 7 0 0
## streetcar.motorman 1 42 26 0 0
## taxi.driver 1 9 19 0 0
## truck.driver 1 21 15 0 0
## machine.operator 1 21 20 0 0
## barber 1 16 26 0 0
## bartender 1 16 28 0 0
## shoe.shiner 1 9 17 0 0
## cook 1 14 22 0 0
## soda.clerk 1 12 30 0 0
## watchman 1 17 25 0 0
## janitor 1 7 20 0 0
## policeman 1 34 47 0 0
## waiter 1 8 32 0 0
## attr(,"assign")
## [1] 0 1 2 3 3
## attr(,"contrasts")
## attr(,"contrasts")$type
## [1] "contr.treatment"
3.3 Matrix Operations
3.3.1 Transpose
The transpose of a matrix \(A\) flips the rows and columns. It is denoted \(A'\) or \(A^{T}\).
The transpose of a \(3 \times 2\) matrix is a \(2 \times 3\) matrix, \[ A = \begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \\ a_{31} & a_{32} \end{bmatrix} = \begin{bmatrix} a_{11} & a_{21} & a_{31} \\ a_{12} & a_{22} & a_{32} \end{bmatrix} \]
Transposing turns a \(1 \times k\) row vector into a \(k \times 1\) column vector and vice-versa.
\[ \begin{aligned}[t] x_i &= \begin{bmatrix} 1 \\ x_{i1} \\ x_{i2} \\ \vdots \\ x_{ik} \end{bmatrix} \\ x_i' &= \begin{bmatrix} 1 & x_{i1} & x_{i2} & \dots & x_{ik} \end{bmatrix} \end{aligned} \]
## [,1] [,2] [,3]
## [1,] 1 3 5
## [2,] 2 4 6
## [,1] [,2]
## [1,] 1 2
## [2,] 3 4
## [3,] 5 6
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 1 2 3 4 5 6
3.4 Matrices as vectors
A matrix is a collection of row (or column) vectors.
Write the matrix as a collection of row vectors \[ A = \begin{bmatrix} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \end{bmatrix} = \begin{bmatrix} \Vec{a}_1' \\ \Vec{a}_2' \end{bmatrix} \] \[ B = \begin{bmatrix} b_{11} & b_{12} \\ b_{21} & b_{22} \\ b_{31} & b_{32} \end{bmatrix} = \begin{bmatrix} \Vec{b}_1 \\ \Vec{b}_2 \Vec{b}_3 \end{bmatrix} \]
How does \(X\) relate to the model specification?
See the model.matrix
## (Intercept) education income typeprof typewc education:income
## accountant 1 86 62 1 0 5332
## pilot 1 76 72 1 0 5472
## architect 1 92 75 1 0 6900
## author 1 90 55 1 0 4950
## chemist 1 86 64 1 0 5504
## minister 1 84 21 1 0 1764
The OLS estimator of coefficients is \[ \hat{\beta} = \underbrace{(X' X)^{-1}}_{Var(X)} \underbrace{X' y}_{Cov(X, Y)} \]
3.5 Special matrices
A square matrix has equal numbers of rows and columns
The identity matrix, \(\Mat{I}_K\) is a \(K \times K\) square matrix with 1s on the diagonal, and 0s everywhere else. \[ \Mat{I}_3 = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} \]
The identity matrix multiplied by any matrix returns the matrix, \[ \Mat{A} \Mat{I}_{K} = \Mat{A} = \Mat{I}_{M} \Mat{A} \] where \(\Mat{A}\) is an \(M \times K\) matrix.
In R, to get the diagonal of a matrix use diag()
,
The function diag()
also creates identity matrices,
## [,1] [,2] [,3]
## [1,] 1 0 0
## [2,] 0 1 0
## [3,] 0 0 1
The zero matrix is a matrix of all zeros, \[ \Mat{0}_K = \begin{bmatrix} 0 & 0 & \dots 0 \\ 0 & 0 & \dots 0 \\ \vdots & \vdots & \ddots & vdots \\ 0 & 0 & \dots & 0 \end{bmatrix} \] The zero vector is a matrix of all zeros, \[ \Mat{0}_K = \begin{bmatrix} 0 \\ 0 \\ \vdots \\ 0 \end{bmatrix} \] The ones vector is a vector of all ones, \[ \Mat{0}_K = \begin{bmatrix} 1 \\ 1 \\ \vdots \\ 1 \end{bmatrix} \]
3.6 Multiple linear regression in matrix form
Let \(\widehat{\Vec{\beta}}\) be the matrix of estimated regression coefficients, and \(\hat{\Vec{y}}\) be the vector of fitted values: \[ \begin{aligned}[t] \widehat{\Vec{\beta}} &= \begin{bmatrix} \widehat{\beta}_0 \\ \widehat{\beta}_1 \\ \vdots \\ \widehat{\beta}_K \end{bmatrix} & \hat{\Vec{y}} &= \Mat{X} \widehat{\Vec{\beta}} \end{aligned} \] This could be expanded to, \[ \begin{aligned}[t] \hat{\Vec{y}} &= \begin{bmatrix} \hat{y}_1 \\ \hat{y}_2 \\ \vdots \\ \hat{y}_N \end{bmatrix} &= \Mat{X} \widehat{\Vec{\beta}} &= \begin{aligned} 1\widehat{\beta}_0 + x_{11} \widehat{\beta}_1 + x_{12} \widehat{\beta}_2 + \dots + x_{1K} \widehat{\beta}_K \\ 1\widehat{\beta}_0 + x_{21} \widehat{\beta}_1 + x_{22} \widehat{\beta}_2 + \dots + x_{2K} \widehat{\beta}_K \\ \vdots \\ 1\widehat{\beta}_0 + x_{N1} \widehat{\beta}_1 + x_{N2} \widehat{\beta}_2 + \dots + x_{NK} \widehat{\beta}_K \\ \end{aligned} \end{aligned} \]
3.7 Residuals
The residuals of a regression are, \[ \Vec{u} = \Vec{y} - \Mat{X} \widehat{\beta} \]
In two dimensions the Euclidian distance is, \[ d(a, b) = \sqrt{a^2 + b^2} \] Think the hypotenuse of a triangle.
The norm or length of a vector generalizes the Euclidian distance to multiple dimensions1
For a \(K \times 1\) vector \(\Vec{a}\), \[ | \Vec{a} | = \sqrt{a_1^2 + a_2^2 + \dots + a_K^2} \]
The norm can be written as the inner product, \[ {| \Vec{a} |}^2 = \Vec{a}\T \Vec{a} \]
Note that when the mean of a vector is 0, the norm is equal to \(N\) times the sample variance (using the \(N\) denominator) \[ \begin{aligned} \Var{\Vec{u}} &= \frac{1}{N} \sum_{i = 1}^N (u_i - \var{u})^2 \\ &= \frac{1}{N} \sum_{i = 1}^N u_i^2 \\ &= \frac{1}{N} \Vec{u}\T \Vec{u} \\ &= \frac{1}{N} {| \Vec{u} |}^2 \\ \end{aligned} \]
3.8 Scalar inverses
What is division? You may think of it as the inverse of multiplication (which it is), but it means that for number \(a\) there exists another number (the inverse of \(a\)) denoted \(a^{-1}\) or \(1 / a\) such that \(a \times a^{-1} = 1\).
This inverse does not always exist. There is no inverse for 0: \(0 \times ? = 1\) has no solution.
If the inverse exists, we can solve algebraic expressions like \(ax = b\) for \(x\), \[ \begin{aligned} ax &= b \\ \frac{1}{a} ax &= \frac{1}{a} b & \text{multiply both sides by the inverse of \[a\]} \\ x = \frac{b}{a} \end{aligned} \]
We’ll see in matrix algebra, the intuition is similar.
- The inverse is a matrix such that when it multiplies a number it results in 1 (or the equivalent)
- The inverse doesn’t always exist
- The inverse can be used to solve
3.9 Matrix Inverses
If it exists (it does not always), the inverse of square matrix \(\Mat{A}\), denoted \(\Mat{A}^{-1}\), is the matrix such that \[ \Mat{A}^{-1} \Mat{A} = \Mat{A} \Mat{A}^{-1} = \Mat{I} \]
The inverse can be used to solve systems of equations (like OLS) \[ \begin{aligned}[t] \Mat{A} \Vec{x} &= \Vec{b} \\ \Mat{A}^{-1} \Mat{A} \Vec{x} &= \Mat{A}^{-1} \Vec{b} \\ I \Vec{x} &= \Mat{A}^{-1} \Vec{b} \\ \Vec{x} &= \Mat{A}^{-1} \Vec{b} \end{aligned} \]
If the inverse exists, then \(\Mat{A}\) is called invertible or nonsingular.
3.10 OLS Estimator
OLS minimizes the sum of squared residuals \[ \arg \min \]
3.11 Implications of OLS
Independent variables are orthogonal to the residuals \[ \Mat{X}\T \hat{\Vec{u}} = \Mat{X}\T(\Vec{y} - \Mat{X} \widehat{\Vec{\beta}}) = 0 \] Fitted values are orthogonal to the residuals \[ \Vec{y}\T \hat{\Vec{u}} =(\Mat{X} \widehat{\Vec{\beta}})\T \hat{\Vec{u}} = \widehat{\Vec{\beta}}\T \Mat{X}\T \hat{\Vec{u}} = 0 \]
3.11.1 OLS in Matrix Form
\[ Y_i = \beta_0 + \beta_1 x_{i1} + \beta_2 x_{i2} + \dots + \beta_k x_{ik} + \epsilon_i \] We can write this as \[ \begin{aligned}[t] Y_i &= \begin{bmatrix} 1 & x_{i1} & x_{i2} & \dots & x_{ik} \end{bmatrix} \begin{bmatrix} \beta_0 \\ \beta_1 \\ \beta_2 \\ \vdots \\ \beta_k \end{bmatrix} + \epsilon_i \\ &= \underbrace{{x_i'}}_{1 \times k + 1} \underbrace{\beta}_{k + 1 \times 1} + \epsilon_i \end{aligned} \]
\[ Y_i = \beta_0 + \beta_1 x_{i1} + \beta_2 x_{i2} + \dots + \beta_k x_{ik} + \epsilon_i \] We can write it as \[ \begin{aligned}[t] \begin{bmatrix} Y_1 \\ Y_2 \\ \vdots \\ Y_n \end{bmatrix} &= \begin{bmatrix} 1 & x_{11} & x_{12} & \dots & x_{1k} \\ 1 & x_{21} & x_{22} & \dots & x_{2k} \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 1 & x_{n1} & x_{n2} & \dots & x_{nk} \end{bmatrix} \begin{bmatrix} \beta_0 \\ \beta_1 \\ \beta_2 \\ \vdots \\ \beta_k \end{bmatrix} + \begin{bmatrix} \epsilon_1 \\ \epsilon_2 \\ \vdots \\ \epsilon_n \end{bmatrix} \\ \underbrace{y}_{(n \times 1)} &= \underbrace{{x_i'}}_{(n \times k + 1)} \underbrace{\beta}_{(k + 1 \times 1)} + \underbrace{\epsilon}_{(n \times 1)} \end{aligned} \]
The regression standard error of the regression is \[ \hat{\sigma}_y^2 = \frac{\sum_i^n \epsilon_i^2}{n - k - 1} \] Write this using matrix notation.
Note that \[ E(X_i)^2 = \frac{\sum X_i^2}{n} \] In matrix notation this is, \[ \begin{bmatrix} x_1 & x_2 & \dots & x_n \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \\ \dots \\ x_n \end{bmatrix} = x' x \] If \(\bar{X} = 0\), then \[ \frac{X' X}{N} = Var(X) \]
- What is the vcov matrix of \(\beta\)?
- When would it be diagonal?
- What is on the off-diagonal?
- What is on the diagonal?
- Extract the standard errors from it.
OLS Standard errors \[ \hat{\beta}_{OLS} = (X' X)^{-1} X' y \]
\[ V(\hat{\beta}) = \begin{bmatrix} V(\hat{\beta}_0) & Cov(\hat{\beta}_0, \hat{\beta}_1) & \dots & Cov(\hat{\beta}_0, \hat{\beta}_k) \\ Cov(\hat{\beta}_1, \hat{\beta}_0) & V(\hat{\beta}_1) & \dots & Cov(\hat{\beta}_1, \hat{\beta}_k) \\ \vdots & \vdots & \ddots & \vdots \\ Cov(\hat{\beta}_k, \hat{\beta}_0) & Cov(\hat{\beta}_k, \hat{\beta}_1) & \dots & V(\hat{\beta}_k) \\ \end{bmatrix} \]
Which of these matrices are
- Homoskedastic
- Heteroskedastic
- Clustered standard errors
- Serially correlated
Show how \((X' X)^{-1} X' y\) is equivalent to the bivariate estimator.
- Write out \(\beta\) and plug in for the true \(Y\) in terms of \(X\) and \(\epsilon\)
- Take the variance of \(\hat{\beta} - \beta\)
\[ \hat{\beta} = \beta + (X' X)^{-1} X' \epsilon \\ \Var(\hat{\beta} - \beta) = var((X' X)^{-1} X' \epsilon) \\ \] We know that
- \((X' X)^{-1} X' \epsilon\) has mean zero since \(E(X' \epsilon) = 0\).
- \(var(z) = E(Z^2) - 0\)
- In matrix form \(Z Z'\) to get full matrix form
\[ V((X' X)^{-1} X' \epsilon) = (X' X)^{-1} X' \epsilon \epsilon' X (X' X)^{-1} = (X' X)^{-1} X' \Sigma X (X' X)^{-1} \] We need a way to estimate \(\hat{\Sigma}\). But it has \(n (n + 1) / 2\) elements … and we have only \(n\) observations, and \(n - k - 1\) degrees of freedom left after estimating the coefficients.
If homoskedasticity, \(\Sigma = \sigma^2 I\). \[ V((X' X)^{-1} X' \epsilon) = \sigma^2 (X' X)^{-1} \]
Panel of countries. Correlation within each year that is always the same
3.12 Covariance/variance interpretation of OLS
\[ \Mat{X}\T \Vec{y} = \sum_{i = 1}^N \begin{bmatrix} y_i \\ y_i x_{i1} \\ y_i x_{i2}\\ \vdots \\ y_i x_{iK} \end{bmatrix} \approx \begin{bmatrix} n\bar{y} \\ \widehat{\Cov}[y_i, x_{i1}] \\ \widehat{\Cov}[y_i, x_{i2}] \\ \vdots \\ \widehat{\Cov}[y_i, x_{iK}] \end{bmatrix} \]
\[ \begin{aligned} \Mat{X}\T \Mat{X} &= \sum_{i = 1}^N \begin{bmatrix} 1 & x_{i1} & x_{i2}& \cdots & x_{ik} \\ x_{i1} & x_{i1}^2 & x_{i2} x_{i1} & \cdots & x_{i1} x_{iK} \\ x_{i2} & x_{i1} x_{i2} & x_{i2}^2 & \cdots & x_{i2} x_{iK} \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ x_{iK} & x_{i1} x_{iK} & x_{i2} x_{iK} & \cdots & x_{ik} x_{iK} \end{bmatrix} \\ &\approx \begin{bmatrix} n & n \bar{x}_1 & n \bar{x}_2 & \cdots & n \bar{x}_K \\ n \bar{x}_3 & \widehat{\Var}[x_{i1}] & \widehat{\Cov}[x_{i1}, x_{i2}] & \cdots & n \widehat{Cov}[x_{i1}, x_{iK}] \\ n \bar{x}_3 & \widehat{\Cov}[x_{i1}, x_{i2}] & \widehat{\Var}[x_{i2}] & \cdots & n \widehat{\Cov}[x_{i2}, x_{iK}] \\ \vdots \\ n \bar{x}_K & \widehat{\Cov}[x_{iK}, x_{i1}] & \widehat{\Cov}[x_{iK}, x_{i2}] & \cdots & n \widehat{\Var}[x_{iK}] \end{bmatrix} \end{aligned} \]
This is technically the 2-norm, as there are other norms.↩


The value of "title" parameter in query string is "' OR 'a'='a"
Code:
Generated query by django is:
qry = "SELECT * FROM books_book WHERE title='%s'" % (title)
book = Book.objects.raw(qry)
SELECT * FROM books_book WHERE title='' OR 'a'='a'
And it is displaying all books


Priest Wood:
The Sacred Book of Seals? I thought that was a myth. How fascinating....
What have you learned about it?
"First tell me. What do you know about the 'Emperor's Key'?"


I promised I'd expand on those other uses for that SQL sequence generator, so here we are: higher order markov chains! This particular piece of code I'll be introducing allows generating strings with a model you train with other strings - for example, you could train the model with first names and then tell it to generate a first name based on that.
Why am I doing this in SQL? Because I can! And because, actually this really is kind of straightforward. The implementation is in SQLite, as usual.
I've also taken the time to create a separate GIT repository for this in case anyone's interested. The repository contains a set of pre-trained models with 5000 corporation names from the US tax bureau and the 5000 most popular last names from the US Census Bureau from 1990, along with the most popular female and male first names from the same year. The provided makefile will download and train that data for you, as well.
Update: Release 2 of markov.sql is a port to PostgreSQL; have a look at that if you prefer PostgreSQL, or if you enjoy reading about weird SQL hacks in general. As part of this update I've renamed some files in the repository to make it clear which database they're supposed to be used with and I've changed the links in this article to reflect this.
The repository for this little project is available at: http://git.becquerel.org/jyujin/markov.git - you can either grab a tarball from there or browse the source code (only 2 files, really). Alternatively, you could also issue the following command on your shell to check out a copy of the repository:
This will create a directory called markov all set up and ready to play.
Once you have the sources, there is a pre-compiled, pre-trained SQLite database dump under dist/sqlite3.markov-data.sql in that repository. To play with that, issue the following on a command line in this new markov-directory:
Now for the fun part: to create names, insert the type of name you want in the markovconstruct table, then insert the maximum number of iterations in the vautoconstruct view, like this:
insert into markovconstruct (id) values (3), (3), (3), (3), (3);
sqlite> insert into vautoconstruct (steps) values (40);]]>
The pre-trained IDs are: 2 for corporation names, 3 for female first names, 4 for male first names and 5 for last names. Once it's done, you should find the results in the markovresult table:
select * from markovresult;
3|1|alaron
3|2|roma
3|3|julia
3|4|shanie
3|5|daine]]>
The markovconstruct table has an optional column depth, which controls the order of the model that is used to create the output. The default is 3. To train new models yourself, insert the strings to train with into the vtrain table, like this:
insert into vtrain (id, data) values (42, 'foo'), (42, 'frob'), (42, 'barf'), (42, 'bar');]]>
That view should take care of everything. Once the insert operation completes the model will have been updated and you can generate strings based on it like you did with the names above.
Apart from the sequence generator, the following SQL trains and uses the model. A combined source file is available in the previously mentioned GIT repository.
First we need a few tables to hold the trained model; the tables markov3, markov2 and markov1 hold this data for us - third order, second order and first order models, respectively:
To train the models, we need somewhere to store the training data along with the parser state. Ordinarily we could omit this, but SQLite doesn't like self-recursive triggers, so we're stuck with a temporary data table.
To perform the actual training, all we then have to do is to examine the current state and the following symbol and increase the "cnt" in the model by one. Then the symbols are shifted through and the first symbol of the remainder of the string is used as the next symbol. We repeat that until the string is empty. NULLs are used as sentinels for start and end characters in the models.
Usually, in SQL, we'd use a stored procedure for this purpose - but SQLite doesn't support those. So insted we create a handful of views and create instead of insert triggers for them. Instead of calling these procedures, we have to insert into that view, but the net effect is the same as calling a procedure - that's a pretty handy trick in SQLite, by the way.
And finally, to create strings with our shiny new model, all we do is we start with a blank state and look up the probabilities for the next character in the appropriate model. This is where that handy sequence generator comes in.
You may have noticed that the model doesn't contain any totals, and the probabilities aren't expressed as floating point numbers. Instead, the only bit of data in the model is the number of times that the training data had a certain character follow the current state. If this were any other language, we'd have to massage and finalise this model to create a probability (between 0 and 1) to work with, then follow the regular algorithm. But this is SQL!
Instead, we create a view that selects all possible characters that could come next, given the current state and the model. We then repeat each of these possible next states as often as they occured in the training session with the help of our sequence generator and the cartesian product (or natural join in SQL). For example, if we had "foo" as the current state, and the next character could be an "a", a "b" or a "c" with counts 1, 2 and 3, respectively, then our view would return the result rows "a", "b", "b", "c", "c", "c". From this view we pick one row at random, using a select ... order by random() limit 1 clause. This has the same effect as calculating the totals, the probabilities and then choosing a number between 0 and 1 - except it's much more natural in SQL and quite a lot more straightforward. Well, as natural and straightforward as an order by random() select can possibly be, anyway :D.
This is a very primitive markov chain implementation, but it gets the job done. So I figured it'd be nice to include a few samples with this article. First, a few female first names based on the 1990 US Census Bureau data:
dani tristine odesire bryn ang jewell kylee maxie athrine don shari coriannetta hery margarda chella zuletta caretta frana janilseannelle vergie sanne bonna lakiaraine antin winny mona ardanna selena christashirleshanh pat kim ren ann kenza lauree nichanne rey tranchel nandra vira tessidy noelleneena cele chae cleonie zenor margenisha sommer shelleeshamerri chrin
This was generated with the following one liner in the training data: delete from markovresult; delete from markovconstruct; insert into markovconstruct (id) select 3 as id from seq8 where seq8.b < 50; insert into vautoconstruct (steps) values (40); select result from markovresult; - if we use 4 as the id, we get male names:
conrad jeremil karendellenard pedrigoberrolas luis bricenzo johnnis lyle ross rill keenardo darrolfonzo carson tore doyle vicent wilson kinley joesph santon cecil marcelo tyron wm joseven irwinston brand joan judson jamerlint mckie gail willis lylestefan fletch johnie neil sil mac den shelby haron jord fere bur shirley lamario normand kenny wilmerlin
And finally, id 5 in that dataset creates last names:
clandallamy busseno boa mcnaily choward cavez reinriggins mundtremblinclaross buchen ness mccliff fowley frazier crosby pharterider bean segayler barth nutson hessiter gain true aquett monds frie colemendrew cosgow wen wald hawkins dard thale hamer alf dell clangum bland ruck parrower humann mas varra spearce mire lanill ves sweedlindes marabtreauch bron druffmancough
Gotta love the US Census Bureau :D. Enjoy!


|
Elektra
0.8.24
|
This plugin is a notification plugin, which sends notifications using ZeroMq publish (ZMQ_PUB
) sockets when the key database (KDB) has been modified. It is compatible with the sending zeromqrecv plugin.
libzmq3-dev
(ZeroMQ C bindings > 3.2)The recommended way is to globally mount the plugin together with the zeromqrecv plugin:
kdb global-mount zeromqsend zeromqrecv
This plugin is designed to be used as a transport plugin for Elektra's notification feature. Since ZeroMq creates threads for asynchronous I/O this plugin always operates asynchronously.
Since ZeroMQ sockets only provide a 1:n mapping (i.e. one publisher with many subscribers or one subscriber and many publishers) the zeromqsend
and zeromqrecv
plugins require a XPUB/XSUB endpoint. The kdb tool "hub-zeromq" provides these endpoints.
Mount this plugin globally with default settings to use it as sending transport plugin for Elektra's notification feature:
kdb global-mount zeromqsend
This plugin supports the following configuration options when mounting:
ipc
and tcp
ZeroMQ transports are recommended. The default value is "tcp://localhost:6000".The ZeroMQ transport plugins use the publish/subscribe sockets (ZMQ_PUB
and ZMQ_SUB
) for notification transport.
Each notification is a multipart message. The first part contains the type of change, the second part contains the name of the changed key.
Possible only current change is Commit
.


--- title: Home layout: default ---
Stop writing thousands of lines of specification code.
Our intuitive visual editors significantly cut down on design time, and are spec agnostic.
Generate OAI (Swagger) and RAML specification code on demand.
Easily share your API with the world. StopLight supports one click publishing to the api-docs.io hosting platform.
Full API versioning support included.
Quickly send real requests to your API, and stop wasting time with cURL.
Store results privately on your computer, or online when you need to debug a request with a colleague.
Code generation included.
Mock, validate, and transform requests with Prism. Prism is fully integrated into the API Designer.
StopLight runs a hosted instance of Prism for every API in the designer, but you can also download and run Prism locally on any computer or server.
Invite engineers, QA, product managers, customer support... and your mom, to collaborate on your API projects.
Since our tools are visually driven, everybody on your team can understand and interact with your API, not just those fluent in technical specifications.
Have an existing API, but no spec? We've got you covered.
Send your API traffic through Prism proxy, and we'll automatically map out your endpoint and model definitions, saving your team tons of time.
“StopLight is not only helping me to do my job more efficiently, it is dead simple to use. It makes the delivery preparations steps of documenting the API easy, since the documentation was started before customer validation steps, and is updated throughout the process.”
“I feel like it [stoplight] has the potential to shift the landscape pretty significantly, something I haven't seen any API service provider do in a while.”
“What I didn't anticipate was the increased alignment across all stakeholders due to Stoplight creating a focal point for API definition and documentation. My plan to meet the aggressive MVP deadline at Twyla was to begin hiring API developers and outsource design and front-end development. Stoplight allowed us to mock the API so that front-end development could proceed in parallel with API development, always ensuring everyone had realtime updates.”


In show dull give need so held.  Incommode our not one ourselves residence. Shall there whose those stand she end. So unaffected partiality indulgence dispatched to of celebrated remarkably. Unfeeling are had allowance own perceived abilities. Sportsman delighted improving dashwoods gay instantly happiness six. Ham now amounted absolute not mistaken way pleasant whatever. At an these still no dried folly stood thing. Rapid it on hours hills it seven years. If polite he active county in spirit an. Mrs ham intention promotion engrossed assurance defective. Confined so graceful building opinions whatever trifling in. Insisted out differed ham man endeavor expenses. At on he total their he songs. Related compact effects is on settled do. Post no so what deal evil rent by real in. But her ready least set lived spite solid. September how men saw tolerably two behaviour arranging. She offices for highest and replied one venture pasture. Applauded no discovery in newspaper allowance am northward. Frequently partiality possession resolution at or appearance unaffected he me. Engaged its was evident pleased husband. Ye goodness felicity do disposal dwelling no. First am plate jokes to began of cause an scale. Subjects he prospect elegance followed no overcame possible it on. Are sentiments apartments decisively the especially alteration. Thrown shy denote ten ladies though ask saw. Or by to he going think order event music. Incommode so intention defective at convinced. Led income months itself and houses you. After nor you leave might share court balls. Suppose end get boy warrant general natural. Delightful met sufficient projection ask. Decisively everything principles if preference do impression of. Preserved oh so difficult repulsive on in household. In what do miss time be. Valley as be appear cannot so by. Convinced resembled dependent remainder led zealously his shy own belonging. Always length letter adieus add number moment she. Promise few compass six several old offices removal parties fat. Concluded rapturous it intention perfectly daughters is as. Picture removal detract earnest is by. Esteems met joy attempt way clothes yet demesne tedious. Replying an marianne do it an entrance advanced. Two dare say play when hold. Required bringing me material stanhill jointure is as he. Mutual indeed yet her living result matter him bed whence. Sussex result matter any end see. It speedily me addition weddings vicinity in pleasure. Happiness commanded an conveying breakfast in. Regard her say warmly elinor. Him these are visit front end for seven walls. Money eat scale now ask law learn. Side its they just any upon see last. He prepared no shutters perceive do greatest. Ye at unpleasant solicitude in companions interested. Of resolve to gravity thought my prepare chamber so. Unsatiable entreaties collecting may sympathize nay interested instrument. If continue building numerous of at relation in margaret. Lasted engage roused mother an am at. Other early while if by do to. Missed living excuse as be. Cause heard fat above first shall for. My smiling to he removal weather on anxious. Respect forming clothes do in he. Course so piqued no an by appear. Themselves reasonable pianoforte so motionless he as difficulty be. Abode way begin ham there power whole. Do unpleasing indulgence impossible to conviction. Suppose neither evident welcome it at do civilly uncivil. Sing tall much you get nor. On am we offices expense thought. Its hence ten smile age means. Seven chief sight far point any. Of so high into easy. Dashwoods eagerness oh extensive as discourse sportsman frankness. Husbands see disposed surprise likewise humoured yet pleasure. Fifteen no inquiry cordial so resolve garrets as. Impression was estimating surrounded solicitude indulgence son shy.


Put the math expression within $…$:
\(\LaTeX{}\)
$\Pi$
$ a * b = c ^ b $
$ 2^{\frac{n-1}{3}} $
$ \int_a^b f(x)\,dx. $
\( \int_a^b f(x)\,dx. \)
| $ \rho {\rm{FOD}} = \sum\limits{\sigma ,i} {(\delta _1 - \delta _2 n_i^\sigma ) | \phi _i^\sigma ({\bf{r}}) | ^2} $ |
Here is a liquid filter.
`escape inline code`
inline code
Here is a capture block.
100 / 3 = 33
:+1: :bolivia:
\1. 21312
\2. 21312
\4. 4214
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import networkx as nx
from collections import Counter
diagrams = defaultdict(list)
particle_counts = defaultdict(Counter)
for (a, b), neighbors in common_neighbors.items():
# Build up the graph of connections between the
# common neighbors of a and b.
g = nx.Graph()
for i in neighbors:
for j in set(nl.point_indices[
nl.query_point_indices == i]).intersection(neighbors):
g.add_edge(i, j)
# Define the identifiers for a CNA diagram:
# The first integer is 1 if the particles are bonded, otherwise 2
# The second integer is the number of shared neighbors
# The third integer is the number of bonds among shared neighbors
# The fourth integer is an index, just to ensure uniqueness of diagrams
diagram_type = 2-int(b in nl.point_indices[nl.query_point_indices == a])
key = (diagram_type, len(neighbors), g.number_of_edges())
# If we've seen any neighborhood graphs with this signature,
# we explicitly check if the two graphs are identical to
# determine whether to save this one. Otherwise, we add
# the new graph immediately.
if key in diagrams:
isomorphs = [nx.is_isomorphic(g, h) for h in diagrams[key]]
if any(isomorphs):
idx = isomorphs.index(True)
else:
diagrams[key].append(g)
idx = diagrams[key].index(g)
else:
diagrams[key].append(g)
idx = diagrams[key].index(g)
cna_signature = key + (idx,)
particle_counts[a].update([cna_signature])
| : | : : | : \(O_3 + C_2H_2 \rightarrow\) : | : \(O_3 + C_2H_4 \rightarrow\) : | : : | ||||
|---|---|---|---|---|---|---|---|---|
| : ^^ Method : | ^^ \(\lambda^a\) | vdW | TS | cycloadd. | vdW | TS | cycloadd. | ^^ MAE |
| \(\lambda\)-tPBE | 0.20 | -0.40 | 7.69 | -68.00 | -1.86 | 4.87 | -57.57 | 1.29 |
| MC1H-PBE \(^b\) | 0.25 | -1.08 | 3.66 | -70.97 | -1.25 | 0.13 | -61.26 | 3.35 |
| Reference values \(^c\) | ——— | -1.90 | 7.74 | -63.80 | -1.94 | 3.37 | -57.15 | ——— |
| \(^a\) The optimal mixing parameter.\(\~\) \(^b\) From Ref. .\(\~\) \(^c\) Best estimates from Ref. . |
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| spancell1 | spancell2 | cell | spancell3 | |||
| ^^ spancell1 | spancell2 | cell | spancell3 |
| (0,0) | (0,1) | (0,2) | (0,3) | |
| (1,0) | ^^ | (1,3) |
| (0,0) | (0,1) | (0,2) | (0,3) | |
| (1,0) | (1,3) |
| (0,0) | (0,1) | (0,2) | (0,3) | |
| (1,0) | ^^ |
| (0,0) | (0,1) | (0,2) | (0,3) | \ |
| (1,0) | ^^ |
| Stage | Direct Products | ATP Yields |
|---|---|---|
| Glycolysis | 2 ATP | |
| ^^ | 2 NADH | 3–5 ATP |
| Pyruvaye oxidation | 2 NADH | 5 ATP |
| Citric acid cycle | 2 ATP | |
| ^^ | 6 NADH | 15 ATP |
| ^^ | 2 FADH | 3 ATP |
| 30–32 ATP |
| : Here’s a Inline Attribute Lists example : | |||
|---|---|---|---|
| : : | : <div style="color: red;"> < Normal HTML Block > </div> : | ||
| ^^ | Red {: .cls style=”background: orange” } | ||
| ^^ IALs | Green {: #id style=”background: green; color: white” } | ||
| ^^ | Blue {: style=”background: blue; color: white” } | ||
| ^^ | Black {: color-style font-style} |
| Heading | Column 1 | Column 2 |
|---|---|---|
| Row 1 | Apple1 | Orange |
| Row 2 (merged) | Blueberry | Strawberry |
| ^^ | Plum | Raspberry |
Not in table: <Mail Gateway>
In table:
| Decision Point | Design Decision |
|---|---|
| Authoritative DNS MX Record | <Mail Gateway> |
9 * 9
| 1 * 1 = 1 | |||
| 1 * 2 = 2 | 2 * 2 = 4 | ||
| 1 * 3 = 3 | 2 * 3 = 6 | 3 * 3 = 9 | |
| 1 * 3 = 3 | 2 * 3 = 6 | 3 * 4 = 12 | 4 * 4 = 16 |
:+1:
$\LaTeX{}$
@startuml Bob -> Alice : hello @enduml
Tips:
|
) to delineate columns, and dashes to delineate the header row from the rest of the table.Use pipes ( |
) to delineate columns, and dashes to delineate the header row from the rest of the table. |
Footnote ↩


M
- the type of the model; for example PersonModel
I
- the type of the identifier; when using
TableRowSorter
this will be Integer
public abstract class RowFilter<M,I> extends Object
RowFilter
is used to filter out entries from the
model so that they are not shown in the view. For example, a
RowFilter
associated with a JTable
might
only allow rows that contain a column with a specific string. The
meaning of entry depends on the component type.
For example, when a filter is
associated with a JTable
, an entry corresponds to a
row; when associated with a JTree
, an entry corresponds
to a node.
Subclasses must override the include
method to
indicate whether the entry should be shown in the
view. The Entry
argument can be used to obtain the values in
each of the columns in that entry. The following example shows an
include
method that allows only entries containing one or
more values starting with the string "a":
RowFilter<Object,Object> startsWithAFilter = new RowFilter<Object,Object>() { public boolean include(Entry<? extends Object, ? extends Object> entry) { for (int i = entry.getValueCount() - 1; i >= 0; i--) { if (entry.getStringValue(i).startsWith("a")) { // The value starts with "a", include it return true; } } // None of the columns start with "a"; return false so that this // entry is not shown return false; } };
RowFilter
has two formal type parameters that allow
you to create a RowFilter
for a specific model. For
example, the following assumes a specific model that is wrapping
objects of type Person
. Only Person
s
with an age over 20 will be shown:
RowFilter<PersonModel,Integer> ageFilter = new RowFilter<PersonModel,Integer>() { public boolean include(Entry<? extends PersonModel, ? extends Integer> entry) { PersonModel personModel = entry.getModel(); Person person = personModel.getPerson(entry.getIdentifier()); if (person.getAge() > 20) { // Returning true indicates this row should be shown. return true; } // Age is <= 20, don't show it. return false; } }; PersonModel model = createPersonModel(); TableRowSorter<PersonModel> sorter = new TableRowSorter<PersonModel>(model); sorter.setRowFilter(ageFilter);
TableRowSorter
| Modifier and Type | Class and Description |
|---|---|
static class |
RowFilter.ComparisonType
Enumeration of the possible comparison values supported by
some of the default
RowFilter s. |
static class |
RowFilter.Entry<M,I>
An
Entry object is passed to instances of
RowFilter , allowing the filter to get the value of the
entry's data, and thus to determine whether the entry should be shown. |
| Constructor and Description |
|---|
RowFilter() |
| Modifier and Type | Method and Description |
|---|---|
static <M,I> RowFilter<M,I> |
andFilter(Iterable<? extends RowFilter<? super M,? super I>> filters)
Returns a
RowFilter that includes entries if all
of the supplied filters include the entry. |
static <M,I> RowFilter<M,I> |
dateFilter(RowFilter.ComparisonType type,
Date date,
int... indices)
Returns a
RowFilter that includes entries that
have at least one Date value meeting the specified
criteria. |
abstract boolean |
include(RowFilter.Entry<? extends M,? extends I> entry)
Returns true if the specified entry should be shown;
returns false if the entry should be hidden.
|
static <M,I> RowFilter<M,I> |
notFilter(RowFilter<M,I> filter)
Returns a
RowFilter that includes entries if the
supplied filter does not include the entry. |
static <M,I> RowFilter<M,I> |
numberFilter(RowFilter.ComparisonType type,
Number number,
int... indices)
Returns a
RowFilter that includes entries that
have at least one Number value meeting the
specified criteria. |
static <M,I> RowFilter<M,I> |
orFilter(Iterable<? extends RowFilter<? super M,? super I>> filters)
Returns a
RowFilter that includes entries if any
of the supplied filters includes the entry. |
static <M,I> RowFilter<M,I> |
regexFilter(String regex,
int... indices)
Returns a
RowFilter that uses a regular
expression to determine which entries to include. |
public static <M,I> RowFilter<M,I> regexFilter(String regex, int... indices)
RowFilter
that uses a regular
expression to determine which entries to include. Only entries
with at least one matching value are included. For
example, the following creates a RowFilter
that
includes entries with at least one value starting with
"a":
RowFilter.regexFilter("^a");
The returned filter uses Matcher.find()
to test for inclusion. To test for exact matches use the
characters '^' and '$' to match the beginning and end of the
string respectively. For example, "^foo$" includes only rows whose
string is exactly "foo" and not, for example, "food". See
Pattern
for a complete description of
the supported regular-expression constructs.
regex
- the regular expression to filter onindices
- the indices of the values to check. If not supplied all
values are evaluatedRowFilter
implementing the specified criteriaNullPointerException
- if regex
is
null
IllegalArgumentException
- if any of the indices
are < 0PatternSyntaxException
- if regex
is
not a valid regular expression.Pattern
public static <M,I> RowFilter<M,I> dateFilter(RowFilter.ComparisonType type, Date date, int... indices)
RowFilter
that includes entries that
have at least one Date
value meeting the specified
criteria. For example, the following RowFilter
includes
only entries with at least one date value after the current date:
RowFilter.dateFilter(ComparisonType.AFTER, new Date());
type
- the type of comparison to performdate
- the date to compare againstindices
- the indices of the values to check. If not supplied all
values are evaluatedRowFilter
implementing the specified criteriaNullPointerException
- if date
is
null
IllegalArgumentException
- if any of the indices
are < 0 or type
is
null
Calendar
,
Date
public static <M,I> RowFilter<M,I> numberFilter(RowFilter.ComparisonType type, Number number, int... indices)
RowFilter
that includes entries that
have at least one Number
value meeting the
specified criteria. For example, the following
filter will only include entries with at
least one number value equal to 10:
RowFilter.numberFilter(ComparisonType.EQUAL, 10);
type
- the type of comparison to performindices
- the indices of the values to check. If not supplied all
values are evaluatedRowFilter
implementing the specified criteriaIllegalArgumentException
- if any of the indices
are < 0, type
is null
or number
is null
public static <M,I> RowFilter<M,I> orFilter(Iterable<? extends RowFilter<? super M,? super I>> filters)
RowFilter
that includes entries if any
of the supplied filters includes the entry.
The following example creates a RowFilter
that will
include any entries containing the string "foo" or the string
"bar":
List<RowFilter<Object,Object>> filters = new ArrayList<RowFilter<Object,Object>>(2); filters.add(RowFilter.regexFilter("foo")); filters.add(RowFilter.regexFilter("bar")); RowFilter<Object,Object> fooBarFilter = RowFilter.orFilter(filters);
filters
- the RowFilter
s to testRowFilter
implementing the specified criteriaIllegalArgumentException
- if any of the filters
are null
NullPointerException
- if filters
is nullArrays.asList(T...)
public static <M,I> RowFilter<M,I> andFilter(Iterable<? extends RowFilter<? super M,? super I>> filters)
RowFilter
that includes entries if all
of the supplied filters include the entry.
The following example creates a RowFilter
that will
include any entries containing the string "foo" and the string
"bar":
List<RowFilter<Object,Object>> filters = new ArrayList<RowFilter<Object,Object>>(2); filters.add(RowFilter.regexFilter("foo")); filters.add(RowFilter.regexFilter("bar")); RowFilter<Object,Object> fooBarFilter = RowFilter.andFilter(filters);
filters
- the RowFilter
s to testRowFilter
implementing the specified criteriaIllegalArgumentException
- if any of the filters
are null
NullPointerException
- if filters
is nullArrays.asList(T...)
public static <M,I> RowFilter<M,I> notFilter(RowFilter<M,I> filter)
RowFilter
that includes entries if the
supplied filter does not include the entry.filter
- the RowFilter
to negateRowFilter
implementing the specified criteriaIllegalArgumentException
- if filter
is
null
public abstract boolean include(RowFilter.Entry<? extends M,? extends I> entry)
The entry
argument is valid only for the duration of
the invocation. Using entry
after the call returns
results in undefined behavior.
entry
- a non-null
object that wraps the underlying
object from the model 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.


| static | Application() |
| public static nothrow void | EndModal() |
| public static void | Exit() |
| public static void | Exit(int exitCode) |
| public static nothrow Window* | GetActiveWindow() |
| public static Control* | GetFocusedControl() const |
| public static nothrow LogView* | GetLogView() |
| public static nothrow ResourceManager& | GetResourceManager() |
| public static nothrow WindowManager& | GetWindowManager() |
| public static void | Init() |
| public static nothrow Window* | MainWindow() |
| private static bool | ProcessMessage(void* windowHandle, uint msg, uint wparam, long lparam, long& result, void*& originalWndProc) |
| public static void | ProcessMessages() |
| internal static nothrow void | ResetRunningModal() |
| public static int | Run(Window& mainWindow) |
| public static void | RunModal() |
| public static nothrow bool | RunningModal() |
| public static nothrow void | SetActiveWindow(Window* activeWindow_) |
| public static nothrow void | SetLogView(LogView* logView_) |
| public static nothrow void | SetMainWindow(Window* w) |
| internal static nothrow void | SetRunningModal() |
| private static Window* | activeWindow |
| private static LogView* | logView |
| private static Window* | mainWindow |
| private static ResourceManager | resourceManager |
| private static bool | runningModal |
| private static WindowManager | windowManager |