postcss
functionProcessor
classLazyResult
classResult
classWarning
classCssSyntaxError
classInput
classRoot
nodeAtRule
nodeRule
nodeDeclaration
nodeComment
nodepostcss
functionThe postcss
function is the main entry point for PostCSS.
var postcss = require('postcss');
For those using TypeScript, typings are already provided in this package. Simply, import PostCSS as you would normally.
import * as postcss from 'postcss';
postcss(plugins)
Returns a new Processor
instance that will apply plugins
as CSS processors.
postcss([autoprefixer, cssnext, cssgrace]).process(css).css;
Arguments:
plugins (array)
: list of PostCSS plugins to be included as processors.Plugins can also be included with the Processor#use
method.
See its description below for details about plugin formats.
postcss.parse(css, opts)
Parses source css
and returns a new Root
node, which contains
the source CSS nodes.
// Simple CSS concatenation with source map support
var root1 = postcss.parse(css1, { from: file1 });
var root2 = postcss.parse(css2, { from: file2 });
root1.append(root2).toResult().css;
Arguments:
css (string|#toString)
: String with input CSS or any object
with toString()
method, like a Buffer.opts (object) optional
: options:from
: the path to the source CSS file. You should always set from
,
because it is used in map generation and in syntax error messages.map
: an object of source map options.
Only map.prev
is used in parse
.postcss.plugin(name, initializer)
Creates a PostCSS plugin with a standard API.
var remove = postcss.plugin('postcss-remove', function (opts) {
opts = opts || {};
var filter = opts.prop || 'z-index';
return function (css, result) {
css.walkDecls(filter, function (decl) {
decl.remove();
});
};
});
postcss([ remove ]) // with default options
postcss([ remove({ prop: 'color' })]) // with options
Arguments:
name (string)
: PostCSS plugin name. Same as in name
property
in package.json
. It will be saved in plugin.postcssPlugin
property.initializer (function)
: will receive plugin options and should return
functions to modify nodes in input CSS.The newly-wrapped function will provide both the name and PostCSS version of the plugin:
var processor = postcss([replace]);
processor.plugins[0].postcssPlugin //=> 'postcss-replace'
processor.plugins[0].postcssVersion //=> '4.1.0'
The plugin function receives 2 arguments: Root
node and Result
instance.
The function should mutate the provided Root
node. Alternatively, you can
create a new Root
node and override the result.root
property.
var cleaner = postcss.plugin('postcss-cleaner', function () {
return function (css, result) {
result.root = postcss.root();
};
});
As a convenience, plugins also expose a process
method so that you can use
them as standalone tools.
cleaner.process(css, options);
// This is equivalent to:
postcss([ cleaner(options) ]).process(css);
Asynchronous plugins should return a Promise
instance.
postcss.plugin('postcss-import', function () {
return function (css, result) {
return new Promise(function (resolve, reject) {
fs.readFile('base.css', function (base) {
css.prepend(base);
resolve();
});
});
};
});
Add warnings using the Node#warn()
method.
postcss.plugin('postcss-caniuse-test', function () {
return function (css, result) {
css.walkDecls(function (decl) {
if ( !caniuse.support(decl.prop) ) {
decl.warn(result,
'Some browsers do not support ' + decl.prop);
}
});
};
});
Send data to other plugins using the Result#messages
array.
postcss.root(props)
Creates a new Root
node.
postcss.root({ after: '\n' }).toString() //=> "\n"
Arguments:
props (object) optional
: properties for the new root node.postcss.atRule(props)
Creates a new AtRule
node.
postcss.atRule({ name: 'charset' }).toString() //=> "@charset"
Arguments:
props (object) optional
: properties for the new at-rule node.postcss.rule(props)
Creates a new Rule
node.
postcss.rule({ selector: 'a' }).toString() //=> "a {\n}"
Arguments:
props (object) optional
: properties for the new rule node.postcss.decl(props)
Creates a new Declaration
node.
postcss.decl({ prop: 'color', value: 'black' }).toString() //=> "color: black"
Arguments:
props (object) optional
: properties for the new declaration node.postcss.comment(props)
Creates a new Comment
node.
postcss.comment({ text: 'test' }).toString() //=> "/* test */"
Arguments:
props (object) optional
: properties for the new comment node.postcss.vendor
Contains the Vendor module.
postcss.vendor.unprefixed('-moz-tab') //=> ['tab']
postcss.list
Contains the List module.
postcss.list.space('5px calc(10% + 5px)') //=> ['5px', 'calc(10% + 5px)']
postcss.stringify(node, builder)
Default function to convert a node tree into a CSS string.
Processor
classA Processor
instance contains plugins to process CSS. Create
one Processor
instance, initialize its plugins, and then use that instance
on numerous CSS files.
var processor = postcss([autoprefixer, cssnext, cssgrace]);
processor.process(css1).css;
processor.process(css2).css;
processor.use(plugin)
Adds a plugin to be used as a CSS processor.
var processor = postcss();
processor.use(autoprefixer()).use(cssnext()).use(cssgrace());
Arguments:
plugin (function|#postcss|Processor)
: PostCSS plugin. It can be in three
formats:postcss.plugin()
method.Root
node
as the first argument and current Result
instance as the second.postcss
method. PostCSS will use that method
as described in #2.Processor
instance. PostCSS will copy plugins
from that instance into this one.Plugins can also be added by passing them as arguments when creating
a postcss
instance (see postcss(plugins)
).
Asynchronous Plugins should return a Promise
instance.
processor.process(css, opts)
Parses source CSS and returns a LazyResult
instance. Because some plugins
can be asynchronous it doesn’t make any transformations. Transformations will
be applied in the LazyResult
’s methods.
processor.process(css, { from: 'a.css', to: 'a.out.css' }).then(function (result) {
console.log(result.css);
});
Arguments:
css (string|#toString|Result)
: String with input CSS or any object
with a toString()
method, like a Buffer. Optionally, send a Result
instance and the processor will take the existing [Root
] parser from it.opts (object) optional
: options:from
: the path of the CSS source file. You should always set from
,
because it is used in source map generation and syntax error messages.to
: the path where you’ll put the output CSS file. You should always set
to
to generate correct source maps.parser
: function to generate AST by string.stringifier
: class to generate string by AST.syntax
: object with parse
and stringify
functions.map
: an object of source map options.processor.plugins
Contains plugins added to this processor.
var processor = postcss([cssnext, cssgrace]);
processor.plugins.length //=> 2
processor.version
Contains the current version of PostCSS.
postcss().version //=> '4.0.5'
LazyResult
classA promise proxy for the result of PostCSS transformations.
A LazyResult
instance is returned by Processor#process(css, opts)
.
var lazy = postcss([cssnext]).process(css);
lazy.then(onFulfilled, onRejected)
Processes input CSS through synchronous and asynchronous plugins
and calls onFulfilled
with a Result
instance. If a plugin throws
an error, the onRejected
callback will be executed.
postcss([cssnext]).process(css).then(function(result) {
console.log(result.css);
});
This method is a standard Promise method.
lazy.catch(onRejected)
Processes input CSS through synchronous and asynchronous plugins
and calls onRejected
for each error thrown in any plugin.
postcss([cssnext]).process(css).then(function(result) {
console.log(result.css);
}).catch(function (error) {
console.error(error);
});
This method is a standard Promise method.
lazy.toString()
Alias for the LazyResult#css
property.
lazy.css
Processes input CSS through synchronous plugins, converts Root
to a CSS
string and returns Result#css
.
processor.process(css).css;
This property will only work with synchronous plugins. If the processor
contains any asynchronous plugins it will throw an error. In this case,
you should use LazyResult#then()
instead.
postcss([cssnext]).then(function (result) {
console.log(result.css);
});
lazy.content
An alias for the css
property. Use it with syntaxes that generate non-CSS
output.
lazy.css === lazy.content;
lazy.map
Processes input CSS through synchronous plugins and returns Result#map
.
if ( result.map ) {
fs.writeFileSync(result.opts.to + '.map', result.map.toString());
}
This property will only work with synchronous plugins. If the processor
contains any asynchronous plugins it will throw an error. In this case,
you should use LazyResult#then()
instead.
postcss([cssnext]).then(function (result) {
if ( result.map ) {
fs.writeFileSync(result.opts.to + '.map', result.map.toString());
}
});
lazy.root
Processes input CSS through synchronous plugins and returns
Result#root
.
This property will only work with synchronous plugins. If the processor
contains any asynchronous plugins it will throw an error. In this case,
you should use LazyResult#then()
instead.
postcss([cssnext]).then(function (result) {
console.log(result.root);
});
lazy.warnings()
Processes input CSS through synchronous plugins and calls [Result#warnings()
].
postcss([cssnext]).warnings().forEach(function (message) {
console.warn(message.text);
});
This property will only work with synchronous plugins. If the processor
contains any asynchronous plugins it will throw an error. In this case,
you should use LazyResult#then()
instead.
postcss([cssnext]).then(function (result) {
result.warnings().forEach(function (message) {
console.warn(message.text);
});
});
lazy.messages
Processes input CSS through synchronous plugins and returns Result#messages
.
This property will only work with synchronous plugins. If the processor
contains any asynchronous plugins it will throw an error. In this case,
you should use LazyResult#then()
instead.
lazy.processor
Returns a Processor
instance, which will be used for CSS transformations.
var lazy = postcss([cssnext, cssgrace]).process(css);
lazy.processor.plugins.length //=> 2
lazy.opts
Options from the Processor#process(css, opts)
call that produced
this Result
instance.
postcss().process(css, opts).opts == opts;
Result
classProvides the result of the PostCSS transformations.
A Result
instance is returned by Root#toResult(opts)
or LazyResult#then()
methods.
postcss([cssnext]).process(css).then(function (result1) {
console.log(result1.css);
});
var result2 = postcss.parse(css).toResult();
result.toString()
Alias for Result#css
property.
result.warn(text, opts)
Creates an instance of Warning
and adds it to Result#messages
.
var plugin = postcss.plugin('postcss-important', function () {
return function (css, result) {
css.walkDecls(function (decl) {
if ( decl.important ) {
result.warn('Try to avoid !important', { node: decl });
}
});
};
});
postcss([plugin]).process(css).then(function (result) {
result.warnings() //=> [{
// plugin: 'postcss-important-warning',
// text: 'Try to avoid !important'
// node: { type: 'decl', … }
// }]
});
Arguments:
text (string)
: warning message. It will be used in the text
property of
the message object.opts (object) optional
: properties to assign to the message object.node
: CSS node that was the source of the warning.word (string)
: word inside a node’s string that should be highlighted
as the source of the warning.index
(number): index inside a node’s string that should be highlighted
as the source of the warning.plugin
: name of the plugin that created this warning. Result#warn()
will
automatically fill it with the plugin.postcssPlugin
value.result.warnings()
Returns warnings from plugins. Filters Warning
instances
from [Result#messages].
result.warnings().forEach(function (message) {
console.log(message.toString());
});
result.css
A CSS string representing this Result
’s 'Root
instance.
postcss.parse('a{}').toResult().css //=> "a{}"
result.content
An alias for the css
property. Use it with syntaxes that generate non-CSS
output.
result.css === result.content;
result.map
An instance of the SourceMapGenerator
class from the source-map
library,
representing changes to the Result
’s Root
instance.
result.map.toJSON() //=> { version: 3, file: 'a.css', sources: ['a.css'], … }
This property will have a value only if the user does not want an inline source
map. By default, PostCSS generates inline source maps, written directly into
the processed CSS. The map
property will be empty by default.
An external source map will be generated — and assigned to map
—
only if the user has set the map.inline
option to false
, or if PostCSS
was passed an external input source map.
if ( result.map ) {
fs.writeFileSync(result.opts.to + '.map', result.map.toString());
}
result.root
Contains the Root
node after all transformations.
root.toResult().root == root;
result.messages
Contains messages from plugins (e.g., warnings or custom messages).
Each message should have type
and plugin
properties.
postcss.plugin('postcss-min-browser', function () {
return function (css, result) {
var browsers = detectMinBrowsersByCanIUse(css);
result.messages.push({
type: 'min-browser',
plugin: 'postcss-min-browser',
browsers: browsers
});
};
});
Add a warning using Result#warn()
and get all warnings
using the Result#warnings()
method.
result.processor
Returns the Processor
instance used for this transformation.
result.processor.plugins.forEach(function (plugin) {
if ( plugin.postcssPlugin == 'postcss-bad' ) {
throw 'postcss-good is incompatible with postcss-bad';
}
});
result.opts
Options from the Processor#process(css, opts)
or Root#toResult(opts)
call that produced this Result
instance.
root.toResult(opts).opts == opts;
Warning
classRepresents a plugin warning. It can be created using Node#warn()
.
if ( decl.important ) {
decl.warn(result, 'Try to avoid !important');
}
warning.toString()
Returns a string with the error position and message.
warning.toString() //=> 'postcss-important:a.css:10:4: Try to avoid !important'
warning.text
Contains the warning message.
warning.text //=> 'Try to avoid !important'
warning.plugin
Contains the name of the plugin that created this warning. When you call
Node#warn()
it will fill this property automatically.
warning.plugin //=> 'postcss-important'
warning.node
Contains the CSS node that caused the warning.
warning.node.toString() //=> 'color: white !important'
warning.line
The line in the input file with this warning’s source.
warning.line //=> 5
warning.column
Column in the input file with this warning’s source.
warning.column //=> 4
CssSyntaxError
classThe CSS parser throws this error for broken CSS.
postcss.parse('a{') //=> CssSyntaxError
Custom parsers can throw this error for broken custom syntax
using the Node#error()
method.
throw node.error('Unknown variable', { plugin: 'postcss-vars' });
error.toString()
Returns a string with the error position, message and source code of the broken part.
error.toString() //=> CssSyntaxError: app.css:1:1: Unclosed block
// a {
// ^
error.showSourceCode(color)
Returns a few lines of CSS source that caused the error.
error.showSourceCode() //=>
// a {
// bad
// ^
// }
Arguments:
color (boolean) optional
: whether arrow will be colored red by terminal
color codes. By default, PostCSS will use process.stdout.isTTY
and
process.env.NODE_DISABLE_COLORS
.If the CSS has an input source map without sourceContent
, this method will
return an empty string.
error.message
Contains full error text in the GNU error format.
error.message //=> 'a.css:1:1: Unclosed block'
error.reason
Contains only the error description.
error.reason //=> 'Unclosed block'
error.plugin
Contains the PostCSS plugin name if the error didn’t come from the CSS parser.
error.plugin //=> 'postcss-vars'
PostCSS will fill it automatically.
error.file
Contains the absolute path to the broken file. If you use it, send the from
option to the parser.
error.file //=> 'a.sass'
PostCSS will use the input source map to detect the original error location. If you wrote a Sass file, compiled it to CSS and then parsed it with PostCSS, PostCSS will show the original position in the Sass file.
If you need the position in the PostCSS input (e.g., to debug the previous
compiler), use error.input.file
.
error.file //=> 'a.sass'
error.input.file //=> 'a.css'
error.line
Contains the source line of the error.
error.line //=> 2
PostCSS will use the input source map to detect the original error location. If you wrote a Sass file, compiled it to CSS and then parsed it with PostCSS, PostCSS will show the original position in the Sass file.
If you need the position in the PostCSS input (e.g., to debug the previous
compiler), use error.input.file
.
error.line //=> 2
error.input.line //=> 4
error.column
Contains the source column of the error.
error.column //=> 1
PostCSS will use the input source map to detect the original error location. If you wrote a Sass file, compiled it to CSS and then parsed it with PostCSS, PostCSS will show the original position in the Sass file.
If you need the position in the PostCSS input (e.g., to debug the previous
compiler), use error.input.file
.
error.column //=> 1
error.input.column //=> 4
error.source
Contains the source code of the broken file.
error.source //=> 'a {} b {'
PostCSS will use the input source map to detect the original error location. If you wrote a Sass file, compiled it to CSS and then parsed it with PostCSS, PostCSS will show the original position in the Sass file.
If you need the position in the PostCSS input (e.g., to debug the previous
compiler), use error.input.file
.
error.source //=> 'a { b {} }'
error.input.column //=> 'a b { }'
Contains helpers for working with vendor prefixes.
var vendor = postcss.vendor;
vendor.prefix(string)
Returns the vendor prefix extracted from an input string.
postcss.vendor.prefix('-moz-tab-size') //=> '-moz-'
vendor.unprefixed(string)
Returns the input string stripped of its vendor prefix.
postcss.vendor.unprefixed('-moz-tab-size') //=> 'tab-size'
Contains helpers for safely splitting lists of CSS values, preserving parentheses and quotes.
var list = postcss.list;
list.space(string)
Safely splits space-separated values (such as those for background
,
border-radius
, and other shorthand properties).
postcss.list.space('1px calc(10% + 1px)') //=> ['1px', 'calc(10% + 1px)']
list.comma(string)
Safely splits comma-separated values (such as those
for transition-*
and background
properties).
postcss.list.comma('black, linear-gradient(white, black)')
//=> ['black', 'linear-gradient(white, black)']
Input
classRepresents the source CSS.
var root = postcss.parse(css, { from: file });
var input = root.source.input;
input.file
The absolute path to the CSS source file defined with the from
option.
var root = postcss.parse(css, { from: 'a.css' });
root.source.input.file //=> '/home/ai/a.css'
input.id
The unique ID of the CSS source. Used if from
option is not provided (because PostCSS does not know the file path).
var root = postcss.parse(css);
root.source.input.file //=> undefined
root.source.input.id //=> <input css 1>
input.from
The CSS source identifier. Contains input.file
if the user set
the from
option, or input.id
if they did not.
var root = postcss.parse(css, { from: 'a.css' });
root.source.input.from //=> '/home/ai/a.css'
var root = postcss.parse(css);
root.source.input.from //=> <input css 1>
input.map
Represents the input source map passed from a compilation step before PostCSS (e.g., from the Sass compiler).
map.consumer()
returns an instance of the SourceMapConsumer
class
from the source-map
library.
root.source.input.map.consumer().sources //=> ['a.sass']
input.origin(line, column)
Reads the input source map and returns a symbol position in the input source (e.g., in a Sass file that was compiled to CSS before being passed to PostCSS):
root.source.input.origin(1, 1) //=> { file: 'a.css', line: 3, column: 1 }
All node classes inherit the following common methods.
node.type
Returns a string representing the node’s type.
Possible values are root
, atrule
, rule
, decl
, or comment
.
postcss.decl({ prop: 'color', value: 'black' }).type //=> 'decl'
node.parent
Returns the node’s parent node.
root.nodes[0].parent == root;
node.source
Returns the input source of the node, with the following properties:
node.source.input
: An Input
instance.node.source.start
: The starting position of the node’s source —
line and column.node.source.end
: The ending position of the node’s source — line and column.decl.source.input.from //=> '/home/ai/a.sass'
decl.source.start //=> { line: 10, column: 2 }
decl.source.end //=> { line: 10, column: 12 }
The property is used in source map generation.
If you create a node manually (e.g., with postcss.decl()
),
that node will not have a source
property and will be absent
from the source map. For this reason, the plugin developer should consider
cloning nodes to create new ones (in which case the new node’s source
will reference the original, cloned node) or setting the source
property
manually.
// Bad
var prefixed = postcss.decl({ prop: '-moz-' + decl.prop, value: decl.value });
// Good
var prefixed = decl.clone({ prop: '-moz-' + decl.prop });
if ( atrule.name == 'add-link' ) {
var rule = postcss.rule({ selector: 'a' }); // Rule has no source
atrule.parent.insertBefore(atrule, rule); // We add it because of atrule
rule.source = atrule.source; // So we copy source from atrule
}
node.raws
Contains information to generate byte-to-byte equal node string as it was in the origin input.
Every parser saves its own properties, but the default CSS parser uses:
before
: the space symbols before the node. It also stores *
and _
symbols before the declaration (IE hack).after
: the space symbols after the last child of the node to the end of the
node.between
: the symbols between the property and value for declarations,
selector and {
for rules, or last parameter and {
for at-rules.semicolon
: contains true
if the last child has an (optional) semicolon.afterName
: the space between the at-rule’s name and its parameters.left
: the space symbols between /*
and the comment’s text.right
: the space symbols between the comment’s text and */
.important
: the content of the important statement,
if it is not just !important
.PostCSS cleans selectors, declaration values and at-rule parameters
from comments and extra spaces, but it stores origin content
in raws
properties. As such, if you don’t change a declaration’s value,
PostCSS will use the raw value with comments.
node.toString()
Returns a CSS string representing the node.
postcss.rule({ selector: 'a' }).toString() //=> 'a {}''
Arguments:
stringifier (functions|object) optional
: a syntax to use
in string generation.node.error(message, opts)
Returns a CssSyntaxError
instance containing the original position
of the node in the source, showing line and column numbers and also
a small excerpt to facilitate debugging.
If present, an input source map will be used to get the original position of the source, even from a previous compilation step (e.g., from Sass compilation).
This method produces very useful error messages.
if ( !variables[name] ) {
throw decl.error('Unknown variable ' + name, { word: name });
// CssSyntaxError: postcss-vars:a.sass:4:3: Unknown variable $black
// a
// color: $black
// ^
// background: white
}
Arguments:
message (string)
: error description.opts (object) optional
: options.plugin (string)
: plugin name that created this error.
PostCSS will set it automatically.word (string)
: a word inside a node’s string that should be highlighted
as the source of the error.index
(number): an index inside a node’s string that should be highlighted
as the source of the error.node.warn(result, text, opts)
This method is provided as a convenience wrapper for Result#warn()
.
var plugin = postcss.plugin('postcss-deprecated', function () {
return function (css, result) {
css.walkDecls('bad', function (decl) {
decl.warn(result, 'Deprecated property bad');
});
};
});
Arguments:
result
: The Result
instance that will receive the warning.text (string)
: warning message. It will be used in the text
property of
the message object.opts (object) optional
: properties to assign to the message object.word (string)
: word inside a node’s string that should be highlighted
as the source of the warning.index
(number): index inside a node’s string that should be highlighted
as the source of the warning.plugin
: name of the plugin that created this warning. Result#warn()
will
automatically fill it with the plugin.postcssPlugin
value.Note that opts.node
is automatically passed to Result#warn()
for you.
node.next()
and node.prev()
Returns the next/previous child of the node’s parent.
Returns undefined
if the current node is the last/first child.
var annotation = decl.prev();
if ( annotation.type == 'comment' ) {
readAnnotation( annotation.text );
}
node.root()
Returns the Root
instance of the node’s tree.
root.nodes[0].nodes[0].root() == root
node.remove()
Removes the node from its parent and cleans the parent
properties from the
node and its children.
if ( decl.prop.match(/^-webkit-/) ) {
decl.remove();
}
node.replaceWith(...otherNodes)
Inserts node(s) before the current node and removes the current node.
if ( atrule.name == 'mixin' ) {
atrule.replaceWith(mixinRules[atrule.params]);
}
node.clone(props)
Returns a clone of the node.
The resulting cloned node and its (cloned) children will have a clean parent
and code style properties.
var cloned = decl.clone({ prop: '-moz-' + decl.prop });
cloned.raws.before //=> undefined
cloned.parent //=> undefined
cloned.toString() //=> -moz-transform: scale(0)
Arguments:
props (object) optional
: new properties to override in the clone.node.cloneBefore(props)
and node.cloneAfter(props)
Shortcut to clone the node and insert the resulting cloned node before/after the current node.
decl.cloneBefore({ prop: '-moz-' + decl.prop });
Arguments:
props (object) optional
: new properties to override in the clone.node.moveTo(newParent)
Removes the node from its current parent and inserts it
at the end of newParent
.
This will clean the before
and after
code style properties from the node
and replace them with the indentation style of newParent
. It will also clean
the between
property if newParent
is in another Root
.
atrule.moveTo(atrule.parent.parent);
Arguments:
newParent: (Container)
: container node where the current node will be moved.node.moveBefore(otherNode)
and node.moveAfter(otherNode)
Removes the node from its current parent and inserts it into a new parent
before/after otherNode
.
This will also clean the node’s code style properties just as it would in
node.moveTo(newParent)
.
Arguments:
otherNode (Node)
: node that will be after/before current node after moving.node.raw(prop, defaultType)
Returns a code style property value. If the node is missing the code style property (because the node was manually built or cloned), PostCSS will try to autodetect the code style property by looking at other nodes in the tree.
var root = postcss.parse('a { background: white }');
root.nodes[0].append({ prop: 'color', value: 'black' });
root.nodes[0].nodes[1].raws.before //=> ' '
Arguments:
prop (string)
: name or code style property.defaultType (string)
: name of default value. It can be easily missed
if the value is the same as prop
.The Root
, AtRule
, and Rule
container nodes inherit some common methods
to help work with their children.
Note that all containers can store any content. If you write a rule inside a rule, PostCSS will parse it.
container.nodes
An array containing the container’s children.
var root = postcss.parse('a { color: black }');
root.nodes.length //=> 1
root.nodes[0].selector //=> 'a'
root.nodes[0].nodes[0].prop //=> 'color'
container.first
The container’s first child.
rule.first == rules.nodes[0];
container.last
The container’s last child.
rule.last == rule.nodes[rule.nodes.length - 1];
container.index(child)
Returns a child
’s index within the container’s nodes
array.
rule.index( rule.nodes[2] ) //=> 2
Arguments:
child (Node)
: child of the current container.container.every(callback)
Returns true
if callback
returns true for all of the container’s children.
var noPrefixes = rule.every(function (decl) {
return decl.prop[0] != '-';
});
Arguments:
callback (function)
: iterator. Returns true or false.container.some(callback)
Returns true
if callback
returns true for (at least) one
of the container’s children.
var hasPrefix = rule.some(function (decl) {
return decl.prop[0] == '-';
});
Arguments:
callback (function)
: iterator. Returns true or false.container.each(callback)
Iterates through the container’s immediate children, calling callback
for each child.
Returning false
in the callback
will break iteration.
var color;
rule.each(function (decl) {
if ( decl.prop == 'color' ) {
color = decl.value;
return false;
}
});
Arguments:
callback (function)
: iterator. Receives each node and its index.Unlike the for {}
-cycle or Array#forEach()
this iterator is safe
if you are mutating the array of child nodes during iteration.
PostCSS will adjust the current index to match the mutations.
var root = postcss.parse('a { color: black; z-index: 1 }');
var rule = root.first;
for ( var i = 0; i < rule.nodes.length; i++ ) {
var decl = rule.nodes[i];
decl.cloneBefore({ prop: '-webkit-' + decl.prop });
// Cycle will be infinite, because cloneBefore moves the current node
// to the next index
}
rule.each(function (decl) {
decl.cloneBefore({ prop: '-webkit-' + decl.prop });
// Will be executed only for color and z-index
});
container.each()
only iterates through the container’s immediate children.
If you need to recursively iterate through all the container’s descendant nodes,
use container.walk()
.
container.walk(callback)
Traverses the container’s descendant nodes, calling callback
for each node.
root.walk(function (node) {
// Traverses all descendant nodes.
});
Arguments:
callback (function)
: iterator. Receives each node and its index.Like container.each()
, this method is safe to use
if you are mutating arrays during iteration.
If you only need to iterate through the container’s immediate children,
use container.each()
.
container.walkDecls([propFilter,] callback)
Traverses the container’s descendant nodes, calling callback
for each
declaration node.
root.walkDecls(function (decl) {
if ( decl.prop.match(/^-webkit-/) ) {
decl.remove();
}
});
Arguments:
propFilter: (string|RegExp) optional
: string or regular expression
to filter declarations by property name.callback (function)
: iterator. Receives each declaration node and its
index.If you pass a propFilter
, iteration will only happen over declarations with
matching properties.
// Make a flat design
root.walkDecls('border-radius', function (decl) {
decl.remove();
});
root.walkDecls(/^background/, function (decl) {
decl.value = takeFirstColorFromGradient(decl.value);
});
Like container.each()
, this method is safe to use if you are mutating
arrays during iteration.
container.walkAtRules([nameFilter,] callback)
Traverses the container’s descendant nodes, calling callback
for each
at-rule node.
root.walkAtRules(function (rule) {
if ( rule.name.match(/^-webkit-/) ) rule.remove();
});
Arguments:
nameFilter: (string|RegExp) optional
: string or regular expression to filter
at-rules by name.callback (function)
: iterator. Receives each at-rule and its index.If you pass a filter
, iteration will only happen over at-rules that have
matching names.
var first = false;
root.walkAtRules('charset', function (rule) {
if ( !first ) {
first = true;
} else {
rule.remove();
}
});
Like container.each()
, this method is safe to use if you are mutating arrays
during iteration.
container.walkRules([selectorFilter,] callback)
Traverses the container’s descendant nodes, calling callback
for each
rule node.
var selectors = [];
root.walkRules(function (rule) {
selectors.push(rule.selector);
});
console.log('Your CSS uses ' + selectors.length + ' selectors');
Arguments:
selectorFilter: (string|RegExp) optional
: string or regular expression
to filter rules by selector.callback (function)
: iterator. Receives each rule node and its index.If you pass a selectorFilter
, iteration will only happen over rules with
matching selectors.
Like container.each()
, this method is safe to use if you are mutating arrays
during iteration.
container.walkComments(callback)
Traverses the container’s descendant nodes, calling callback
for each
comment node.
root.walkComments(function (comment) {
comment.remove();
});
Arguments:
callback (function)
: iterator. Receives each comment node and its index.Like container.each()
, this method is safe to use if you are mutating arrays
during iteration.
container.replaceValues(pattern, opts, callback)
Passes all declaration values within the container that match pattern
through
callback
, replacing those values with the returned result of callback
.
This method is useful if you are using a custom unit or function and need to iterate through all values.
root.replaceValues(/\d+rem/, { fast: 'rem' }, function (string) {
return 15 * parseInt(string) + 'px';
});
Arguments:
pattern (string|RegExp)
: replace pattern.opts (object) optional
: options to speed up the search:props
: An array of property names. The method will only search for values
that match regexp
within declarations of listed properties.fast
: A string that’s used to narrow down values and speed up
the regexp search. Searching every single value with a regexp can be slow.
If you pass a fast
string, PostCSS will first check whether the value
contains the fast
string; and only if it does will PostCSS check that
value against regexp
. For example, instead of just checking for /\d+rem/
on all values, set fast: 'rem'
to first check whether a value has
the rem
unit, and only if it does perform the regexp check.callback (function|string)
: string to replace pattern
or callback that
returns a new value. The callback will receive the same arguments as those
passed to a function parameter of String#replace
.container.prepend(...nodes)
and container.append(...nodes)
Inserts new nodes to the start/end of the container.
var decl = postcss.decl({ prop: 'color', value: 'black' });
rule.append(decl);
var decl1 = postcss.decl({ prop: 'color', value: 'black' });
var decl2 = postcss.decl({ prop: 'background-color', value: 'white' });
rule.prepend(decl1, decl2);
Arguments:
node (Node|array|object|string)
: new node.Because each node class is identifiable by unique properties, use the following shortcuts to create nodes in insert methods:
root.append({ name: 'charset', params: '"UTF-8"' }); // at-rule
root.append({ selector: 'a' }); // rule
rule.append({ prop: 'color', value: 'black' }); // declaration
rule.append({ text: 'Comment' }) // comment
A string containing the CSS of the new element can also be used. This approach is slower than the above shortcuts.
root.append('a {}');
root.first.append('color: black; z-index: 1');
container.insertBefore(oldNode, newNode)
and container.insertAfter(oldNode, newNode)
Insert newNode
before/after oldNode
within the container.
rule.insertBefore(decl, decl.clone({ prop: '-webkit-' + decl.prop }));
Arguments:
oldNode (Node|number)
: child or child’s index.node (Node|array|object|string)
: new node.container.removeChild(node)
Removes node
from the container and cleans the parent
properties from the
node and its children.
rule.nodes.length //=> 5
rule.removeChild(decl);
rule.nodes.length //=> 4
decl.parent //=> undefined
Arguments:
node (Node|number)
: child or child’s index.container.removeAll()
Removes all children from the container and cleans their parent
properties.
rule.removeAll();
rule.nodes.length //=> 0
Root
nodeRepresents a CSS file and contains all its parsed nodes.
var root = postcss.parse('a{color:black} b{z-index:2}');
root.type //=> 'root'
root.nodes.length //=> 2
root.toResult(opts)
Returns a Result
instance representing the root’s CSS.
var root1 = postcss.parse(css1, { from: 'a.css' });
var root2 = postcss.parse(css2, { from: 'b.css' });
root1.append(root2);
var result = root1.toResult({ to: 'all.css', map: true });
Arguments:
opts (object) optional
: options:to
: the path where you’ll put the output CSS file. You should always set
to
to generate correct source maps.map
: an object of source map options.AtRule
nodeRepresents an at-rule.
If it’s followed in the CSS by a {}
block, this node will have a nodes
property representing its children.
var root = postcss.parse('@charset "UTF-8"; @media print {}');
var charset = root.first;
charset.type //=> 'atrule'
charset.nodes //=> undefined
var media = root.last;
media.nodes //=> []
atrule.name
The at-rule’s name. This is the identifier that immediately follows the @
.
var root = postcss.parse('@media print {}');
var media = root.first;
media.name //=> 'media'
atrule.params
The at-rule’s parameters. These are the values that follow the at-rule’s name
but precede any {}
block. The spec refers to this area
as the at-rule’s “prelude”.
var root = postcss.parse('@media print, screen {}');
var media = root.first;
media.params //=> 'print, screen'
Rule
nodeRepresents a CSS rule: a selector followed by a declaration block.
var root = postcss.parse('a{}');
var rule = root.first;
rule.type //=> 'rule'
rule.toString() //=> 'a{}'
rule.selector
The rule’s full selector represented as a string. If there are multiple comma-separated selectors, the entire group will be included.
var root = postcss.parse('a, b { }');
var rule = root.first;
rule.selector //=> 'a, b'
rule.selectors
An array containing the rule’s individual selectors. Groups of selectors are split at commas.
var root = postcss.parse('a, b { }');
var rule = root.first;
rule.selector //=> 'a, b'
rule.selectors //=> ['a', 'b']
rule.selectors = ['a', 'strong'];
rule.selector //=> 'a, strong'
Declaration
nodeRepresents a CSS declaration.
var root = postcss.parse('a { color: black }');
var decl = root.first.first;
decl.type //=> 'decl'
decl.toString() //=> ' color: black'
declaration.prop
The declaration’s property name.
var root = postcss.parse('a { color: black }');
var decl = root.first.first;
decl.prop //=> 'color'
declaration.value
The declaration’s value.
var root = postcss.parse('a { color: black }');
var decl = root.first.first;
decl.value //=> 'black'
declaration.important
true
if the declaration has an !important
annotation.
var root = postcss.parse('a { color: black !important; color: white }');
root.first.first.important //=> true
root.first.last.important //=> undefined
Comment
nodeRepresents a comment between declarations or statements (rule and at-rules).
Comments inside selectors, at-rule parameters, or declaration values
will be stored in the Node#raws
properties explained above.
var root = postcss.parse('a { color: /* inner */ black; /* outer */ }');
var decl = root.first.first;
var comment = root.first.last;
comment.type //=> 'comment'
decl.between //=> ': /* inner */'
comment.text
The comment’s text.
var root = postcss.parse('/* Empty file */');
var comment = root.first;
var comment.text //=> 'Empty file'


---
layout: post
title: Using a Raspberry Pi with a Bus Pirate as a JTAG Dongle to Linksys BEFSR41
Router V2
date: '2015-10-10T18:03:00.002-07:00'
author: gojimmypi
tags:
modified_time: '2017-03-31T16:57:59.076-07:00'
thumbnail: https://4.bp.blogspot.com/-pLIj2bWHPAs/Vhm0hPVPHXI/AAAAAAAAAA8/AT0Y6HvhSqQ/s72-c/RPi_Bus_Pirate_to_Linksys_Success.JPG
blogger_id: tag:blogger.com,1999:blog-4109066286647243251.post-3456006003674239325
blogger_orig_url: https://gojimmypi.blogspot.com/2015/10/using-raspberry-pi-with-bus-pirate-as.html
---
I've learned quite a bit about OpenOCD, my new Bus Pirate, and JTAG during the last day or so. In short, I was able to use my Raspberry Pi to control the Bus Pirate, which in turn was connected to my old BEFSR41 Linksys Router.
For all the details, see my
PiOCD on git
Success was a cryptic text message in an SSH session:


If you wish to contact me regarding job opportunities, the best place to reach me is on LinkedIn. Please direct all professional communications there. I look forward to hearing from you!


25 Jul 2017
Bregman As Default?
Some verbose trash
For most nonlinear inverse problem, direct solution is not accessible easily, thus many people chose an iterative optimization scheme.
Suppose forward model $\mathcal{M}: (\sigma, u_g, g)\to m$ passes unknown variable coefficient $\sigma\in \mathcal{E}$, unknown solution $u_g$ and known input $g\in\mathcal{G}$ to some observable measurement $m$, where $u$ satisfies solution model constraint $F(u_g, \sigma, g) = 0$. we usually use minimization scheme: $$\min_{\sigma} J(\sigma, u_g) = \sum_{g\in\mathcal{G}} |\mathcal{M}(\sigma, u_g, g) - m|^q + \frac{\beta}{2}|\sigma|_{p}$$
values for $p,q$ are found everywhere, common choices for regularization is TV or $L_1, L_2$.
When $q=2$, adjoint method is often used to reduce computational cost, ignoring $g$ for each input,
$$\frac{\partial |\mathcal{M}(\sigma,u) - m|^2}{\partial \sigma} (\delta \sigma)=2( \frac{\partial \mathcal{M}}{\partial \sigma}(\delta \sigma))^t(\mathcal{M}(\sigma,u) - m)$$ and $$\frac{\partial \mathcal{M}(\sigma, u)}{\partial \sigma}(\delta \sigma) = \mathcal{M}_{\sigma}\delta\sigma + \mathcal{M}_{u}\frac{\partial u}{\partial \sigma}(\delta \sigma)$$
we need to resolve $\frac{\partial u}{\partial \sigma}$ which is reduced from solution model that $$F_u \frac{\partial u}{\partial \sigma}(\delta \sigma) + F_{\sigma}(\delta\sigma) = 0$$
so we have $$\frac{\partial \mathcal{M}(\sigma, u)}{\partial \sigma}(\delta \sigma) = \mathcal{M}_{\sigma}\delta\sigma + \mathcal{M}_u F_u^{-1} F_{\sigma}(\delta\sigma)$$
The $F^{-1}_u$ is some solution operator, we take adjoint, then we only need solve $$(F_{\sigma}(\delta\sigma))^t F_u^{-t} \mathcal{M}_u^t (\mathcal{M}(\sigma, u) - m)$$
Now, for each iteration, we need to evaluate operations, mostly matrix-vector multiplications.
$$\mathcal{M}_u^t(y), F_u^{-t}(y), F_{\sigma}(y), F^{-1}(y)$$
For linear operators, we have $F_u = F$, but $F_{\sigma}$ has to be calculated separately, for large system, $F^{-1}$ is nontrivial to update fast.
This is the unconstrained version. This version of numerical implementation has to calculate exact solutions to $F$ multiple times $O(1)$.
In order to quantify the cost, we consider following model of time cost.
- $t_{mv}$ is sparse matrix-vector multiplication time.
- $t_{sv}$ is the inversion time.
- $t_{pre}$ is precomputing time for
mv
orsv
. - $t_{set}$ is total intrinsic setting time for all operators, which is minimal.
Total time for each iteration will be: $t_{set} + t_{pre} + 2t_{sv} + (n+1)t_{mv}$. When the operators are sparse (local), then $t_{mv} = O(n)$, $t_{sv} = O(n)$, but mostly ill-conditioned, preconditioner is needed, total is $O(n^2)$. In this case, it is not optimal to use the low rank compression here due to high overhead in $t_{pre}$.
If $F$ is integral equation, then system is dense. $F_u^{-1}$ or $F^{-1}$ is not cheap to calculate in practice, iterative method might be utilized for such problems, in such case, low rank method can kick in.
Then we look at constrained version. Optimization problem is $$\min_{\sigma, u_g} J(\sigma, u_g) = \sum_{g\in\mathcal{G}} |\mathcal{M}(\sigma, u_g, g) - m|^q + \frac{\beta}{2}|\sigma|_{p}$$ subject to $$F(u_g, \sigma, g) = 0.$$
The Lagrangian multiplier method gives $$\min_{\sigma, u_g, \lambda}L(\sigma, u_g, \lambda_g) = J(\sigma, u_g) - \sum_g\lambda_g F_g$$
The KKT conditon says $$J_{\sigma} = \sum_g \lambda_g F_{g,\sigma},\quad J_{u_g} = \sum_{g}\lambda_g F_{g, u_g}$$
To solve the problem, we use some penalty term in addition to get AL
as
$$L_{aug}(\sigma, u_g, \lambda_g, \mu) = J(\sigma, u_g) - \sum_{g}\lambda_g F_g + \frac{\mu}{2}|F(u_g,\sigma, g)|^2$$
Then KKT condition implies at $k$-th iteration,
$$J_{\sigma} -(\sum_g\lambda^k_g - \mu^k F)F_{g,\sigma} = 0 ,\quad J_{u_g} -(\sum_g\lambda^k_g - \mu^k F)F_{u_g,\sigma} = 0 $$
which implies that near optimal, we have $$\lambda_g^{\ast} = \lambda^{k}_g - \mu^k F_g.$$ giving equivalent Bregman iteration as $$\lambda_g^{k+1} = \lambda^{k}_g - \mu^k F_g.$$
Bregman is faster ?
No matter what method, one problem is in common, we need to solve sub-problem of finding $(\sigma^k, u_g^k)$ each time.
In unconstrained case, $u_g$ must be solution of $F$. In Bregman, it is not. The problem is unconstrained, variables will increase to $O(n + N)$, where $n$ is unknowns of $\sigma$ and $N$ is unknowns of $u_g$.
Let's put everything into Bregman's frame, set $u = (\sigma, u_g)$ and $J(u)$ defined in previous part is convex in $u$ and penalty term is $$H(u) = \frac{\mu}{2}|F(u, g)|^2$$
We are solving $$\min_u {J(u) + H(u)}$$
with Bregman distance $D^p_J(u, v) = J(u) - J(v) - \langle p , u-v\rangle$,the iteration is given by
- $u^{k+1} = \arg\min_{u} D_J^{p^k}(u , u^k) + H(u)$
- $p^{k+1} = p^k - \nabla H(u^{k+1})\in \partial J(u^{k+1})$
- update $\mu$.
So what is the complexity in each iteration? In first update, we solve a minimization problem by BFGS/Newton. This problem is not easier than original problem at all. But adding $\mu$ makes the system less ill-conditioned, so finding a solution needs less iterations, while total iteration number might be large.


BY EDWIN JAHIEL
MAD CITY *** 1/4. Directed by Constantin Costa-Gavras. Written by Tom Matthews, based on a story by Matthews and Eric Williams.Photography, Patrick Blossier.Editing, Francoise Bonnot. Production design, Catherine Hardwicke. Music,Thomas Newman. Produced by Arnold Kopelson and Anne Kopelson. Cast: Dustin Hoffman (Max Brackett), John Travolta (Sam Baily), Alan Alda (Hollander), Mia Kirshner (Laurie), William Atherton (Dohlen), Blythe Danner (Mrs. Banks) Bill Nunn (museum guard) et al. A Warners release. 114 min PG-13
Director Costa-Gavras was born in Greece. His correct name is Konstatinos (Constantine), or Kostas for short, Gavras ("gah-VRASS). It was hyphenated by the French.
Few people today are aware that the Cold War began right at the end of World War II, in Greece, as a civil war between Communist partisans and the Royalist regime.
Gavras's father was a modest government employee. He was suspected of leftist affiliations and suffered for it. The discrimination extended to the young Costas. Denied rights like a driving permit or entrance to Athens University, he went to Paris at age 16 or 17, studied literature at the Sorbonne, later film-making, then became assistant director to several major directors. His first film, a crime thriller, was a hit. In 1968, Gavras became a French citizen, made his third film, the multi-prized "Z" that was hailed as the first big, French political picture. There followed more, impressive political thrillers.
Gavras was on to a fresh film formula. He was the first to combine the vigorous, American style with European political sensibility. The movies were major successes, won great awards. All were taken from real events, each antagonized a different political regimes. "Z," on the assassination of a leftist Greek leader by the forces of the right, riled the military junta that was to rule Greece for seven years - even though the murder had preceded the colonels' putsch."The Confession" dealt with political kangaroo trials within Communist Czechoslovakia. It infuriated much of the Left. "State of Siege" set in Uruguay (but filmed in democratic Chile just before Allende's fall) took on the CIA and political torture. It displeased many in the USA. "Special Section"'s denouncing of French tribunals under the German Occupation, and French judges as toadying collaborators, made many French legal professionals see red.
Then began Gavras's US-period. "Missing" (Cannes festival top prize) dealt with mass slaughter, the killing of a young American in Pinochet's Chile, and the inanity of State Department representatives. "Hanna K" attempted a "rapprochement" between Arabs and Jews, was accused of being pro-Palestinian. It had a short life in American theaters. The flawed but gripping "Betrayed" denounced white supremacists was followed by "Music Box," on wartime criminals harbored in the USA.
The better Gavras films are fascinating. The man has no fixed or partisan ideology, yet the same strain runs through his movies: attacking the abuse of power of any sort. In "Mad City," that principle still applies, since the media, led by television, wield amazing influence and often abuse it for sensationalism, ratings and ego-boosting.
The story is one of headlines. Max Brackett (Hoffman) a star investigative TV reporter for the CTN network, had rubbed the wrong way the powerful, self-serving and jealous CTN star anchor Hollander (Alda), and had been exiled to an affiliate in a small California city. Max, chafing at the bit because his station's manager will not allow him to do big exposes without proofs, is sent to report on a local museum, now in financial straits. This turns into manna from Heaven for sensation-seeking Max. Now is his chance for a scoop that will put him back on top.
As he interviews museum director Mrs. Banks (Danner), the haughty scion of the founders, there bursts in Sam Baily (Travolta). He is a poor blue-collar slob who was dismissed as a guard. He is armed with a rifle and dynamite, not intending to use them, but for getting Mrs. Banks' attention and plead for reinstatement. The man is clearly slow-witted and, at least temporarily, highly deranged.
Accidentally, Sam discharges his gun and hits the remaining guard, Williams, who is black and was Sam's buddy.  He treats them with friendliness. The crisis grows instantly into a media-circus with crowds, reporters, cops (and a headline-seeking police chief), firemen, flashing lights, street vendors...
Connoisseurs realize that "Mad City"'s writers knew Billy Wilder's "The Big Carnival," (1951), originally titled "Ace in the Hole." Kirk Douglas played an opportunistic big-city reporter who sees his chance at winning fame (the Ace) by exploiting cynically a man in New Mexico buried by a cave-in (in a Hole). The event becomes a media circus (the Carnival). Is it an accident that Dustin Hoffman is named Max Brackett? Wilder's longtime writer was Charles Brackett.
Other inspirations include "The Front Page" (remade as "His Girl Friday); "Dog Day Afternoon" where a robbery by Dustin Hoffman blows out of proportions; and various exposes of the TV business (e.g."Network").
The madness continues in broad yet believable lines. Press people, a la paparazzi, pursue Williams to his hospital bed or film him with from a scaffolding outside his window. A black reporter insinuates to Mrs.Williams that racism was involved. A bystander harangues the crowd on Waco, Ruby Ridge, and people (read "whites") losing jobs through racial quotas.
We've come a long way since "Z," where the press actually helped the Good Guys. Yet traces of decency remain. Max's initial reaction is only to exploit the incident, but soon he becomes the advisor-mentor of helpless Sam. He coaches, then interviews him on camera, trying to show the good, human side of the man. He also becomes his intermediary and, yes, his friend, as he walks a tightrope between getting the story and doing the best he can for Sam.
Played superbly and coolly by Hoffman, he is a canny, intelligent pro, knows the trade by heart, even anticipates the media's and the FBI's moves. Caught between several fires, he maneuvers very well --until, that is, slimy anchor Hollander shows up to steal the show. The two men's relationship and power struggles are convincingly depicted.
Inevitably, Gavras makes the movie "a l'americaine," with strokes bolder--and slicker perhaps--than in an European psychological thriller. This does not hurt, although Travolta is so well in control of his crazed sad sack characterization that it gets theatrical at times. The technical credits are very good. Photography is by Frenchman Patrick Blossier ("Vagabond," "Betrayed," "Music Box"). Editing is by Frenchwoman Francoise Bonnot who has often worked brilliantly with Gavras, starting with "Z" for which she received an Oscar. She also won the UK's BAFTA Award.
Then there's the character of Laurie (Kirshner), a pretty, young TV intern, who was delighted to be assigned to Max for the museum reportage. She looked at him so adoringly that to avoid entanglements he quipped "I'm gay." But soon starry-eyed Laurie symbolizes the future of TV. When Hollander appears, the sweet young thing ceases to be Max's Girl Friday and switches camps. By implication she would do anything to climb the ladder. There are no fealties in the business.
The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


Statistics::TheilSen - Perl implementation of Theil Sen Estimator
Version 0.05
This is a perl implementation of the Theil Sen Estimator, which is a method of linear regression that uses medians. All of the gradients of the lines between all points are calculated, and hte median is the one reported. Sounds trivial. If you have 1000s of points, then you have millions of lines, and sort-based median methods can take ages, so Statistics::TheilSen uses the partition-based Statistics::QuickMedian.
# OOP...
use Statistics::TheilSenEstimator;
my $tse = Statistics::TheilSenEstimator->new(\$y_values, \$x_values);
# which is really a shortcut for:
my $tse = Statistics::TheilSenEstimator->new();
$tse->addData(\@y_values, \@x_values); # listrefs of numeric scalars
my $status_line = $tse->run(); # might tell if you had bad values, etc
print "y = ", $tse->m(), "x + ", $tse->c(); # y = mx + c
# or procedural...
use Statistics::TheilSenEstimator qw/theilsen/;
my ($m,$c) = theilsen(\@y_values, \@x_values);
Accepts two list refs, the lists should be the same length. They represent y and x series which will be the subject of the regression. Returns a list of two
use Statistics::TheilSenEstimator qw/theilsen/;
my ($m,$b) = theilsen(\$y_values, \$x_values);
use Statistics::TheilSenEstimator;
my $tse = Statistics::TheilSenEstimator->new();
#or
my $tse = Statistics::TheilSenEstimator->new(\@y_values, \@x_values);
returns a new Statistics::TheilSenEstimator estimator object with the optional data added.
$tse->addData(\@y_values, \@x_values);
Adds data to the y and x series. Data series should be the same length.
my $status_line = $tse->run();
Runs the estimator on the data currently in the object. Returns any messages about whether errors or weird things were found in the data. Sets m and c in the object
my $gradient = $tse->m();
Returns "m", the gradient of the model generated by run(). If run() was not called since addData(), then run() will be called here!
my $intersect = $tse->c();
Returns "c", the intersect of the model generated by run(). If run() was not called since addData(), then run() will be called here!
Jimi Wills, <jimi at webu.co.uk>
Please report any bugs or feature requests to
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Statistics-TheilSen. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.bug-statistics-theilsen at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Statistics::TheilSenEstimator
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Statistics-TheilSenEstimator
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
http://en.wikipedia.org/wiki/Theil%E2%80%93Sen_estimator
Copyright 2013 Jimi Wills.
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
http://www.perlfoundation.org/artistic_license_2_0
Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.
If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.
This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.
This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.  UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Please complete the following exercises on this page. When complete post this page to your server. Make a link in your WDV221 homework page for this assignment.
Include a comment in each script with the exercise number and a description of what the script is supposed to do.
Using Blackboard submit this Assignment.
Use the form fields for the input values. For each of the following exercises create a function what will be activated by the button.


None
Resolved Issues:
A carefully crafted FITS filename could be used by an attacker to execute arbitrary Javascript. If, for example, the following FITS file is loaded into JS9:
JS9.Load("<svg onmouseover=alert(1)>.fits")then moving the mouse over the Statusbar plugin (where the image id is displayed) will result in the alert being triggered. Similarly, setting the id explicitly:
JS9.Load("foo.fits", {"id": "<svg onmouseover=alert(1)>.fits"})will trigger the alert. This vulnerability is present in any plugin displaying the image id or filename (e.g., the Blend and Blink plugins).
As of v3.2 (and the GitHub repository as of 10/28/2020), a check is performed to sense dangerous strings in filenames and ids, and throw an error. Patched versions of js9.js and js9.min.js for v3.1 are available:
Thanks to Marwan Ali albahar (Umm Alqura University) for reporting this issue.


类 LinearRegression
- java.lang.Object
-
- edu.princeton.cs.algs4.LinearRegression
-
public class LinearRegression extends java.lang.Object
TheLinearRegression
class performs a simple linear regression on an set of n data points (yi, xi). That is, it fits a straight line y = α + β x, (where y is the response variable, x is the predictor variable, α is the y-intercept, and β is the slope) that minimizes the sum of squared residuals of the linear regression model. It also computes associated statistics, including the coefficient of determination R2 and the standard deviation of the estimates for the slope and y-intercept.
-
-
构造器概要
构造器 构造器 说明 LinearRegression(double[] x, double[] y)
Performs a linear regression on the data points(y[i], x[i])
.
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 double
intercept()
Returns the y-intercept α of the best of the best-fit line y = α + β x.double
interceptStdErr()
Returns the standard error of the estimate for the intercept.double
predict(double x)
Returns the expected responsey
given the value of the predictor variablex
.double
R2()
Returns the coefficient of determination R2.double
slope()
Returns the slope β of the best of the best-fit line y = α + β x.double
slopeStdErr()
Returns the standard error of the estimate for the slope.java.lang.String
toString()
Returns a string representation of the simple linear regression model.
-
-
-
构造器详细资料
-
LinearRegression
public LinearRegression(double[] x, double[] y)
Performs a linear regression on the data points(y[i], x[i])
.- 参数:
x
- the values of the predictor variabley
- the corresponding values of the response variable- 抛出:
java.lang.IllegalArgumentException
- if the lengths of the two arrays are not equal
-
-
方法详细资料
-
intercept
public double intercept()
Returns the y-intercept α of the best of the best-fit line y = α + β x.- 返回:
- the y-intercept α of the best-fit line y = α + β x
-
interceptStdErr
public double interceptStdErr()
Returns the standard error of the estimate for the intercept.- 返回:
- the standard error of the estimate for the intercept
-
predict
public double predict(double x)
Returns the expected responsey
given the value of the predictor variablex
.- 参数:
x
- the value of the predictor variable- 返回:
- the expected response
y
given the value of the predictor variablex
-
R2
public double R2()
Returns the coefficient of determination R2.- 返回:
- the coefficient of determination R2, which is a real number between 0 and 1
-
slope
public double slope()
Returns the slope β of the best of the best-fit line y = α + β x.- 返回:
- the slope β of the best-fit line y = α + β x
-
slopeStdErr
public double slopeStdErr()
Returns the standard error of the estimate for the slope.- 返回:
- the standard error of the estimate for the slope
-
toString
public java.lang.String toString()
Returns a string representation of the simple linear regression model.- 覆盖:
toString
在类中java.lang.Object
- 返回:
- a string representation of the simple linear regression model, including the best-fit line and the coefficient of determination R2
-
-


| as.raster {grDevices} | R Documentation |
Functions to create a raster object (representing a bitmap image) and coerce other objects to a raster object.
is.raster(x) as.raster(x, ...) ## S3 method for class 'matrix' as.raster(x, max = 1, ...) ## S3 method for class 'array' as.raster(x, max = 1, ...) ## S3 method for class 'logical' as.raster(x, max = 1, ...) ## S3 method for class 'numeric' as.raster(x, max = 1, ...) ## S3 method for class 'character' as.raster(x, max = 1, ...) ## S3 method for class 'raw' as.raster(x, max = 255L, ...)
x |
any R object. |
max |
number giving the maximum of the color values range. |
... |
further arguments passed to or from other methods. |
An object of class "raster"
is a matrix of colour values as
given by rgb
representing a bitmap image.
It is not expected that the user will need to call these functions
directly; functions to render bitmap images in graphics packages will
make use of the as.raster()
function to generate a raster
object from their input.
The as.raster()
function is (S3) generic so methods can be
written to convert other R objects to a raster object.
The default implementation for numeric matrices interprets scalar values on black-to-white scale.
Raster objects can be subsetted like a matrix and it is possible to assign to a subset of a raster object.
There is a method for converting a raster object to a
matrix
(of colour strings).
Raster objects can be compared for equality or inequality (with each other or with a colour string).
There is a is.na
method which returns a logical matrix
of the same dimensions as the raster object. Note that NA
values are interpreted as the fully transparent colour by some (but
not all) graphics devices.
For as.raster()
, a raster object.
For is.raster()
, a logical indicating whether
x
is a raster object.
Raster images are internally represented row-first, which can cause confusion when trying to manipulate a raster object. The recommended approach is to coerce a raster to a matrix, perform the manipulation, then convert back to a raster.
# A red gradient as.raster(matrix(hcl(0, 80, seq(50, 80, 10)), nrow = 4, ncol = 5)) # Vectors are 1-column matrices ... # character vectors are color names ... as.raster(hcl(0, 80, seq(50, 80, 10))) # numeric vectors are greyscale ... as.raster(1:5, max = 5) # logical vectors are black and white ... as.raster(1:10 %% 2 == 0) # ... unless nrow/ncol are supplied ... as.raster(1:10 %% 2 == 0, nrow = 1) # Matrix can also be logical or numeric (or raw) ... as.raster(matrix(c(TRUE, FALSE), nrow = 3, ncol = 2)) as.raster(matrix(1:3/4, nrow = 3, ncol = 4)) # An array can be 3-plane numeric (R, G, B planes) ... as.raster(array(c(0:1, rep(0.5, 4)), c(2, 1, 3))) # ... or 4-plane numeric (R, G, B, A planes) as.raster(array(c(0:1, rep(0.5, 6)), c(2, 1, 4))) # subsetting r <- as.raster(matrix(colors()[1:100], ncol = 10)) r[, 2] r[2:4, 2:5] # assigning to subset r[2:4, 2:5] <- "white" # comparison r == "white"


that Node server.
below to get it started up.
You should see some output like the following:
node process id: 5376
Attempting connection to the class server at <IP_ADDRESS>:11111
RemoteClassLoaderConnection: Reconnected to the class server
JPPF Node management initialized
Attempting connection to the node server at <IP_ADDRESS>:11111
Reconnected to the node server
Node successfully initialized
You should see some output like the following:
node process id: 5376
Attempting connection to the class server at <IP_ADDRESS>:11111
RemoteClassLoaderConnection: Reconnected to the class server
JPPF Node management initialized
Attempting connection to the node server at <IP_ADDRESS>:11111
Reconnected to the node server
Node successfully initialized
and ready to contribute!


MECHA is an explicit cross-section model of the root hydraulic anatomy which connects hydraulic concepts across scales.
The model computes horizontal water flow at the level of individual cells, quantifies the contribution of water composite pathways, and predicts root radial permeability (kr), using detailed anatomical descriptions and experimental data on the permeability of cell walls (kw), membranes (Lp) and the conductance of individual plasmodesmata (KPD).
MECHA was coded in Python, and is therefore platform independant. It can be run on Windows, Linux and MacOS
The source code of MECHA is available on github: https://github.com/MECHARoot/MECHA
The github repo also contain example parameter files needed to run MECHA. You do not need your own data to try it out.
The first step before running MECH is to install a working version for Python. Installation of Python are available here: https://www.python.org/downloads/
MECHA is built upon a handfull of external libraries. You will need to install them before using the model.
numpy
scipy
networkx
lxml
These libraries can be install using pip. In the Terminal or Console, enter:
pip install numpy pip install scipy pip install networkx==1.9.1 pip install lxml pip install matplotlib
In the Terminal or Console enter the following lines:
cd "$PATH_TO_FOLDER_CONTAINING_MECHA" python mecha_all.py
MECHA uses four parameters files as input, stored in the /in
folder in the main MECHA directory:
General.xml
: General simulation parametersBC.xml
: Boundary conditions for the simulation. This is where you choose wether the soil is dry, wet, or only partially touch the root.Geometry.xml
: Parameters for the root section geometry. This is where you define which root section to use in the simulation.Hydraulics.xml
: Hydraulic parameters of the different variables in the simulation
MECHA output files in a folder defined in the General.xml
input file, under the Output
tag. Different type of files are generated:
*.PVTK files
: These are geometry files that can be open in Paraview Macro_prop_i.txt files
: Theses files contain synthetic informations about the simulation results. They contain the radial data.MECHA was developed at the Université catholique de Louvain, in the Earth and Life Insititute, in the lab of Xavier Draye. The primary developpers of the model are Valentin Couvreur and Marc Faget.
MECHA what first used here:
Going with the flow. Multiscale insights into the composite nature of water transport in roots Valentin Couvreur, Marc Faget, Guillaume Lobet, Mathieu Javaux, François Chaumont and Xavier Draye
Plant Physiology, 2018
MECHA was then re-use in other research study, such as:
Connecting the dots between computational tools to analyse soil–root water relations Sixtine Passot, Valentin Couvreur, Félicien Meunier, Xavier Draye, Mathieu Javaux, Daniel Leitner, Loïc Pagès, Andrea Schnepf, Jan Vanderborght, Guillaume Lobet
Journal of Experimental Botany, 2019


What is bootstrap.
Bootstr p is open-source html,css and javaaScript code to design the front-end. By using this technology we can create a responsive web pages.
ID
Branch
Year
Course Name
2
IT
4
B.tect
3
IT
4
B.tect
4
IT
3
B.sc


class: center, middle, inverse, title-slide # ETC1010: Data Modelling and Computing ## Lecture 5: Plotting your data ### Di Cook (
<EMAIL_ADDRESS>,
@visnut
) ### Week 5 --- # Overview - Grammar of graphics + Chloropleth Maps + Networks + Multivariate plots --- # Maps - Maps are basically point data sets, with lines connecting dots in special order, and groups, yielding polygons defining geographic regions - To fill polygons with colour corresponding to a variable, requires joining map data with data table - Geographic regions often have multiple names, which may not match in the different tables --- # OECD PISA data - About 500,000 students - Approx 20,000 schools - Around 70 countries tested every 3 years on reading, writing and science. - Nearly 1000 variables collected on each student, and more on parents and schools --- # Gender gap - We often hear in the news that boys perform better than girls in math - Examine this by taking the PISA scores, compute the average for boys and girls, and difference these for each country. The calculations use a weighted mean, because each student in the study has a sampling weight associated with them, indicating how representative they are of their demographic in the country. --- # Display means  --- # Country labels Original labels for countries are the three letter code: ``` > scores # A tibble: 514,397 x 6 CNT ST004D01T PV1MATH PV1READ PV1SCIE SENWT <chr> <dbl> <dbl> <dbl> <dbl> <dbl> 1 ALB 1 462.940 429.846 517.092 2.181 2 ALB 1 430.100 462.788 479.635 2.181 3 ALB 1 302.612 503.169 446.930 2.181 ``` --- # Map The maps ofetn have actual country names as the labels for each geographic polygon: ``` long lat group order region subregion 1 -69.89912 12.45200 1 1 Aruba <NA> 2 -69.89571 12.42300 1 2 Aruba <NA> 3 -69.94219 12.43853 1 3 Aruba <NA> 4 -70.00415 12.50049 1 4 Aruba <NA> 5 -70.06612 12.54697 1 5 Aruba <NA> 6 -70.05088 12.59707 1 6 Aruba <NA> ``` --- # ISO data base ```r library(ISOcodes) data("ISO_3166_1") ISO_3166_1 %>% select(Alpha_3, Name) %>% head() Alpha_3 Name 1 ABW Aruba 2 AFG Afghanistan 3 AGO Angola 4 AIA Anguilla 5 ALA Åland Islands 6 ALB Albania ``` --- # Join the PISA and ISO codes ```r scores <- tb %>% select(CNT, ST004D01T, PV1MATH, PV1READ, PV1SCIE, SENWT) %>% collect() scores <- scores %>% mutate(CNT=recode(CNT, "QES"="ESP", "QCH"="CHN", "QAR"="ARG", "TAP"="TWN")) %>% filter(CNT != "QUC") %>% filter(CNT != "QUD") %>% filter(CNT != "QUE") countries <- scores %>% left_join(ISO_3166_1, by=c("CNT"="Alpha_3")) countries$Name[countries$CNT == "KSV"] <- "Kosovo" ``` ``` > countries # A tibble: 514,397 x 7 CNT ST004D01T PV1MATH PV1READ PV1SCIE SENWT Name <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <chr> 1 ALB 1 462.940 429.846 517.092 2.181 Albania 2 ALB 1 430.100 462.788 479.635 2.181 Albania 3 ALB 1 302.612 503.169 446.930 2.181 Albania 4 ALB 1 336.522 569.626 383.794 2.181 Albania 5 ALB 1 290.929 389.138 412.304 2.181 Albania ``` --- # Still some mismatches In the PISA data: ```r pisa_gap <- pisa_gap %>% mutate(Name = recode(Name, "Czechia"="Czech Republic", "Korea, Republic of"="South Korea", "Macedonia, Republic of"="Macedonia", "Moldova, Republic of"="Moldova", "Russian Federation"="Russia", "Taiwan, Province of China"="Taiwan", "Trinidad and Tobago"="Trinidad", "United States"="USA", "United Kingdom"="UK", "Viet Nam"="Vietnam")) ``` In the map data: ```r world_map$region[world_map$subregion == "Hong Kong"] <- "Hong Kong" world_map$region[world_map$subregion == "Macao"] <- "Macao" ``` Now join: ```r to_map <- left_join(world_map, pisa_gap, by=c("region"="Name")) ``` --- # Map it! ```r ggplot(to_map, aes(map_id = region)) + geom_map(aes(fill=wmathgap), map = world_map, color="grey70", size=0.1) + scale_fill_gradient2("Math gap", limits=c(-35, 35), na.value="grey99", low="#1B9E77", high="#D95F02", mid="white") + expand_limits(x = world_map$long, y = world_map$lat) + theme_few() + theme(legend.position = "bottom", legend.key.width=unit(1.5, "cm"), axis.ticks = element_blank(), axis.title = element_blank(), axis.text = element_blank()) ``` ---  --- # Networks Network data arises in many settings, e.g. study of communities, biological pathways, ... Typically the data is provided in two related tables, nodes and edges. Both may have additional attributes. Here's an example from the TV series Madmen. The nodes data contains the actors in the series, and the edges contains pairs of actors that had romantic relationships. ``` List of 2 $ edges :'data.frame': 39 obs. of 2 variables: ..$ Name1: Factor w/ 9 levels "Betty Draper",..: 1 1 2 2 2 2 2 2 2 2 ... ..$ Name2: Factor w/ 39 levels "Abe Drexler",..: 15 31 2 4 5 6 8 9 11 21 ... $ vertices:'data.frame': 45 obs. of 2 variables: ..$ label : Factor w/ 45 levels "Abe Drexler",..: 5 9 16 23 26 32 33 38 39 17 ... ..$ Gender: Factor w/ 2 levels "female","male": 1 2 2 1 2 1 2 2 2 2 ... ``` --- # Generate a network view - Create a layout (in 2D) which places nodes which are most related close, - Plot the nodes as points, connect the appropriate lines - Overlaying other aspects, e.g. gender  --- # American college football ```r glimpse(football) List of 2 $ edges :'data.frame': 613 obs. of 3 variables: ..$ from : chr [1:613] "BrighamYoung" "Iowa" "BrighamYoung" "NewMexico" ... ..$ to : chr [1:613] "FloridaState" "KansasState" "NewMexico" "TexasTech" ... ..$ same.conf: num [1:613] 0 0 1 0 1 1 0 1 0 1 ... $ vertices:'data.frame': 115 obs. of 2 variables: ..$ label: chr [1:115] "BrighamYoung" "FloridaState" "Iowa" "KansasState" ... ..$ value: chr [1:115] "Mountain West" "Atlantic Coast" "Big Ten" "Big Twelve" ... ``` ---  --- # Harry Potter characters There is a connection between two students if one provides emotional support to the other at some point in the book. Code to pull the data together is provided by Sam Tyner [here](https://github.com/sctyner/geomnet/blob/master/README.Rmd#harry-potter-peer-support-network). ```r load("data/hpchars.rda") load("data/hpedges.rda") head(hp.chars) name schoolyear gender house 1 Adrian Pucey 1989 M Slytherin 2 Alicia Spinnet 1989 F Gryffindor 3 Angelina Johnson 1989 F Gryffindor 4 Anthony Goldstein 1991 M Ravenclaw 5 Blaise Zabini 1991 M Slytherin 6 C. Warrington 1989 M Slytherin head(hp.edges) name1 name2 book 1 Dean Thomas Harry James Potter 1 2 Dean Thomas Hermione Granger 1 3 Dean Thomas Neville Longbottom 1 4 Dean Thomas Ronald Weasley 1 5 Dean Thomas Seamus Finnigan 1 6 Fred Weasley George Weasley 1 ``` ---  --- # Getting beyond 2D - Pairs of variables in a matrix layout: pairs plots or scatterplot matrix - Parallel axes instead of orthogonal axes --- # Pairs plots  --- # All variables are numeric  --- # Parallel coordinate plot  --- # Resources - Tyner, Briatte, Hofmann (2015) [Network Visualization with ggplot2](http://rjournal.github.io/archive/2017-1/RJ-2017-1.pdf) - Pairs plots, parallel coordinate plots, and [methods for high-d data](http://ggobi.org/book/index.html) --- class: inverse middle # Share and share alike
This work is licensed under a Creative Commons Attribution 4.0 International License.


|
Processor Counter Monitor
|
Public Member Functions | |
| HTTPConnection (HTTPServer *hs, int socketFD, struct sockaddr_in clientAddr, std::vector< http_callback > const &cl) | |
| HTTPConnection (HTTPConnection const &)=delete | |
| void | operator= (HTTPConnection const &)=delete |
| void | close () |
| virtual void | execute () override |


Loading...
Thank you for your patience, loading your results is taking longer than usual.
No People Loaded.
| Photo | First Name | Last Name | Address | Age | Interests |
|---|---|---|---|---|---|
| ${ person.firstName } | ${ person.lastName } | ${ person.address } | ${ person.age } | ${ formatInterests(person.interestSet) } |


0 scripts selected
Get Code
After sharing your Scratch program, copy and paste the URL in the textbox above. Press the Return/Enter key to get your code!


Successfully Added
Your First Name , Surname , Gender , Age and Degree have been successfully added to the System.
Thank You For Your Time
Home
Sign Up


| Package | Description |
|---|---|
| org.apache.chemistry.opencmis.server.support.query |
| Class and Description |
|---|
| CmisSelector |
| ColumnReference |
| FunctionReference.CmisQlFunction |
| PredicateWalker
Interface for a tree walker of a WHERE clause.
|
| PredicateWalkerBase
Base interface for a tree walker of a WHERE clause.
|
| QueryObject
QueryObject is a class used to encapsulate a CMIS query.
|
| QueryObject.JoinSpec |
| QueryObject.SortSpec |
| QueryUtilBase
Utility class to help parsing and processing a query statement using the
AntLR parser Subclasses have to implement methods that setup parser and query
walker and parse and process a query.
|
Copyright © 2009–2016 The Apache Software Foundation. All rights reserved.


--- layout: docpage title: "Documentation" is_homepage: false is_sphinx_doc: true doc-parent: "Getting Started" doc-title: "Installing Cassandra" doc-header-links: ' ' doc-search-path: "../search.html" extra-footer: ' ' ---
These are the instructions for deploying the supported releases of Apache Cassandra on Linux servers.
Cassandra runs on a wide array of Linux distributions including (but not limited to):
This is not an exhaustive list of operating system platforms, nor is it prescriptive. However users will be well-advised to conduct exhaustive tests of their own particularly for less-popular distributions of Linux. Deploying on older versions is not recommended unless you have previous experience with the older distribution in a production environment.
java -version
.python --version
.For most users, installing the binary tarball is the simplest choice. The tarball unpacks all its contents
into a single location with binaries and configuration files located in their own subdirectories. The most
obvious attribute of the tarball installation is it does not require root
permissions and can be
installed on any Linux distribution.
Packaged installations require root
permissions. Install the RPM build on CentOS and RHEL-based
distributions if you want to install Cassandra using YUM. Install the Debian build on Ubuntu and other
Debian-based distributions if you want to install Cassandra using APT. Note that both the YUM and APT
methods required root
permissions and will install the binaries and configuration files as the
cassandra
OS user.
$ java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-8u222-b10-1ubuntu1~16.04.1-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)
$ curl -OL http://apache.mirror.digitalpacific.com.au/cassandra/4.0.0/apache-cassandra-4.0.0-bin.tar.gz
NOTE: The mirrors only host the latest versions of each major supported release. To download an earlier version of Cassandra, visit the Apache Archives.
$ gpg --print-md SHA256 apache-cassandra-4.0.0-bin.tar.gz
apache-cassandra-4.0.0-bin.tar.gz: 28757DDE 589F7041 0F9A6A95 C39EE7E6
CDE63440 E2B06B91 AE6B2006 14FA364D
Compare the signature with the SHA256 file from the Downloads site:
$ curl -L https://downloads.apache.org/cassandra/4.0.0/apache-cassandra-4.0.0-bin.tar.gz.sha256
28757dde589f70410f9a6a95c39ee7e6cde63440e2b06b91ae6b200614fa364d
$ tar xzvf apache-cassandra-4.0.0-bin.tar.gz
The files will be extracted to the apache-cassandra-4.0.0/
directory. This is the tarball installation
location.
<tarball_installation>/
bin/
conf/
data/
doc/
interface/
javadoc/
lib/
logs/
pylib/
tools/
For information on how to configure your installation, see Configuring Cassandra.
$ cd apache-cassandra-4.0.0/
$ bin/cassandra
NOTE: This will run Cassandra as the authenticated Linux user.
You can monitor the progress of the startup with:
$ tail -f logs/system.log
Cassandra is ready when you see an entry like this in the system.log
:
INFO [main] 2019-12-17 03:03:37,526 Server.java:156 - Starting listening for CQL clients on localhost/<IP_ADDRESS>:9042 (unencrypted)...
$ bin/nodetool status
The status column in the output should report UN which stands for “Up/Normal”.
Alternatively, connect to the database with:
$ bin/cqlsh
$ java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-8u222-b10-1ubuntu1~16.04.1-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)
cassandra.sources.list
. The latest major version
is 4.0 and the corresponding distribution name is 40x
(with an “x” as the suffix).
For older releases use 311x
for C* 3.11 series, 30x
for 3.0, 22x
for 2.2 and 21x
for 2.1.
For example, to add the repository for version 4.0 (40x
):$ echo "deb http://www.apache.org/dist/cassandra/debian 40x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
deb http://www.apache.org/dist/cassandra/debian 40x main
$ curl https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 266k 100 266k 0 0 320k 0 --:--:-- --:--:-- --:--:-- 320k
OK
$ sudo apt-get update
$ sudo apt-get install cassandra
NOTE: A new Linux user cassandra
will get created as part of the installation. The Cassandra service
will also be run as this user.
$ tail -f /var/log/cassandra/system.log
Cassandra is ready when you see an entry like this in the system.log
:
INFO [main] 2019-12-17 03:03:37,526 Server.java:156 - Starting listening for CQL clients on localhost/<IP_ADDRESS>:9042 (unencrypted)...
NOTE: For information on how to configure your installation, see Configuring Cassandra.
$ nodetool status
The status column in the output should report UN
which stands for “Up/Normal”.
Alternatively, connect to the database with:
$ cqlsh
$ java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_232-b09)
OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode)
/etc/yum.repos.d/cassandra.repo
(as the root
user). The latest major version is 4.0 and the corresponding distribution name is 40x
(with an “x” as the suffix).
For older releases use 311x
for C* 3.11 series, 30x
for 3.0, 22x
for 2.2 and 21x
for 2.1.
For example, to add the repository for version 4.0 (40x
):[cassandra]
name=Apache Cassandra
baseurl=https://downloads.apache.org/cassandra/redhat/40x/
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://downloads.apache.org/cassandra/KEYS
$ sudo yum update
$ sudo yum install cassandra
NOTE: A new Linux user cassandra
will get created as part of the installation. The Cassandra service
will also be run as this user.
$ sudo service cassandra start
$ tail -f /var/log/cassandra/system.log
Cassandra is ready when you see an entry like this in the system.log
:
INFO [main] 2019-12-17 03:03:37,526 Server.java:156 - Starting listening for CQL clients on localhost/<IP_ADDRESS>:9042 (unencrypted)...
NOTE: For information on how to configure your installation, see Configuring Cassandra.
$ nodetool status
The status column in the output should report UN
which stands for “Up/Normal”.
Alternatively, connect to the database with:
$ cqlsh
For help with installation issues, see the Troubleshooting section.


| Package | Description |
|---|---|
| com.arjuna.ats.arjuna.coordinator | |
| com.arjuna.ats.arjuna.coordinator.abstractrecord | |
| com.arjuna.ats.arjuna.tools.osb.mbean | |
| org.jboss.jbossts.star.resource |
| Modifier and Type | Field and Description |
|---|---|
protected AbstractRecord |
RecordList.listHead |
| Modifier and Type | Method and Description |
|---|---|
static AbstractRecord |
AbstractRecord.create(int type) |
AbstractRecord |
RecordList.getFront()
Remove and return the element at the front of the list.
|
protected AbstractRecord |
AbstractRecord.getNext() |
AbstractRecord |
RecordList.getNext(AbstractRecord current) |
protected AbstractRecord |
AbstractRecord.getPrevious()
These few functions are link manipulation primitives used by the
RecordList processing software to chain instances together.
|
AbstractRecord |
RecordList.getRear()
Remove and return the element at the tail of the list.
|
protected AbstractRecord |
BasicAction.insertRecord(RecordList reclist,
AbstractRecord record) |
AbstractRecord |
RecordListIterator.iterate() |
AbstractRecord |
RecordList.peekFront() |
AbstractRecord |
RecordList.peekNext(AbstractRecord curr) |
AbstractRecord |
RecordList.peekRear() |
| Modifier and Type | Method and Description |
|---|---|
int |
BasicAction.add(AbstractRecord A)
Add a record to the atomic action.
|
protected void |
BasicAction.addRecord(AbstractRecord A)
Add the specified abstract record to the transaction.
|
abstract void |
AbstractRecord.alter(AbstractRecord a)
Alter the current record with the one presented.
|
protected int |
BasicAction.doAbort(boolean reportHeuristics,
AbstractRecord record) |
protected int |
BasicAction.doCommit(boolean reportHeuristics,
AbstractRecord record) |
protected int |
BasicAction.doPrepare(boolean reportHeuristics,
AbstractRecord record) |
boolean |
AbstractRecord.equals(AbstractRecord ar)
Determine if two records are equal in that both are the same type and
have the same order value (determined via 'order()').
|
AbstractRecord |
RecordList.getNext(AbstractRecord current) |
boolean |
AbstractRecord.greaterThan(AbstractRecord ar)
Determine if two records are greater than in that both are the same type
and their Uids are greater than.
|
boolean |
RecordList.insert(AbstractRecord newRecord)
Insert the entry at the head of the list.
|
protected AbstractRecord |
BasicAction.insertRecord(RecordList reclist,
AbstractRecord record) |
boolean |
AbstractRecord.lessThan(AbstractRecord ar)
Determine if two records are less than in that both are the same type and
their Uids are less than.
|
abstract void |
AbstractRecord.merge(AbstractRecord a)
Merge the current record with the one presented.
|
AbstractRecord |
RecordList.peekNext(AbstractRecord curr) |
void |
RecordList.putFront(AbstractRecord newRecord)
Explicit push onto front of list.
|
void |
RecordList.putRear(AbstractRecord newRecord)
Explicit push onto rear of list.
|
boolean |
RecordList.remove(AbstractRecord oldRecord) |
void |
AbstractRecord.replace(AbstractRecord a)
The current record is about to replace the one presented.
|
protected void |
AbstractRecord.setNext(AbstractRecord ar)
Set the next element in the list to the specified instance.
|
protected void |
AbstractRecord.setPrevious(AbstractRecord ar)
Set the previous element in the list to the specified instance.
|
abstract boolean |
AbstractRecord.shouldAdd(AbstractRecord a)
Should we add the record presented to the intentions list?
|
abstract boolean |
AbstractRecord.shouldAlter(AbstractRecord a)
Should we alter the current record with the one presented?
|
abstract boolean |
AbstractRecord.shouldMerge(AbstractRecord a)
Should we merge the current record with the one presented?
|
abstract boolean |
AbstractRecord.shouldReplace(AbstractRecord a)
Should we replace the record presented with the current record?
|
| Modifier and Type | Method and Description |
|---|---|
Class<? extends AbstractRecord> |
RecordTypeManager.getClass(int type) |
Class<? extends AbstractRecord> |
RecordTypeMap.getRecordClass() |
| Modifier and Type | Method and Description |
|---|---|
int |
RecordTypeManager.getType(Class<? extends AbstractRecord> c) |
| Modifier and Type | Field and Description |
|---|---|
protected AbstractRecord |
LogRecordWrapper.rec
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
AbstractRecord |
LogRecordWrapper.getRecord()
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
protected LogRecordWrapper |
ActionBean.createParticipant(AbstractRecord rec,
ParticipantStatus listType)
Deprecated.
Extension point for other Bean implementations to provide an implementation bean for its participants.
|
protected LogRecordWrapper |
ActionBean.createParticipant(AbstractRecord rec,
ParticipantStatus listType,
UidWrapper wrapper)
Deprecated.
|
LogRecordWrapper |
ActionBean.getParticipant(AbstractRecord rec)
Deprecated.
See if there is participant Bean corresponding to the given record
|
Uid |
OSEntryBean.getUid(AbstractRecord rec)
Deprecated.
|
Uid |
ActionBeanWrapperInterface.getUid(AbstractRecord rec)
Deprecated.
|
Uid |
ActionBean.getUid(AbstractRecord rec)
Deprecated.
return the Uid for given AbstractRecord
|
Uid |
ActionBean.GenericAtomicActionWrapper.getUid(AbstractRecord rec) |
void |
LogRecordWrapper.init(ActionBean parent,
AbstractRecord rec,
ParticipantStatus listType)
Deprecated.
|
| Constructor and Description |
|---|
LogRecordWrapper(ActionBean parent,
AbstractRecord rec,
ParticipantStatus listType)
Deprecated.
|
LogRecordWrapper(ActionBean parent,
AbstractRecord rec,
ParticipantStatus listType,
UidWrapper wrapper)
Deprecated.
|
| Modifier and Type | Class and Description |
|---|---|
class |
RESTRecord
Log record for driving participants through 2PC and recovery
|
| Modifier and Type | Method and Description |
|---|---|
void |
RESTRecord.alter(AbstractRecord a) |
void |
RESTRecord.merge(AbstractRecord a) |
boolean |
RESTRecord.shouldAdd(AbstractRecord a) |
boolean |
RESTRecord.shouldAlter(AbstractRecord a) |
boolean |
RESTRecord.shouldMerge(AbstractRecord a) |
boolean |
RESTRecord.shouldReplace(AbstractRecord a) |
Copyright © 2016 JBoss by Red Hat. All rights reserved.


Eddie has been programming for over a decade and has consulted for organisations in the financial, governmental and private sectors. Outside of his consultancy role Eddie enjoys attending and contributing to hackathons and conferences around the world which deal with a variety of technical and social issues. His first foray into the realm of Women's issues was EmpowerHack's "Empowering women and girl refugees" hackathon. Since then Eddie has contributed to EmpowerHack's Open Source projects from a technical perspective and has also brought his expertise and infectious enthusiasm to actively support the growth of women in tech at WHFNP and AcornAspirations. He has been likened to Sheldon Cooper from "The Big Bang Theory" with marginally more social skills. Jaoude Studios Ltd Connect with Eddie Jaoude on Twitter or LinkedIn.


Body
class Body : BodyPart
Center offset is the offset of center from the layoutX/Y.
BodyPart
abstract class BodyPart
Motor
class Motor : BodyPart
Sensor
class Sensor : BodyPart
Vehicle
class Vehicle


Use this dialog to enter the encryption password. The password is the key used to encrypt data and later decrypt it. For further details see Encryption.
This dialog is invoked by the Encryption Password command or by the Encrypt and Decrypt commands if there is no current password.
Password
Enter the password to use for encryption and decryption here When decrypting you must use the same password with which you encrypted.
Re-enter
If the Mask password check box (see below) is on the you must enter the password again here. If the value of the Password field (above) does not match this field then the password is not accepted. This is done to catch typos since you do not have feedback as to the characters typed when masking is used.
Min Length
This sets the minimum password length that you must enter. For high security make this value at least 8 and always use a good password. If your requirements are not as stringent you can reduce the minimum password length.
Mask password
When this option is on then when you enter a password you only see asterisks, and you must enter the password twice (in the Password and Re-enter fields). When this option is off you can see the password as you enter it into the Password field so you don't have to enter it twice.


A serial entrepreneur that founded his first company when he was 18 years old. Spent the last few years building high-tech hardware products while also advising startups.
A maker and crafter that spent the last couple of years helping others prototyping their products while also building his own at organizations like HackerSchool.
Executive director of Nova SBE entrepreneurship and innovation center, involved in various entrepreneurship programs like Shark Thank Portugal and Vodafone BIG smartcities.
With a mechanical engineering background, focused on manufacturing, he is a product designer by heart. At 24 he had already launched 2 businesses, 6 products and a successful Indiegogo campaign.
Founder of Imatch, an innovation boutique consulting company that deserves the trust of corporate giants like: BMW, McDonald’s, L’Oreal, Pepsico, Pfizer, Vodafone...
| 08:00 | Breakfast | ||||||
|---|---|---|---|---|---|---|---|
| 09:00 | 1 on 1 Sessions |
Visit to HFA Electronica |
|||||
| 11:00 | Coffee Break | ||||||
| 11:30 | Week Review And New Goals |
||||||
| 13:30 | Lunch | ||||||
| 15:00 | Workshop Business |
Sales Channels | Mentor Meeting with Pedro Gomes |
||||
| 17:00 | Coffee Break | ||||||
| 17:30 | Workshop Manufactoring |
Design For Manufactoring |
|||||
| 19:30 | Beer Break | Mental Check-Up Dinner |


Please fill the boxes below with the data required.
*I accept the treatment of my data and I will act in accordance with the rules.


ColumnFilters:
|
Demonstrates:
- Implementing a Tree Data View with Filtering and Sorting
- The data can have unlimited tree depth coming from parent/child ref (parentId)
- You can filter "File Size" with operator prefix, for example ">3" (greater than 3Mb)
View Source:
|


Read all the news and stay Uptodate with the development of the game!
Missing-Textures studio is recruiting new DEVELOPERS!!


Mbappe tipped for Real Madrid move by Karembeu
by Sports DeskFormer Real Madrid midfielder Christian Karembeu backed Paris Saint-Germain star Kylian Mbappe to join the LaLiga giants.
Mbappe continues to be heavy linked with a blockbuster switch to Madrid heading into Tuesday's Champions League showdown at the Santiago Bernabeu.
Madrid head coach Zinedine Zidane has made no secret of his admiration for the 20-year-old France international, saying: "I am already in love with him", on the eve of the PSG's trip to the Spanish capital.
Frenchman Karembeu, who won two Champions League titles during his time at Madrid, tipped compatriot Mbappe to link up with Zidane's side.
"I think the next star or big move [in La Liga] will be [Kylian] Mbappe," Karembeu said via LaLiga when asked who will be the next French star in Spain. "I surprise you!
"Ok, we know that there's already [Ferland] Mendy [Madrid], [Ousmane] Dembele [Barcelona, [Karim] Benzema [Madrid]. There are rumours that [Manchester United midfielder Paul] Pogba will come.
"[Antoine] Griezmann [Barcelona] has shown his skills already. Why not, like I said, Mbappe?"
Mbappe – a World Cup winner in 2018 – has scored five Ligue 1 goals this season and nine across all competitions for Thomas Tuchel's PSG.


| NSEL | I | number of items (subset size) |
|---|---|---|
| NCAND | I | number of candidates (set size) |
| LIST | I(NSEL) | latest combination, LIST(1)=0 to initialize |
|---|
| J | I | status: |
|---|---|---|
| -1 = illegal NSEL or NCAND | ||
| 0 = OK | ||
| +1 = no more combinations available |
LIST(1)=1, LIST(2)=2, ..., LIST(NSEL)=NSELThis is also the combination returned for the ``finished'' (J=1) case. The final permutation to be generated is:
LIST(1)=NCAND, LIST(2)=NCAND-1, ...,
LIST(NSEL)=NCAND-NSEL+1
SLALIB --- Positional Astronomy Library


8 Probability Distributions8.1 OverviewThe distributions package provides a framework and implementations for some commonly used probability distributions. Continuous univariate distributions are represented by implementations of the RealDistribution interface. Discrete distributions implement IntegerDistribution (values must be mapped to integers) and there is an EnumeratedDistribution class representing discrete distributions with a finite, enumerated set of values. Finally, multivariate real-valued distributions can be represented via the MultivariateRealDistribution interface.
An overview of available continuous distributions: 8.2 Distribution FrameworkThe distribution framework provides the means to compute probability density functions (density(·)), probability mass functions (probability(·)) and distribution functions (cumulativeProbability(·)) for both discrete (integer-valued) and continuous probability distributions. The framework also allows for the computation of inverse cumulative probabilities and sampling from distributions. For an instance f of a distribution F, and a domain value, x, f.cumulativeProbability(x) computes P(X <= x) where X is a random variable distributed as f, i.e., f.cumulativeProbability(·) represents the distribution function of f. If f is continuous, (implementing the RealDistribution interface) the probability density function of f is represented by f.density(·). For discrete f (implementing IntegerDistribution), the probability mass function is represented by f.probability(·). Continuous distributions also implement probability(·) with the same definition (f.probability(x) represents P(X = x) where X is distributed as f), though in the continuous case, this will usually be identically 0. TDistribution t = new TDistribution(29); double lowerTail = t.cumulativeProbability(-2.656); // P(T(29) <= -2.656) double upperTail = 1.0 - t.cumulativeProbability(2.75); // P(T(29) >= 2.75) All distributions implement a sample() method to support random sampling from the distribution. Implementation classes expose constructors allowing the default RandomGenerator used by the sampling algorithm to be overridden. If sampling is not going to be used, providing a null RandomGenerator constructor argument will avoid the overhead of initializing the default generator. Inverse distribution functions can be computed using the inverseCumulativeProbability methods. For continuous f and p a probability, f.inverseCumulativeProbability(p) returns
For discrete f, the definition is the same, with Z (the integers) in place of R. Note that in the discrete case, the ≥ in the definition can make a difference when p is an attained value of the distribution. 8.3 User Defined DistributionsUser-defined distributions can be implemented using RealDistribution, IntegerDistribution and MultivariateRealDistribution interfaces serve as base types. These serve as the basis for all the distributions directly supported by Apache Commons Math. To aid in implementing distributions, the AbstractRealDistribution, AbstractIntegerDistribution and AbstractMultivariateRealDistribution provide implementation building blocks and offer basic distribution functionality. By extending these abstract classes directly, much of the repetitive distribution implementation is already developed and should save time and effort in developing user-defined distributions. |