Import symbols from @angular/cdk/testing/selenium-webdriver
SeleniumWebDriverElement
A TestElement
implementation for WebDriver.
| Name | Description |
|---|---|
|
async
blur
|
|
|---|---|
|
Blur the element. |
|
| Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
clear
|
|
|---|---|
|
Clear the element's input (for input and textarea elements only). |
|
| Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
click
|
|
|---|---|
|
Click the element at the default location for the current environment. If you need to guarantee
the element is clicked at a specific location, consider using |
|
| Parameters | |
|
modifiers? ModifierKeys
|
|
| Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
click
|
|
|---|---|
|
Click the element at the element's center. |
|
| Parameters | |
|
location "center"
|
|
|
modifiers? ModifierKeys
|
|
| Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
click
|
|
|---|---|
|
Click the element at the specified coordinates relative to the top-left of the element. |
|
| Parameters | |
|
relativeX number
|
Coordinate within the element, along the X-axis at which to click. |
|
relativeY number
|
Coordinate within the element, along the Y-axis at which to click. |
|
modifiers? ModifierKeys
|
Modifier keys held while clicking |
| Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
dispatchEvent
|
|
|---|---|
|
Dispatches an event with a particular name. |
|
| Parameters | |
|
name string
|
Name of the event to be dispatched. |
|
data? Record<string, EventData>
|
|
| Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
focus
|
|
|---|---|
|
Focus the element. |
|
| Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
getAttribute
|
|
|---|---|
|
Gets the value for the given attribute from the element. |
|
| Parameters | |
|
name string
|
|
| Returns | |
Promise<string | null>
|
|
async
getCssValue
|
|
|---|---|
|
Get the computed value of the given CSS property for the element. |
|
| Parameters | |
|
property string
|
|
| Returns | |
Promise<string>
|
|
async
getDimensions
|
|
|---|---|
|
Gets the dimensions of the element. |
|
| Returns | |
Promise<ElementDimensions>
|
|
async
getProperty
|
|
|---|---|
|
Gets the value of a property of an element. |
|
| Parameters | |
|
name string
|
|
| Returns | |
Promise<T>
|
|
async
hasClass
|
|
|---|---|
|
Checks whether the element has the given class. |
|
| Parameters | |
|
name string
|
|
| Returns | |
Promise<boolean>
|
|
async
hover
|
|
|---|---|
|
Hovers the mouse over the element. |
|
| Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
isFocused
|
|
|---|---|
|
Checks whether the element is focused. |
|
| Returns | |
Promise<boolean>
|
|
async
matchesSelector
|
|
|---|---|
|
Checks whether this element matches the given selector. |
|
| Parameters | |
|
selector string
|
|
| Returns | |
Promise<boolean>
|
|
async
mouseAway
|
|
|---|---|
|
Moves the mouse away from the element. |
|
| Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
rightClick
|
|
|---|---|
| Parameters | |
|
...args [ModifierKeys?] | ["center", ModifierKeys?] | [number, number, ModifierKeys?]
|
|
| Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
selectOptions
|
|
|---|---|
|
Selects the options at the specified indexes inside of a native |
|
| Parameters | |
|
...optionIndexes number[]
|
|
| Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
sendKeys
|
|
|---|---|
|
Sends the given string to the input as a series of key presses. Also fires input events and attempts to add the string to the Element's value. |
|
| Parameters | |
|
...keys (string | TestKey)[]
|
|
| Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
sendKeys
|
|
|---|---|
|
Sends the given string to the input as a series of key presses. Also fires input events and attempts to add the string to the Element's value. |
|
| Parameters | |
|
modifiers ModifierKeys
|
|
|
...keys (string | TestKey)[]
|
|
| Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
setContenteditableValue
|
|
|---|---|
|
Sets the value of a |
|
| Parameters | |
|
value string
|
Value to be set on the element. |
| Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
setInputValue
|
|
|---|---|
|
Sets the value of a property of an input. |
|
| Parameters | |
|
newValue string
|
|
| Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
text
|
|
|---|---|
|
Gets the text from the element. |
|
| Parameters | |
|
options? TextOptions
|
Options that affect what text is included. |
| Returns | |
Promise<string>
|
|
SeleniumWebDriverHarnessEnvironment
extends
HarnessEnvironment
A HarnessEnvironment
implementation for WebDriver.
| Name | Description |
|---|---|
|
| createEnvironment | |
|---|---|
|
Creates a |
|
| Parameters | |
|
element () => webdriver.WebElement
|
|
| Returns | |
HarnessEnvironment<() => webdriver.WebElement>
|
|
| createTestElement | |
|---|---|
|
Creates a |
|
| Parameters | |
|
element () => webdriver.WebElement
|
|
| Returns | |
TestElement
|
|
| documentRootLocatorFactory | |
|---|---|
| Returns | |
LocatorFactory
|
|
async
forceStabilize
|
|
|---|---|
|
Flushes change detection and async tasks captured in the Angular zone. In most cases it should not be necessary to call this manually. However, there may be some edge cases where it is needed to fully flush animation events. |
|
| Returns | |
Promise<void>
|
Promise that resolves when the action completes. |
async
getAllChildLoaders
|
|
|---|---|
| Parameters | |
|
selector string
|
|
| Returns | |
Promise<HarnessLoader[]>
|
|
async
getAllHarnesses
|
|
|---|---|
| Parameters | |
|
query HarnessQuery<T>
|
|
| Returns | |
Promise<T[]>
|
|
async
getAllRawElements
|
|
|---|---|
|
Gets a list of all elements matching the given selector under this environment's root element. |
|
| Parameters | |
|
selector string
|
|
| Returns | |
Promise<(() => webdriver.WebElement)[]>
|
|
async
getChildLoader
|
|
|---|---|
| Parameters | |
|
selector string
|
|
| Returns | |
Promise<HarnessLoader>
|
|
| getDocumentRoot | |
|---|---|
|
Gets the root element for the document. |
|
| Returns | |
() => webdriver.WebElement
|
|
async
getHarness
|
|
|---|---|
| Parameters | |
|
query HarnessQuery<T>
|
|
| Returns | |
Promise<T>
|
|
async
getHarnessOrNull
|
|
|---|---|
| Parameters | |
|
query HarnessQuery<T>
|
|
| Returns | |
Promise<T | null>
|
|
static
getNativeElement
|
|
|---|---|
|
Gets the ElementFinder corresponding to the given TestElement. |
|
| Parameters | |
|
el TestElement
|
|
| Returns | |
webdriver.WebElement
|
|
async
harnessLoaderFor
|
|
|---|---|
| Parameters | |
|
selector string
|
|
| Returns | |
Promise<HarnessLoader>
|
|
async
harnessLoaderForAll
|
|
|---|---|
| Parameters | |
|
selector string
|
|
| Returns | |
Promise<HarnessLoader[]>
|
|
async
harnessLoaderForOptional
|
|
|---|---|
| Parameters | |
|
selector string
|
|
| Returns | |
Promise<HarnessLoader | null>
|
|
async
hasHarness
|
|
|---|---|
| Parameters | |
|
query HarnessQuery<T>
|
|
| Returns | |
Promise<boolean>
|
|
static
loader
|
|
|---|---|
|
Creates a |
|
| Parameters | |
|
driver webdriver.WebDriver
|
|
|
options? WebDriverHarnessEnvironmentOptions
|
|
| Returns | |
HarnessLoader
|
|
| locatorFor | |
|---|---|
| Parameters | |
|
...queries T
|
|
| Returns | |
AsyncFactoryFn<LocatorFnResult<T>>
|
|
| locatorForAll | |
|---|---|
| Parameters | |
|
...queries T
|
|
| Returns | |
AsyncFactoryFn<LocatorFnResult<T>[]>
|
|
| locatorForOptional | |
|---|---|
| Parameters | |
|
...queries T
|
|
| Returns | |
AsyncFactoryFn<LocatorFnResult<T> | null>
|
|
async
rootHarnessLoader
|
|
|---|---|
| Returns | |
Promise<HarnessLoader>
|
|
WebDriverHarnessEnvironmentOptions
Options to configure the environment.
| Name | Description |
|---|---|
|
The query function used to find DOM elements. |
async
waitForAngularReady
|
|
|---|---|
|
Waits for angular to be ready after the page load. |
|
| Parameters | |
|
wd webdriver.WebDriver
|
|


--- title: calcTPVotes sidebar: function_reference_sidebar permalink: parentGrainReconstructor.calcTPVotes.html folder: function_reference toc: false ---
compute votes from triple points
| job | parentGrainReconstructor |
| job.votes | table of votes |
| threshold | threshold fitting angle between job.p2c and the boundary OR |
| tolerance | range over which the probability increases from 0 to 1 (default 1.5) |
| minFit | minimum required fit for a TP to produce votes |
| maxFit | maximum second best fit for a TP to produce votes |
| numFit | number of fits to compute (default 2) |


Basic engine documentation
This page (and whole site) is powered by Source engine, and all the documentation comes built in in every Source instance.
Sourcejs.com client side source code is stored at github.
Fast start
To start, all you need is to follow these simple steps:
$ git clone https://github.com/sourcejs/Source.git
$ cd Source
$ npm install
$ grunt init
$ sudo node app.js
Be sure that you have Git, Node.js and Grunt installed, before Source setup. Read more about Grunt tasks workflow with Source here.
After initializing new project with grunt, you will get public folder as a root path for Node.js server, that runs on 80 port.
Public is the main folder for your specs, it's in ".gitignore", so you can use another git repository there (as we do for Sourcejs.com, check sources for example). All the client-side code of Source engine is copied to this folder through Grunt update tasks.
Starting template1
Starting template for spec page is located here, just copy it to new folder and page is ready.
Read more about Spec pages here.File structure
Main engine architecture is based on two enviroments - client and server (node) that have their own modules and plugins:
// Client side (frontend) part
client
init
src
plugins (.gitignored)
// Server root folder for spect (.gitignored)
public
core
user
// Server (node) part
init
core
user (.gitignored)
This complex structure is built to let custom Source engine users to easily override core settings and to extend them in both enviroments. This setup helps you to manage Source engine with your spec repositories all in one place.
If you don't want to modify core functionality, just use /user and /public/user folders that has everything you need for your custom settings on client and server side.
Node
// Server (node) part
init
core
options
routes
views
user (.gitignored)
options
routes
plugins
app.js
package.json //For your custom dependencies
app.js
As you can see, core and user have common file structure, and options from /user will override options from /core, same logic for other parts.
/app.js is the main server script, and could be extented through /user/app.js
As /user folder is in ".gitignore", you could put there anything you want, like custom package.json for additional plugins and dependencies.
Client
// Client side (frontend) part
client
init
src
core
docs
test
plugins (.gitignored)
// Server root folder for spect (.gitignored)
public
//Files from /client/src (.gitignored)
core //minified
docs
test
plugins //minified
data //for your custom data and resources
user
/client/src - has all the client side code of Source engine, all files from this folder are minified and copied to /public folder on "grunt init" (first setup) and "grunt update".
For overriding core settings same logic as on server side is available, for example, to override header/footer templates and change options use /user folder.
Folder /data is for user content like your images or your project styles etc.
Options
Node
Options of Source server side are stored in /user/options/options.json (appears after initializing project), all options there overrides default core options /core/options/options.js.
{
"common": {
"pathToSpecs": "public"
},
"grunt" : {
"server": {
"pathToDir": "/path/to/project/dir/on/server",
"host": "your.host.here",
"port": "yourPortHere",
"key": "keyInFile.ftppass"
}
}
}
common.pathToSpecs object is setting the path to specs folder, so if you want to override it, just change the setting in /user folder.
In the same options file we store all options for Grunt deploy tasks and many more settings to come.
Client
Client side options works with same logic as server side options, overriding core options from /public/user/js/options.js.
{
sourceOptions : {
modulesEnabled : {},
modulesOptions : {},
// Plugins
pluginsEnabled : {},
pluginsOptions : {}
},
// Default options for landing page
landingOptionsExceptions : {
pluginsEnabled : {}
}
}
This is options object from /public/user/js/options.js (see sources for more examples), here we have next fields:
- modulesEnabled - settings for enabling or disabling core modules
- modulesOptions - core modules options
- pluginsEnabled - the same as modules, but for custom plugins in "/public/plugins"
- landingOptionsExceptions - lets us disable some modules from the navigation pages of Source engine
All client side options could be overridden from any page, using this approach:
Plugins
Node
You could install any plugins for the server side through npm right in /user folder with custom package.json and require them in /user/app.js.
Client
All client plugins need to be stored in /client/plugins, plugins will be copied to /public folder with grunt tasks. We recommend to use Volo packet manager, and with "volo find Sourcejs" you will find all our official plugins from GitHub.
To activate plugins use /public/user/js/options.js, there you will find "pluginsEnabled" object where name of the parameter must be the same as plugin name (and plugin folder name as well) and value set to "true".
pluginsEnabled : {
//Plugins enabling
//bubble: true,
//debugmode: true
}
Contact us
Leave your questions and feedback at Issues sections on Github.


Based on site observations by enumerators
Open to the elements
Limited access to water
Poor quality drinking water
Falling hazards
Limited access to electricity
Risk of unexploded mines
Number of individuals
Number of sites by size
Number of individuals
Direct environment
(water_access + water_quality + openelement + damage + mines+ hazards + fighting) ranked in 5 five classes.
Number of sites
Zoom on the map to filter sites. click on the pinpoint for more information
Average number of individuals per household per site
Based on site observation by enumerators
Sites that include unfinished buildings (buildings under construction)
Sites that include open accommodations (tents or any improvised shelter)


set a 15 set b "hello"
send "Mozilla Firefox OS is written in\n" send "HTML5\n"
puts "Mozilla Firefox OS is written in" puts "HTML5"
| puts automatically appends a new line.
expect "pattern" action
expect { "pattern1" action1 "pattern2" action2 "pattern3" { action3a action3b } }
expect -gl "super *"
expect -re "(login|Username):"
expect -ex "* wars"
spawn ./a.out spawn chromium spawn gnome-terminal
interact
if {$temperature < 50} { puts "It’s pretty cold." }
while {$temperature < 20} { puts "Ice Age!" }


Brendan Rodgers warns Leicester are trying to 'lob a hand-grenade' into established elite again
Leicester boss Rodgers has the Foxes in third in the Premier League ahead of hosting Arsenal at the King Power Stadium on Saturday evening
by James Nursey, https://www.mirror.co.uk/authors/james-nursey/Brendan Rodgers admits Leicester are relishing trying to lob a “hand-grenade” into the established elite again.
The underdog Foxes won the title in 2016 before the big powers spent huge sums to redress the balance of power.
But now City are up to third under Rodgers and are pushing for honours and European qualification again.
They have capitalised on indifferent form by the likes of Spurs, Manchester United and Arsenal , who visit tonight.
Boss Rodgers said: “You have to fight.
“You can’t accept that is the top six in terms of money and finance and that you are always going to sit below it.
“We have to hopefully find a way and drop a hand-grenade in there. But we have to do it in a different way.
“We have resources but not the resources to get some of these players who will go to other clubs.
“We have to find a way but that is the exciting part and beauty, and the challenge.”
Yet Rodgers knows if Leicester are successful it could inspire the bigger clubs to hit back with vast investment in new players.
He added: “It has sometimes been a trend that if something happens that wakens them up they have that facility to go and spend and get the level of player to get them back up there.”


Requires Artifactory Pro
New line or comma separated references to other artifacts that this build should use as dependencies.
Each reference is specified in the format of:
repo_key:path_pattern[;props=val1,val2[;prop2+=val3][@build_name#build_number][=>target_dir], where:
repo_key - A key of the Artifactory repository that contains the dependencies (may contain the * and the
? wildcards).
path_pattern - An Ant-like pattern of the dependencies path within the Artifactory (may contain the * and
the ? wildcards).
For example: repo-key:dir/*/bob/*.zip (** wilcards are supported only if you combine with matrix params)
Artifacts can be downloaded conditionally based on their property values in Artifactory.
For example, to
download all zip files marked as production ready: repo-key:dir/*/bob/*.zip;status+=prod.
For more details see the plug-in's documentation.
build_name - The name of the build that was published to Artifactory, of which dependencies should be
resolved.
build_number - A specific build run number. Can be LATEST to depend on the latest build run,
or LAST_RELEASE to depend on the latest build with a "release" status.
For example: repo-key:dir/**/bob/*.zip@myBuild#LATEST
target_dir - An optional target directory to where resolved dependencies will be downloaded.
By default dependencies will be downloaded to a path under the build workspace.
For example: repo-key:*.zip=>winFiles, repo-key:unix/distro.tgz=>linuxFiles,
where winFiles and linuxFiles are target directories.
Target directories can either be absolute or relative to the working directory.
Use =!> instead of => to delete any locally found files which are not downloaded from Artifactory.
Pattern value can take environment variables. For example: repo-key/*.xml=>${BUILD_ID}-${BUILD_NUMBER}


Active ingredients (in each patch)
Menthol 3%
Methyl salicylate 10% (NSAID : nonsteroidal anti-inflammatory drug)
Purpose
Topical analgesic
Uses
Temporarily relieves mild to moderate aches and pains of muscles and joints associated with:
- arthritis
- sprains
- strains
- bruises
- simple backache
Warnings
For external use only
Stomach bleeding warning:
This product contains an NSAID, which may cause stomach bleeding. The chance is small but higher if you:
- are age 60 or older
- have had stomach ulcers or bleeding problems
- take a blood thinning (anticoagulant) or steroid drug
- take other drugs containing an NSAID [aspirin, ibuprofen, naproxen, or others]
- have 3 or more alcoholic drinks every day while using this product
- take more or for a longer time than directed
Do not use
- on the face or rashes
- on wouds or damaged skin
- if allergic to aspirin or other NSAIDs
- with a heating pad
- when sweating (such as from exercise or heat)
- any patch from a pouch that has been open for 14 or more days
- right before or after heart surgery
Ask a doctor before use if
- you are allergic to topical products
- the stomach bleeding warning applies to you
- you are taking a diuretic
- you have high blood pressure, heart disease, or kidney disease
When using this product
- wash hands after applying or removing patch. Avoid contact with eyes. If eye contact occurs, rinse thoroughly with water.
- the risk of heart attack or stroke may increase if you use more than directed or for longer than directed
Stop use and ask a doctor if
- stomach pain or upset gets worse or lasts
- you feel faint, vomit blood, or have bloody or black stools. These are signs of stomach beeding.
- rash, itching or skin irritaion develops
- condition worsens
- symptoms last for more than 3 days
- symptoms clear up and occur again within a few days
If pregnant or breast-feeding,ask a doctor before use while breast-feeding and during the first 6 months of pregnancy. Do not use during the last 3 months of pregnancy because it may cause problems in the unborn child or complications during delivery.
Keep out of reach of children.If put in mouth, get medical help or contact a Poison Control Center right away. Package not child resistant. Dispose of the used patches after folding sticky ends together.
Directions
Adults 18 years and older:
- only use one patch at a time
- clean and dry affected area
- remove patch from backing film and apply to skin (see illustration)
- apply one patch to the affected area and leave in place for up to 8 to 12 hours
- if pain lasts after using the first patch, a second patch may be applied for up to another 8 to 12 hours
- do not use more than 2 patches per day
- do not use for more than 3 days in a row
- the used patch should be removed from the skin when a new one is applied
Children under 18 years of age: do not use; this product has not been shown to work in children
Other information
- store at 20 - 25 degrees Celsius (68-77 degrees Fahrenheit)
- avoid storing product in direct sunlight
- protect product from excessive moisture
- some individuals may not experience pain relief until several hours after applying the patch
Inactive inredients
alicyclic saturated hydrocarbon resin, baking cloth, film, mineral oil, polyisobutylene, polyisobutylene 1,200,000, styrene-isoprene-sryrene block copolymer, synthetic aluminum silicate
Principal Display Panel
Hisamitsu
NDC#46581-680-05
for temporary relief of mild to moderate pain
- Arthritis
- Joint Pain
- Sprains
- Strains
Salonpas
Arthritis Pain Patch
APPLY FOR 8-12 HOURS
Menthol 3%
Methyl Salicylate 10%
Topical Analgesic
FDA APPROVED NON-PRESCRIPTION PAIN RELIEVING PATCH
EFFECTIVENESS CONFIRMED IN CLINICAL TRIAL
5 pathces
2 3/4" X 3 15/16"(7cm X 10cm)
Package not child resistant.
Keep our of reach of children.
* DO NOT USE MORE THAN ONE SALONPAS PATCH AT A TIME. SEE DIRECTIONS
Principal Display Panel
Hisamitsu
FREE SAMPLE
NOT FOR RE-SALE
minty scent
NDC#46581-680-99
for temporary relief of mild to moderate pain
- Arthritis
- Joint Pain
- Sprains
- Strains
1 Peel the center film.
2 Place on affected area.
3 Slide the film upward.
4 Slide the other film downward.
Salonpas
Arthritis Pain Patch
APPLY FOR 8-12 HOURS
Menthol 3%
Methyl Salicylate 10%
Topical Analgesic
FDA APPROVED NON-PRESCRIPTION PAIN RELIEVING PATCH
EFFECTIVENESS CONFIRMED IN CLINICAL TRIAL
1 patch
2 3/4" X 3 15/16" (7cm X 10cm)
Package not child resistant.
Keep out of reach of children.
*DO NOT USE MORE THAN ONE SALONPAS PATCH AT A TIME, SEE DIRECTIONS
Manufactured by
Hisamitsu Pharmaceutical Co., Inc.
JAPAN SAGA TOSU
MADE IN JAPAN
Distributed by
Hisamitsu America,Inc.
Florham Park, NJ 07932
Hisamitsu Pharmaceutical Co., Inc.


We use cookies
Cookies help us deliver our services. By accepting you agree to our use of cookies.
Accept
Decline
Learn more
.


We can verify that your school district is using efficient routes without any cost to the school
district. If our artificial intelligence software finds that it can reduce the number of buses in use or
bus driver hours, then Galileo helps the school district implement these efficient routes.
Galileo receives a portion of the savings after the school incurs the savings ensuring our services are cash flow positive.
In addition, we can quickly run various scenarios in hours not months that
will determine the impact of certain variables on your overall transportation cost. Examples include
capacities on buses, school start times, etc.
Our main service is producing highly-efficient bus routes using our proprietary AI software. Using the school district’s stop data, the AI software will find one of two outcomes:
We confirm you have efficient routes already or we have found you savings.
If our AI verifies your current routes are efficient, then there is no cost.
If the software finds savings through reduction in the number of buses or bus driver hours, we will work with you to update your routes.


Book your Slot now and save your time!!
fvunff ijfjtfoi trrvb odjfdg igjfij jdgjiob jdfiofb ftofb tjthovo gfmmv gdeicb ftojhinbnbjv fdjb
Book Appointment
Address Details
Book Appointment


Road Roughness
All Equipment
Dump Trucks
Water Trucks
Fuel Trucks
Shovels
Loaders
Drillers
Dozers
Graders
Speed


Personal details
Job Details
Add More
Welcome to VideooCV, you are required to enter your personal details in order in help us verify and rate your profile. VideooCV Has Certificate Where Recuruiter are Not allowed to Share/Leak Your Info. If you see a * next to a field, that item is and always will be confidential.
In order for VideooCV to give you the very best chance in finding a job we require some details in regards to your skill sets and employment details ( if any applicable). These details will be available to recruiters to view.
Approval for Auction from Admin Pending.


Nice to meet you! My name is Amaar Fazlani. I was born in Karachi, Pakistan and moved to the United States when I was four months old. Growing up, I always loved to watch and play basketball and my favorite team is the Houston Rockets. I also enjoy reading and love it when I find a book that is both entertaining and thought-provoking. I am a recent graduate from Davidson College. At Davidson, I achieved a B.A. in History and learned how to think critically about issues that were multifaceted in nature with no easy solution. I was constantly pushed to analyze information and data in depth in order to form concrete arguments backed by reliable sources.
One quirk that I have is that I do not know how to swim. I always wanted to learn how to swim but both my parents never knew how to swim either. It is definetely on my to-do list and I hope that in a years time, I can proudly say that I have finally learned to swim. Perhaps one day, in the not too distant future, I can teach others who are in the same shoes as me.


Match Play. 0-0 to 7. How should Red play 55?
pips Red=194 White=94
(CorrectAnswer= 0/0, ErrorScore= 0)
This is not easy.
Over the board 23/13(2) was tried, combining a priming game with the fallback of well-timed ace-point game. This turns out to be a small error.
The best game plan is to keep the 1-2 back game. This is because White’s bar-point is open and will very likely remain open, thus recirculating hit checkers will be relatively easy.
The best move is 13/3, 10/5, 8/3. This maintains the back game, keeps all the checkers in play and retains the small possibility of winning going forwards. Playing 11/6 with one of the fives is wrong because it creates a small stack which is something to be avoided if possible when playing purely.
Over the board 23/13(2) was tried, combining a priming game with the fallback of well-timed ace-point game. This turns out to be a small error.
The best game plan is to keep the 1-2 back game. This is because White’s bar-point is open and will very likely remain open, thus recirculating hit checkers will be relatively easy.
The best move is 13/3, 10/5, 8/3. This maintains the back game, keeps all the checkers in play and retains the small possibility of winning going forwards. Playing 11/6 with one of the fives is wrong because it creates a small stack which is something to be avoided if possible when playing purely.
1. Cubeful 2-ply 23/13(2) Eq.: -0.535 0.366 0.035 0.000 - 0.634 0.372 0.061 2. Cubeful 2-ply 13/3 10/5 8/3 Eq.: -0.542 (-0.007) 0.385 0.018 0.000 - 0.615 0.366 0.106 3. Cubeful 2-ply 11/6 10/5 8/3(2) Eq.: -0.568 (-0.034) 0.369 0.018 0.000 - 0.631 0.365 0.093 4. Cubeful 2-ply 13/3 11/6 10/5 Eq.: -0.575 (-0.041) 0.372 0.016 0.000 - 0.628 0.371 0.099 5. Cubeful 2-ply 13/3 11/6 8/3 Eq.: -0.619 (-0.084) 0.353 0.016 0.000 - 0.647 0.373 0.093


| 020:071 Khan | : |
[Fir'aun (Pharaoh)] said: "Believe you in him [Musa (Moses)] before I give you permission? Verily!  So I will surely cut off your hands and feet on opposite sides, and I will surely crucify you on the trunks of date-palms, and you shall surely know which of us [I (Fir'aun - Pharaoh) or the Lord of Musa (Moses) (Allah)] can give the severe and more lasting torment." |
| 020:071 Maulana | : |
(Pharaoh) said: You believe in him before I give you leave!  So I shall cut off your hands and your feet on opposite sides and I shall crucify you on the trunks of palm-trees, and you shall certainly know which of us can give the severer and the more abiding chastisement. |
| 020:071 Pickthal | : |
(Pharaoh) said: Ye put faith in him before I give you leave.  Now surely I shall cut off your hands and your feet alternately, and I shall crucify you on the trunks of palm trees, and ye shall know for certain which of us hath sterner and more lasting punishment. |
| 020:071 Rashad | : |
He said, "Did you believe in him without my permission?  I will surely sever your hands and feet on alternate sides. I will crucify you on the palm trunks. You will find out which of us can inflict the worst retribution, and who outlasts whom." |
| 020:071 Sarwar | : |
The Pharaoh said, "Since you believed in him without my permission, then Moses certainly must be your chief who has taught you magic. I shall cut your hands and feet on alternate sides and crucify you on the trunk of the palm-tree. You shall certainly find which among us can afflict a more severe and lasting punishment". |
| 020:071 Shakir | : |
(Firon) said: You believe in him before I give you leave; most surely he is the chief of you who taught you enchantment, therefore I will certainly cut off your hands and your feet on opposite sides, and I will certainly crucify you on the trunks of the palm trees, and certainly you will come to know which of us is the more severe and the more abiding in chastising. |
| 020:071 Sherali | : |
Pharaoh said, 'Do you believe in him before I give you leave? He must be your chief who has taught you magic. I will, therefore, surely cut off your hands and your feet on alternate sides, and I will surely crucify you on the trunks of palm trees; and you shall know which of us can impose severer and more abiding punishment.' |
| 020:071 Yusufali | : |
(Pharaoh) said: "Believe ye in Him before I give you permission? Surely this must be your leader, who has taught you magic! be sure I will cut off your hands and feet on opposite sides, and I will have you crucified on trunks of palm-trees: so shall ye know for certain, which of us can give the more severe and the more lasting punishment!" |
Concepts/Themes Covered: الإيمان > الغيب > السحر Faith> The Unseen World> Witching
This tool uses eight English parallel translations for the Holy Quran imported from Mr. Clay Smith. You can also visit Qurany Concepts for browsing the Quran themes or topics. If you want to search the Holy Quran for keywords, please visit Qurany Keywords.


@import play.mvc.Http.Context.Implicit._
TREC Incident Streams - Assessment Interface
TREC-IS
v1 Ontology and Keyword Annotator
Enter your Assessor ID
Please enter your assessor id, we use this to track what tweets you have assessed.
Submit


You are only allowed one endorsement.
☹{{error}}
Data entered in this form is used solely for calculating vote results, duplicate vote prevention, and connecting users with their representative electors based on their geographic and demographic profiles. It will not be shared with any third parties.


Logservice is here to parse cloud foundry logs and format them in json and finally forward them in syslog rfc5424 format to a or multiple log storage platform(s) in same time. (e.g.: Elastic stack).
It lets user define is own parsing rule in grok format but also tags which will be include in logs.
Logservice implements service broker api for make use this service simply as you will works with others services. In addition, logservice parse itself router, metrics and common app logs like apache without do anything. Operators can also include parsing rules by default for easy usage.


We offer a full beverage and dessert menu! We proudly serve Coca-Cola products and Mexican drinks.
We're excited to offer you two locations to dine at - the original location in Paonia and our newest location in Delta we look forward to treating you to our hospitality and authentic Mexican dishes.
350 Stafford Lane
Delta, CO 81416
(970) 874-6912
240 Grand Avenue
Paonia, CO 81428
(970) 527-4187


If science can make sharks super-intelligent, why can't it do the same for screenwriters? That's the question posed by "Deep Blue Sea," a thriller set in an undersea lab where medical researcher Susan McAlester (Saffron Burrows) and her crew are being hunted by predators of their own creation. The essentials of the storyline are best summed up by McAlester's hypertense co-worker Tom (Michael Rapaport): "She screwed with the sharks, and now the sharks are screwin' with us!".
Directed by Renny Harlin, the man who gave us "Die Hard 2: Die Harder" and "Cliffhanger" when he was at his peak and the infamous "Cutthroat Island" at his nadir, "Sea" is essentially a series of explosions and crises, occasionally interrupted by stern warnings about the consequences of fooling around with Mother Nature. The movie is so poorly written it's almost laughable, but it does provide a few genuine jolts, which is more than can be said for most of the current crop of horror films.
"Sea" begins with McAlester inviting financier Russell Franklin (Samuel L. Jackson) to her base of operations, in hope of convincing him not to cut off funding for her quest to find a cure for Alzheimer's Disease. She and her staff have been using "hormonal enhancers" to tinker with the brains of a trio of sharks at their Aquatica compound and McAlester is certain a breakthrough is just around the corner.
Unfortunately, so is a typhoon, which devestates Aquatica and nearly kills everyone in it. Soon the hallways are flooded, the escape routes are impassable and the humans are turning into snacks for their toothy pet monsters.
"These sharks aren't just breaking down doors for the fun of it," Franklin realizes. "They're after us!" Most of the major lines in "Sea" are followed by exclaimation points; the rest of the insipid dialogue by first-time writers Duncan Kennedy, Wayne Powers and Donna Powers is either mumbled or drowned out by the thousands of gallons of water that wash over the cast at regular intervals.
Among those struggling to survive alongside Franklin and McAlester are daredevil Carter Blake (Thomas Jane), simpering Janice (Jacqueline McKenzie) and a Gospel-spouting cook nicknamed Preach (LL Cool J), whose sidekick is a profanity-spouting parrot -- really. None of the actors is required to do much more than shriek, swim or scramble to get out of the scene as quickly as possible. Those who like to see dismemberment up close will be delighted by Harlin's insistance that we get a look at every severed arm and leg in full, bloody detail.
The attacks -- at least one of which is a real surprise -- are generally exciting, although someone should have informed the authors that just because a shark may have increased his brain size does not necessarily mean he'll know how to turn on an oven, as one does here in the movie's most ludicrous sequence. For a movie about the advancement of knowledge, "Sea" is often flabbergastingly dumb. James Sanford
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


Is there something so unbelievable that you would assign it probability 0?
How much evidence do you need to be convinced in something that is very implausible is actually the case? Or rather, if you really don’t believe something to be true, how much evidence do you need to push you all the way to near certainty?
Of course, this is a question about probabilities so we aren’t talking about any kind of knowledge that can be gained without evidence. The kind, for example, where we make definitions and then reason according to a set of rules to get some new knowledge. This kind of reasoning is common in mathematics or law. Most scientific laws, and especially in the rough and tumble world of knowledge in the real world (is this burger fully cooked, is Jones going to arrive late for the meeting again etc…) we are always working with probability and hence using some data to assign a definite number to a possible state of the world.
Let’s think about an interesting case. You believe that something is very implausible but not all the way down at 0. For example, someone claims to have the miraculous ability to communicate with the deceased. For me, this is very unlikely but I’m willing to entertain at least the possibility that it could be true. How low is the probability? I think somewhere around -75 dB. How did I get that number? Basically, I asked myself how many yes/no questions would they have to get right about someone I knew who was deceased that only I would know the answer to. I found by introspecting that after 25 correct responses I would notice a change in my belief. Of course, this number depends on the conditions of the test. This would be 25 questions that I was pretty sure they simply could not know. That’s pretty low, much lower than most Hollywood films where the clairvoyant hooks people in with a couple guesses but that’s where I’m at.
But how many more guesses would be need to get to really make a big dent in my belief about their powers of clairvoyance? The answer is that with a prior that low more evidence will certainly result in a change in my beliefs but it will never approach certainty. There are always some alternative hypothesis that I would entertain that could explain the data I’m observing. These alternatives might also be extremely low, say down at around -50 dB but the important point is that there are competitor hypotheses that are at least more plausible to me than clairvoyance.
This kind of thinking comes from a straightforward application of Bayes' rule to combine evidence and prior beliefs to determine the probability of a hypothesis.
For the clairvoyance case: C is the proposition that the person has clairvoyance and D is the proposition that they got some number of guesses correct.
According to Bayes rule:
$$Pr(C \mid D) = Pr(D \mid C) * Pr(C) / Pr(D)$$
I found my prior is $Pr(D) = -75~\text{dB}$.
The part of this that makes it very difficult to get to near certainty in a case like this is that the value of the denominator $Pr(D)$ is formed by conditioning on a possibly large number of alternative hypothesis, in addition to the hypothesis that the person has clairvoyance: the person happened to actually know the person we are referring to, I’m a contestant on a twisted game show, there is a hidden microphone and they are getting answers from someone outside the room etc… These are all implausible, but less implausible than clairvoyance. To get the probability of the denominator we have by the law of total probability:
$$Pr(D) = Pr(D \mid C) Pr(\text{C}) + \sum_{i=1}^{N} Pr(D \mid A_i) Pr(A_i)$$
If those alternative hypotheses stay more plausible than clairvoyance we are going to stay pretty close to the initially low prior belief.
Although this example is contrived it has relevance to the real world, especially if one believes that human reasoning is approximately rational. An important footnote here is that nowhere in this setup are we dealing with true probabilities. It’s a statement about subjective states of affairs and how beliefs ought to change under those conditions.


home page
Character contribution
Character works
Character speech
Entry atlas
Entry atlas
Life, experience,
Friendly contacts
Deng Xiaoping in the 1950s and 1970s
The death of a great man


Chocolate Pizza
For the fig-swirl: Melt butter over medium heart in a saucepan. Add brown sugar and stir to dissolve. Halve all of the figs and toss in the saucepan with water and lemon juice. Cook over medium heat, stirring frequently, until you have a chunky-jammy mixture. Add salt with one or two stirs, set aside and let cool completely.
Ice cream: In a small pot over medium heat, combine milk, and granulated sugar until sugar is completely dissolved and the milk is just barely lukewarm. Whisk in the egg yolks. Set mixture in the fridge and wait until the fig mixture is cooled.
Using an ice cream machine, pour liquids into the frozen basin and process according a manufacturer instructions, i.e., let spin and thicken for 20 minutes before adding mascarpone, fig jam mixture,and the nuts. Continue to process for +/-10 minutes. Pour semi-frozen mixture into a pyrex dish or glass tupperware. Freeze for at least two hours before serving.
Vanessa Stevenson
Food enthusiast, photography fan. Add a pinch of raw foodism and that's
pretty much who I am Share recipe


Implement atoi
which converts a string to an integer.
The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many numerical digits as possible, and interprets them as a numerical value.
The string can contain additional characters after those that form the integral number, which are ignored and have no effect on the behavior of this function.
If the first sequence of non-whitespace characters in str is not a valid integral number, or if no such sequence exists because either str is empty or it contains only whitespace characters, no conversion is performed.
If no valid conversion could be performed, a zero value is returned.
Note:
Only the space character ' '
is considered as whitespace character. Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. If the numerical value is out of the range of representable values, INT_MAX (231 − 1) or INT_MIN (−231) is returned.
Example 1:
Input: "42"
Output: 42
Example 2:
Input: " -42"
Output: -42
Explanation: The first non-whitespace character is '-', which is the minus sign.
Then take as many numerical digits as possible, which gets 42.
Example 3:
Input: "4193 with words"
Output: 4193
Explanation: Conversion stops at digit '3' as the next character is not a numerical digit.
Example 4:
Input: "words and 987"
Output: 0
Explanation: The first non-whitespace character is 'w', which is not a numerical
digit or a +/- sign. Therefore no valid conversion could be performed.
Example 5:
Input: "-91283472332"
Output: -2147483648
Explanation: The number "-91283472332" is out of the range of a 32-bit signed integer.
Thefore INT_MIN (−231) is returned.
/**
* @param {string} str
* @return {number}
*/
var myAtoi = function (str) {
return Math.min(2147483647, Math.max(-2147483648, parseInt(str))) || 0
};
Looks like Number()
is faster than parseInt()
.
/**
* @param {string} str
* @return {number}
*/
var myAtoi = function (str) {
return Math.min(2147483647, Math.max(-2147483648, (/^ *[-+]?\d+/.exec(str) || [0])[0]))
};
General solution.
/**
* @param {string} str
* @return {number}
*/
var myAtoi = function (str) {
let sign = 1
let i = 0
while (i < str.length) {
const cc = str.charCodeAt(i++)
if (cc === 45) { // -
sign = -1
break
} else if (cc === 43) { // +
break
} else if (cc >= 48 && cc <= 57) { // 0-9
i--
break
} else if (cc !== 32) { // space
return 0
}
}
let result = 0
while (i < str.length) {
const digit = str.charCodeAt(i++) - 48
if (digit < 0 || digit > 9) {
break
}
result = result * 10 + digit
}
return Math.min(2147483647, Math.max(-2147483648, result * sign))
};
Template generated via Leetmark.


fun getVersionName(directRequest: Boolean): String
checks the current application version name
directRequest - used to either check directly the version name or get the value stored in the shared preference
directRequest
Return the version name


test
"Where there is coffee, there is life. Loves to read, paint and sleep."
FOLLOWERS
1293
FOLLOWING
219
STORIES
92


|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface WorkspaceWidget
WorkspaceWidgets are components within the workspace other than blocks that include bars, buttons, factory drawers, and single instance widgets such as the MiniMap and the TrashCan.
| Method Summary | |
|---|---|
void |
addBlock(RenderableBlock block)
Adds the specified block to this widget interally and graphically. |
void |
addBlocks(java.util.Collection<RenderableBlock> blocks)
Adds a collection of blocks to this widget internally and graphically. |
void |
blockDragged(RenderableBlock block)
Called by RenderableBlocks as they are dragged over this Widget. |
void |
blockDropped(RenderableBlock block)
Called by RenderableBlocks that get "dropped" onto this Widget |
void |
blockEntered(RenderableBlock block)
Called when a RenderableBlock is being dragged and goes from being outside this Widget to being inside the Widget. |
void |
blockExited(RenderableBlock block)
Called when a RenderableBlock that was being dragged over this Widget goes from being inside this Widget to being outside the Widget. |
boolean |
contains(int x,
int y)
Widgets must be able to report whether a given point is inside them |
java.lang.Iterable<RenderableBlock> |
getBlocks()
Returns the set of blocks that abstract "lives" inside this widget. |
javax.swing.JComponent |
getJComponent()
Very Java Swing dependent method |
void |
removeBlock(RenderableBlock block)
Used by RenderableBlocks to tell their originating Widgets that they're moving somewhere else and so should be removed. |
| Method Detail |
|---|
void blockDropped(RenderableBlock block)
block
- the RenderableBlock that is "dropped" onto this Widgetvoid blockDragged(RenderableBlock block)
block
- the RenderableBlock being draggedvoid blockEntered(RenderableBlock block)
block
- the RenderableBlock being draggedvoid blockExited(RenderableBlock block)
block
- the RenderableBlock being draggedvoid removeBlock(RenderableBlock block)
block
- the RenderableBlockvoid addBlock(RenderableBlock block)
block
- the desired RenderableBlock to add to thisvoid addBlocks(java.util.Collection<RenderableBlock> blocks)
blocks
- the Collection of RenderableBlocks to addboolean contains(int x, int y)
x
- y
- javax.swing.JComponent getJComponent()
java.lang.Iterable<RenderableBlock> getBlocks()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |


Elections: Here we go again?
The President is going to inform the Speaker of the Knesset that he has no candidate to form a government
by Arutz Sheva StaffPresident Reuven Rivlin will tomorrow (Thursday) inform the Knesset Speaker Yuli Edelstein that 28 days have passed since Gantz has received the mandate to create a government, with no success.
From tomorrow, 61 MKs can request from the President to ask for a specific MK to form a new government, which must be concluded within 21 days. Once the President receives such a letter, he must inform the MK within 2 days that he has the mandate to create a new government.
In the case that no such letter is received within 21 days, the President must inform the Speaker and the Knesset will disperse and new elections will be called for 90 days hence.


Degrees From Horizon is the amount you have to tilt your head to look at the satellite when standing in a flat field.
We believe the initial constellation will have connectivity if the satellite is above 25°, and that this requirement will later be eased to 40° to increase performance. Note: This number is how much of the whole sky (in all directions) will be required to be visible overhead to maintain constant connection to the constellation.


Experience
Graduate Assistant
University of Maryland School of Public Health Dept. of Communication, College Park, Md. | July 2017-present
Work with communications department staff to write press releases, update websites, collect photos and video. Also help manage social media accounts and department calendars.
Online ‘Real Time’ Reporter
Raleigh News & Observer, Raleigh, N.C. | March 2016-June 2017
Use social media and other online tools to identify and quickly write stories across many newsroom beats for North Carolina’s Pulitzer Prize-winning newspaper. Maintain social media and collect photos and videos. Promoted from: North Raleigh News reporter.
Cops and Courts Reporter
Lynchburg News & Advance, Lynchburg, Va. | May 2015 – March 2016
Monitored and covered criminal, civil and federal courts in five counties and in the City of Lynchburg. Identified and wrote stories about crime trends. Maintained Twitter and Facebook pages, collected photos and videos. Promoted from: Bedford County reporter.
General Assignment Reporter
Billings Gazette Communications, Billings, Mont. | Sept. 2013 - May 2015
Reported for a newspaper with more than 45,000 daily subscribers. Covered a range of subjects including Montana State University Billings, features, cops and courts, politics and breaking news. Maintained an active Twitter, and other social media. Recorded video for web-viewing. Promoted from morning reporter.
Self Help Law Center Volunteer
AmeriCorps VISTA, Billings, Mont. | Jan. 2013 - Sept. 2013
Managed and expanded self-help kiosk program; Assisted pro se litigants with legal issues; Created and conducted surveys; Trained volunteers; Traveled across Mont. networking with clerks of court; Helped draft pro se forms; Wrote articles for a poverty blog.
Assistant Music Director and DJ
KUAC FM 89.9 & KSUA FM 91.5, Fairbanks, Alaska | April 2012 - Dec. 2012
Wrote and reviewed new music. Hosted shows on NPR affiliate and College Station (both located at University of Alaska, Fairbanks).
Youth Development Coordinator
AmeriCorps State National, Fairbanks, Alaska | Jan. 2012 - Dec. 2012
Wrote and received three grants for youth programs; Started sustainable recycling program; Funded, designed, built and maintained large teaching garden (earned Master Gardener certification); Obtained, repaired and provided bicycles; Tutored, counseled and taught at-risk youth; Served as Creamer’s Field Wildlife Refuge Guide; Educated youth in partnership with Fairbanks Schools.
Reporter
Raleigh Public Record, Raleigh, N.C. | Fall 2011- Winter 2012
Wrote articles focused on municipal government issues, took editorial photos, assisted with elections coverage.
Intern
The Story with Dick Gordon, Chapel Hill, N.C. | Summer 2011
Performed general intern duties for nationally syndicated show, including: dubbing for shows, updating show archives, researching possible story ideas, locating interviewees, and pitching story ideas to producers.
News Intern
News Desk, WUNC, 91.5 FM, Durham, N.C.
Wrote copy for evening and morning newscasts; Gathered information and sound bites through interviews, research and observations; Assisted APM and NPR reporters to record interviews and upload tape-syncs.
Public Affairs Director
WKNC - 88.1, Raleigh, N.C. | Dec. 2010-Dec. 2011
Coordinated public affairs programming; Produced and recorded public service announcements; Planned and conducted Student Government debates and events; Created online multimedia for student media websites. Progressively promoted from: Assistant Promotions Director 2009-2010; Librarian 2008-2009; DJ 2007-2011.


Overview
Returns a list with the processes for Process Management
Summary
This endpoint gets a list of Processes.
Request Arguments
| Name |
Type |
Description |
Required |
| module_list |
string |
Identifier used to determine which status to filter against |
false |
| order_by |
string |
How to sort the returned records, in a comma delimited list with the direction appended to the column name after a colon. |
false |
| q |
string |
A search expression, will search on this module. Cannot be used at the same time as a filter expression or id. |
false |
| filter |
string |
The filter expression |
false |
| filter_id |
string |
Identifier for a preexisting filter. If filter is also set, the two filters are joined with an AND. |
false |
| max_num |
integer |
A maximum number of records to return. Default is 20. |
false |
| offset |
integer |
The number of records to skip over before records are returned. Default is 0. |
false |
| fields |
string |
Comma delimited list of fields to return |
false |
| deleted |
boolean |
Boolean to show deleted records in the result set. |
false |
Response Arguments
| Name |
Type |
Description |
| next_offset |
Integer |
Next offset |
| records |
<field>/<value> |
List of process attributes |
Response
{
{
"next_offset":-1,
"records":
[
{
"id":"3922976c-284f-11e6-9f40-6c4008960436",
"name":"ABC2",
"date_entered":"2016-06-01T16:18:59-07:00",
"date_modified":"2016-06-01T16:18:59-07:00",
"modified_user_id":"1",
"created_by":"1",
"deleted":"0",
"cas_id":"2",
"cas_parent":"0",
"cas_status":"IN PROGRESS",
"pro_id":"6e172e2c-2842-11e6-a4bb-6c4008960436",
"cas_title":"ABC2",
"cas_custom_status":"",
"cas_init_user":"1",
"cas_create_date":"2016-06-01T16:18:59-07:00",
"cas_update_date":"2016-06-01 23:18:59",
"cas_finish_date":null,
"cas_assigned_status":"UNASSIGNED",
"cas_module":"Accounts",
"team_id":"1",
"team_set_id":"1",
"assigned_user_id":"1",
"assigned_user_name":"Administrator",
"prj_id":"6e025038-2842-11e6-b4f7-6c4008960436",
"prj_created_by":"1",
"prj_module":"Accounts",
"cas_sugar_module":"Accounts",
"cas_sugar_object_id":"38beb03a-284f-11e6-b059-6c4008960436",
"pro_title":"PD1",
"prj_deleted":"0",
"prj_user_id_full_name":"Administrator",
"cas_user_id_full_name":"Sarah Smith"
},
}
}


var hoxy = require('hoxy');
The object returned from require('hoxy')
is just a namespace.
Represents a proxy server.
An instance of this is returned from hoxy.createServer()
.
Factory for a new proxy with given options. All options are optional.
var hoxy = require('hoxy'); var proxy = hoxy.createServer({ upstreamProxy: 'localhost:9090', reverse: 'http://example.com', certAuthority: { key, cert }, tls: { key, cert }, slow: { rate, latency, up, down } });
| name | description |
|---|---|
upstreamProxy |
Optional.
If present, this proxy will in turn use another proxy.
This allows Hoxy to play well with other proxies.
This value should take the form host:port .
|
reverse |
Optional.
If present, this proxy will run as a reverse proxy for the given server.
This allows you to point your client directly at the proxy, instead of configuring it in the client's proxy settings.
This value should take the form scheme://host:port .
|
certAuthority { key, cert } |
Optional. If present, this should contain a key/cert combo representing a certificate authority that your client trusts. See these instructions for how to generate these files. You'll then need to configure your client to use this proxy for https in addition to http. Once you've got all of that set up, Hoxy will generate fake keys/cert combos for every hostname you visit, caching them in memory for subsequent visits, thus allowing the proxy to handle https requests as cleartext. |
tls { key, cert } |
Optional.
Should only be used in comination with reverse .
If present, causes Hoxy to run as an https server.
Passed as opts to https.createServer(opts, function) (see the https module docs).
|
slow { rate, latency, up, down } |
Optional.
up and down are independent.
However, rate and up (if they both exist) form a pipeline; the slower of the two governing the total speed.
The same is true of rate and down .
These properties can also be get/set by using proxy.slow() .
|
Starts proxy listening on port
.
Returns itself.
var hoxy = require('hoxy'); var proxy = hoxy.createServer().listen(8080);
A callback may be provided, to run when the proxy has started listening.
var hoxy = require('hoxy'); var port = 8080; var proxy = hoxy.createServer().listen(port, function() { console.log('The proxy is listening on port ' + port + '.'); });
This method simply passes its arguments to Node's server.listen()
method.
Get/set proxy-level slow options.
If options
is provided, it's a setter.
proxy.slow({ rate, latency, up, down });
If options
is not provided, it's a getter.
var slowOpts = proxy.slow();
This is the entry point for intercepting and operating on requests and responses. This first example intercepts all requests.
proxy.intercept('request', req => console.log(req.url));
This is more verbose, but identical to the above.
proxy.intercept({ phase: 'request' }, function(req, resp, cycle) { console.log(req.url); });
The callback passed to intercept()
(AKA the interceptor) receives three arguments (req, resp, cycle)
which are instances of classes described below.
cycle
is also passed as context.
Thus:
proxy.intercept('request', function(req, resp, cycle) { console.log(this === cycle) // true });
Hoxy internally runs everything sequentially in series, including interceptors. That happens naturally when your interceptor logic is synchronous. But if it's asynchronous, you must signal that by returning a promise. As long as you do that, Hoxy will wait until the promise resolves and things will flow serially.
proxy.intercept('request', function(req, resp, cycle) { // return a promise from the interceptor return getThingA().then(function(thingA) { return getThingB(thingA); }).then(function(thingB) { // do something with "thingB" }); });
Future versions of JavaScript will allow async functions. Some transpilers allow you to use this syntax today. These can be used as interceptors, too. Written this way, your logic and your error handling are much cleaner.
proxy.intercept('request', async function(req, resp, cycle) { // this is an async function let thingA = await getThingA(); let thingB = await getThingB(thingA); // do something with "thingB" });
In current versions of io.js, generators can be used as a stand-in for async functions, but with the benefit of being natively-supported, spec-valid ES6 syntax. You must only yield promises from your generator. See co for more details.
proxy.intercept('request', function*(req, resp, cycle) { // this is a generator let thingA = yield getThingA(); let thingB = yield getThingB(thingA); // do something with "thingB" });
Note: Strictly speaking, Hoxy doesn't care whether your interceptor is an async function or a generator. It only cares what kind of thing the return value is:
Options affect how, or if, interceptors get called.
Here are a few examples.
The following will only intercept GET
requests to example.com
.
proxy.intercept({ phase: 'request', method: 'GET', hostname: 'example.com' }, function(req, resp, cycle) { console.log('request made to: '+req.url); });
The following only intercepts text/html
responses.
When it does, it exposes the response body as a readable/writable $
variable.
proxy.intercept({ phase: 'response', mimeType: 'text/html', as: '$' }, function(req, resp, cycle) { resp.$('title') .text('all your titles are belong to us'); });
The following only intercepts responses with a declared charset.
When it does, it exposes the response body as the string
variable.
proxy.intercept({ phase: 'response', contentType: /charset/i, as: 'string' }, function(req, resp, cycle) { console.log(resp.string); });
The following only intercepts responses from an /api/users
JSON endpoint.
When it does, it exposes the response body as the json
variable.
It uses a URL pattern to match the endpoint URL instead of a regex.
proxy.intercept({ phase: 'response', fullUrl: 'http://example.com/api/users/:id', mimeType: 'application/json', as: 'json' }, function(req, resp, cycle) { console.log(resp.json.email_address); });
| name | type | required | description |
|---|---|---|---|
phase |
string | yes |
Which phase to intercept.
See phase lifecycle for more info.
Accepted values:
|
as |
string | no |
Expose the request or response body (depending on the phase) as data of a certain type.
If there's an error parsing the body into this form, the intercept action is skipped and a warning is logged.
Hoxy normally streams request and response bodies through.
If as is present, hoxy buffers the request or response body into memory.
Accepted values:
'json' with mimeType:'application/json' .
|
| Filtering options (these are logically ANDed together) | |||
| name | type | required | description |
protocol |
string, regex, function | no | Match the request protocol. |
method |
string, regex, function | no | Match the all-uppercase HTTP request method. |
hostname |
string, regex, function | no | Match the host, not including :port. |
port |
number, string, regex, function | no | Match the port number. |
url |
string, regex, function | no |
Match the request URL.
Patterns like /foo/* are allowed.
See route-pattern.
|
fullUrl |
string, regex, function | no |
Match the full request URL including protocol and hostname.
Patterns like /foo/* are allowed.
See route-pattern.
|
contentType |
string, regex, function | no |
Match the full content-type header of the request or response (depending on the phase).
|
requestContentType |
string, regex, function | no |
Same as contentType but only matches request.
|
responseContentType |
string, regex, function | no |
Same as contentType but only matches response.
|
mimeType |
string, regex, function | no |
Match just the mime type portion of the content-type header of the request or response (depending on the phase). I.e., if the entire header is "text/html; charset=utf-8" , just match the "text/html" part.
|
requestMimeType |
string, regex, function | no |
Same as mimeType but only matches request.
|
responseMimeType |
string, regex, function | no |
Same as mimeType but only matches response.
|
status |
number, string, regex, function | no | Match the status code of the response. Only used during response phase. |
Note: filtering options can be different types.
==
) match.
Deals with various logging events.
This first example listens for error
, warn
, and debug
logging events, and prints them to stderr
.
proxy.log('error warn debug');
Or, print logging events to various writable streams.
proxy.log('error warn debug', process.stderr); proxy.log('info', process.stdout);
Or, explicitly handle logging events.
proxy.log('error warn', function(event) { console.error(event.level + ': ' + event.message); if (event.error) console.error(event.error.stack); });
| name | description |
|---|---|
error |
When something bad happens that we wish wouldn't have happened. |
warn |
When something iffy happened that we can probably tolerate. |
info |
When something noteworthy happened that normal people care about. |
debug |
When something boring happened that developers care about. |
Stops proxy receiving requests. Finalizes and/or cleans up any resources the proxy uses internally.
proxy.close(function(err) { // optional callback if (err) { throw err; } console.log('The proxy is no longer accepting new connections.'); });
Represents a request.
An instance of this is passed as the first argument to every interceptor.
Altering its values changes what the server sees.
If you change the hostname
, it changes which server sees the request.
Protocol of the request.
Destination server hostname, sans port.
Destination server port.
All-caps HTTP method used. Lowercase values are converted to uppercase.
HTTP request header name/value JS object.
These are all-lowercase, e.g. accept-encoding
.
Root-relative request URL, including query string, like /foo/bar?baz=qux
An object representing querystring params in the URL.
For example if the URL is /foo/bar?baz=qux
, then this object will look like { baz: 'qux' }
.
Request body parsed as JSON.
This is only present if you intercept the request as:'json'
.
Changes made to this object will be seen by the server.
proxy.intercept({ phase: 'request', method: 'PUT', fulUrl: 'http://example.com/users/:id', as: 'json' }, function(req, resp, cycle) { req.json.prefs.subscriptions = 'all'; });
Request body parsed as form-url-encoded params.
This will be a key/value POJO.
This object will only present if you intercept the request as:'params'
.
Changes made to this object will be seen by the server.
proxy.intercept({ phase: 'request', method: 'POST', mimeType: 'application/x-www-form-urlencoded', as: 'params' }, function(req, resp, cycle) { console.log(req.params.email); });
Note, parameters from the URL querystring are not included in this object.
Request body string.
This is only present if you intercept the request as:'string'
.
Overwriting this will overwrite the request body sent to the server.
proxy.intercept({ phase: 'request', fulUrl: 'http://example.com/users/:id', as: 'string' }, function(req, resp, cycle) { console.log(req.string); });
Request body binary buffer.
This is only present if you intercept the request as:'buffer'
.
Changes made to this object will be seen by the server.
proxy.intercept({ phase: 'request', method: 'POST', fullUrl: 'http://example.com/images', as: 'buffer' }, function(req, resp, cycle) { // req.buffer contains uploaded image });
Simulates slowness during request phase. With this method you can set a minimum latency and/or maximum transfer rate. Since these are minimum/maximum, if your native connection is already slower than these values, this method will have no effect.
// Simulate upload speed of 10,000 bytes per second proxy.intercept('request', function(req, resp, cycle) { req.slow({rate:10000}); // bytes per second });
// Simulate a 500-1000ms delay on every request. proxy.intercept('request', function(req, resp, cycle) { req.slow({latency:randint(500, 1000)}); });
If url
is provided, sets the request's absolute protocol, hostname, port and url.
Otherwise it returns the absolute URL of this request.
This is mainly a convenience method.
// Log every request through the proxy. proxy.intercept('request', function(req, resp, cycle) { console.log(req.fullUrl()); });
Whatever request body gets sent to the server, tee()
pipes an identical copy to your writable stream.
Your stream is held in memory, and only gets written to if and when the request is sent to the server.
In other words, your stream sees whatever the server sees.
If the server sees nothing, your stream sees nothing.
You can tee()
as many times as you want.
proxy.intercept({ phase: 'request', method: /post|put/i, mimeType: 'application/json' }, function(req, resp, cycle) { req.tee(fs.createWriteStream('./uploaded.json')); });
Represents a response.
An instance of this is passed as the second argument to every interceptor.
This object is unpopulated during the request
and request-sent
phases.
Altering its values changes the response to the client.
HTTP status code being sent to the client.
HTTP response header name/value JS object.
Header names are all-lowercase, such as 'content-type'
.
Response body parsed as DOM.
This object is only present if you intercept the response as:'$'
.
This is a cheerio object, which provides a jQuery-like API.
Changes made to it will be seen by the client.
proxy.intercept({ phase: 'response', fullUrl: 'http://example.com/page.html', as: '$' }, function(req, resp, cycle) { // change the title of the page resp.$('title').text('Fake Title!'); });
Response body parsed as JSON.
This is only present if you intercept the response as:'json'
.
Changes to this object will be seen by the client.
proxy.intercept({ phase: 'response', method: 'GET', fullUrl: 'http://example.com/users/123', as: 'json' }, function(req, resp, cycle) { // arbitrarily manipulate the response json resp.json.foo = 'bar'; });
Response body string.
This is only present if you intercept the response as:'string'
.
Overwriting this will overwrite the response body sent to the client.
proxy.intercept({ phase: 'response', fullUrl: 'http://example.com/page.html', as: 'string' }, function(req, resp, cycle) { // print page to log console.log(resp.string); });
Response body binary buffer.
This is only present if you intercept the response as:'buffer'
.
Changes made to this object will be seen by the client.
proxy.intercept({ phase: 'response', fullUrl: 'http://example.com/image.jpg', as: 'buffer' }, function(req, resp, cycle) { // resp.buffer contains a jpg });
Simulates a slow response. With this method you can set a minimum latency and/or maximum transfer rate. Since these are minimum/maximum, if your native connection is already slower than these values, this method has no effect.
// Simulate download speed of 100,000 bytes per second proxy.intercept('response', function(req, resp, cycle) { resp.slow({rate:100000}); // bytes per second });
// Simulate a 500-1000ms delay on every response. proxy.intercept('response', function(req, resp, cycle) { resp.slow({latency:randint(500, 1000)}); });
Whatever response body gets sent to the client, tee()
pipes an identical copy to your writable stream.
Your stream is held in memory, and only gets written to when the response is sent to the client.
In other words, your stream sees whatever the client sees.
You can tee()
as many times as you want.
proxy.intercept({ phase: 'response', mimeType: 'image/gif' }, function(req, resp, cycle) { resp.tee(fs.createWriteStream('./image.gif')); });
Represents a whole request/response cycle.
A Cycle instance is this
in all interceptor calls, and the same instance is shared across an entire request/response cycle.
It's also passed as the third argument, in order to support arrow functions.
It provides a small number of methods not associated specifically to either the request or response.
Provisions responses from the local filesystem.
Generally, the reason you'd do this is to be able to edit those files locally and test them as if they were live on the remote server.
This action populates the response object; see response population for more info.
The completion of this action is asynchronous, so serve()
returns a promise.
Example.
proxy.intercept({ phase: 'request', fullUrl: 'http://example.com/main.js' }, function(req, resp, cycle) { return cycle.serve('/Users/gr123/test/main.js'); });
Or the more verbose-but-identical...
proxy.intercept({ phase: 'request', fullUrl: 'http://example.com/main.js' }, function(req, resp, cycle) { return cycle.serve({ path: '/Users/gr123/test/main.js' }); });
| name | type | required | description |
|---|---|---|---|
| path | string | no |
Which file to serve.
Defaults to the request URL.
Normally this would be used in mutual exclusion with docroot .
Strictly speaking, path is always rooted to docroot , which defaults to "/" .
|
| docroot | string | no |
Which local directory to serve out of.
Defaults to filesystem root "/" .
|
| strategy | string | no |
Mainly relevant when using the docroot option.
Describes the relationship between the local docroot and the remote one.
Strictly speaking, this controls what happens when the local docroot is missing a requested file.
Accepted values:
|
The returned promise resolves after the response has been populated. There are at least three use cases worth mentioning.
Use case #1: Serve a specific file. First:
$ curl http://example.com/js/main.js > main.js
...then:
proxy.intercept({ phase: 'request', fullUrl: 'http://example.com/js/main.js' }, function(req, resp, cycle) { return cycle.serve(__dirname + '/main.js'); });
Use case #2: Serve out of a local docroot. First:
$ mkdir js $ curl http://example.com/js/main.js > js/main.js $ curl http://example.com/js/some-lib.js > js/some-lib.js $ curl http://example.com/js/other-lib.js > js/other-lib.js ...
...then:
proxy.intercept({ phase: 'request', hostname: 'example.com', url: /^\/js\/.*/ }, function(req, resp, cycle) { return cycle.serve({ docroot: __dirname, strategy: 'overlay' }); });
Use case #3: Serve out of a local docroot. Similar to above, but automatically downloads the files for you, instead of having to curl them as in the above example. You control which files get downloaded locally by the filtering options you provide.
proxy.intercept({ phase: 'request', hostname: 'example.com', url: /^\/js\/.*/ }, function(req, resp, cycle) { return cycle.serve({ docroot: __dirname, strategy: 'mirror' }); });
Stores and retrieves data on a cycle instance. This is useful since the same instance is shared across all interceptors for a given request/response cycle, allowing you to share related data across disparate scopes. With two params this method behaves as a setter, with one param as a getter.
['request','request-sent','response','response-sent'] .forEach(function(phase) { proxy.intercept(phase, function(req, resp, cycle) { cycle.data(phase, Date.now()); }); }); proxy.intercept('response-sent', function(req, resp, cycle) { var reqReceived = cycle.data('request'); var reqSent = cycle.data('request-sent'); var respReceived = cycle.data('response'); var respSent = cycle.data('response-sent'); // now print some profiling data });
hoxy.createServer({ reverse: 'https://www.google.com', tls: { key: fs.readFileSync('path/to/my-server.key.pem), cert: fs.readFileSync('path/to/my-server.crt.pem') } }).listen(8080)
The tls
option is passed to the underlying Node HTTPS server.


--- layout: post title: "Rose tree catamorphism" description: "The catamorphism for a tree with different types of nodes and leaves is made up from two functions." date: 2019-08-05 8:30 UTC tags: [Software Design, Haskell] image: "/content/binary/rose-tree-example.png" image_alt: "A rose tree example diagram, with internal nodes containing integers, and leafs containing strings." --- {% include JB/setup %}
{{ page.description }}
This article is part of an article series about catamorphisms. A catamorphism is a universal abstraction that describes how to digest a data structure into a potentially more compact value.
This article presents the catamorphism for a rose tree, as well as how to identify it. The beginning of this article presents the catamorphism in C#, with examples. The rest of the article describes how to deduce the catamorphism. This part of the article presents my work in Haskell. Readers not comfortable with Haskell can just read the first part, and consider the rest of the article as an optional appendix.
A rose tree is a general-purpose data structure where each node in a tree has an associated value. Each node can have an arbitrary number of branches, including none. The distinguishing feature from a rose tree and just any tree is that internal nodes can hold values of a different type than leaf values.
The diagram shows an example of a tree of internal integers and leaf strings. All internal nodes contain integer values, and all leaves contain strings. Each node can have an arbitrary number of branches.
As a C# representation of a rose tree, I'll use the Church-encoded rose tree I've previously described. The catamorphism is this extension method:
public static TResult Cata<N, L, TResult>( this IRoseTree<N, L> tree, Func<N, IEnumerable<TResult>, TResult> node, Func<L, TResult> leaf) { return tree.Match( node: (n, branches) => node(n, branches.Select(t => t.Cata(node, leaf))), leaf: leaf); }
Like most of the other catamorphisms shown in this article series, this one consists of two functions. One that handles the leaf case, and one that handles the partially reduced node case. Compare it with the tree catamorphism: notice that the rose tree catamorphism's node
function is identical to the the tree catamorphism. The leaf
function, however, is new.
In previous articles, you've seen other examples of catamorphisms for Church-encoded types. The most common pattern has been that the Church encoding (the Match
method) was also the catamorphism, with the Peano catamorphism being the only exception so far. When it comes to the Peano catamorphism, however, I'm not entirely confident that the difference between Church encoding and catamorphism is real, or whether it's just an artefact of the way I originally designed the Church encoding.
When it comes to the present rose tree, however, notice that the catamorphisms is distinctly different from the Church encoding. That's the reason I called the method Cata
instead of Match
.
The method simply delegates the leaf
handler to Match
, while it adds behaviour to the node
case. It works the same way as for the 'normal' tree catamorphism.
You can use Cata
to implement most other behaviour you'd like IRoseTree<N, L>
to have. In a future article, you'll see how to turn the rose tree into a bifunctor and functor, so here, we'll look at some other, more ad hoc, examples. As is also the case for the 'normal' tree, you can calculate the sum of all nodes, if you can associate a number with each node.
Consider the example tree in the above diagram. You can create it as an IRoseTree<int, string>
object like this:
IRoseTree<int, string> exampleTree = RoseTree.Node(42, RoseTree.Node(1337, new RoseLeaf<int, string>("foo"), new RoseLeaf<int, string>("bar")), RoseTree.Node(2112, RoseTree.Node(90125, new RoseLeaf<int, string>("baz"), new RoseLeaf<int, string>("qux"), new RoseLeaf<int, string>("quux")), new RoseLeaf<int, string>("quuz")), new RoseLeaf<int, string>("corge"));
If you want to calculate a sum for a tree like that, you can use the integers for the internal nodes, and perhaps the length of the strings of the leaves. That hardly makes much sense, but is technically possible:
> exampleTree.Cata((x, xs) => x + xs.Sum(), x => x.Length) 93641
Perhaps slightly more useful is to count the number of leaves:
> exampleTree.Cata((_, xs) => xs.Sum(), _ => 1) 7
A leaf node has, by definition, exactly one leaf node, so the leaf
lambda expression always returns 1
. In the node
case, xs
contains the partially summed leaf node count, so just Sum
those together while ignoring the value of the internal node.
You can also measure the maximum depth of the tree:
> exampleTree.Cata((_, xs) => 1 + xs.Max(), _ => 0) 3
Consistent with the example for 'normal' trees, you can arbitrarily decide that the depth of a leaf node is 0
, so again, the leaf
lambda expression just returns a constant value. The node
lambda expression takes the Max
of the partially reduced xs
and adds 1
, since an internal node represents another level of depth in a tree.
As in the previous article, I'll use Fix
and cata
as explained in Bartosz Milewski's excellent article on F-Algebras.
As always, start with the underlying endofunctor:
data RoseTreeF a b c = NodeF { nodeValue :: a, nodes :: ListFix c } | LeafF { leafValue :: b } deriving (Show, Eq, Read) instance Functor (RoseTreeF a b) where fmap f (NodeF x ns) = NodeF x $ fmap f ns fmap _ (LeafF x) = LeafF x
Instead of using Haskell's standard list ([]
) for the nodes, I've used ListFix
from the article on list catamorphism. This should, hopefully, demonstrate how you can build on already established definitions derived from first principles.
As usual, I've called the 'data' types a
and b
, and the carrier type c
(for carrier). The Functor
instance as usual translates the carrier type; the fmap
function has the type (c -> c1) -> RoseTreeF a b c -> RoseTreeF a b c1
.
As was the case when deducing the recent catamorphisms, Haskell isn't too happy about defining instances for a type like Fix (RoseTreeF a b)
. To address that problem, you can introduce a newtype
wrapper:
newtype RoseTreeFix a b = RoseTreeFix { unRoseTreeFix :: Fix (RoseTreeF a b) } deriving (Show, Eq, Read)
You can define Bifunctor
, Bifoldable
, Bitraversable
, etc. instances for this type without resorting to any funky GHC extensions. Keep in mind that ultimately, the purpose of all this code is just to figure out what the catamorphism looks like. This code isn't intended for actual use.
A pair of helper functions make it easier to define RoseTreeFix
values:
roseLeafF :: b -> RoseTreeFix a b roseLeafF = RoseTreeFix . Fix . LeafF roseNodeF :: a -> ListFix (RoseTreeFix a b) -> RoseTreeFix a b roseNodeF x = RoseTreeFix . Fix . NodeF x . fmap unRoseTreeFix
roseLeafF
creates a leaf node:
Prelude Fix List RoseTree> roseLeafF "ploeh" RoseTreeFix {unRoseTreeFix = Fix (LeafF "ploeh")}
roseNodeF
is a helper function to create internal nodes:
Prelude Fix List RoseTree> roseNodeF 6 (consF (roseLeafF 0) nilF) RoseTreeFix {unRoseTreeFix = Fix (NodeF 6 (ListFix (Fix (ConsF (Fix (LeafF 0)) (Fix NilF)))))}
Even with helper functions, construction of RoseTreeFix
values is cumbersome, but keep in mind that the code shown here isn't meant to be used in practice. The goal is only to deduce catamorphisms from more basic universal abstractions, and you now have all you need to do that.
At this point, you have two out of three elements of an F-Algebra. You have an endofunctor (RoseTreeF a b
), and an object c
, but you still need to find a morphism RoseTreeF a b c -> c
. Notice that the algebra you have to find is the function that reduces the functor to its carrier type c
, not any of the 'data types' a
or b
. This takes some time to get used to, but that's how catamorphisms work. This doesn't mean, however, that you get to ignore a
or b
, as you'll see.
As in the previous articles, start by writing a function that will become the catamorphism, based on cata
:
roseTreeF = cata alg . unRoseTreeFix where alg (NodeF x ns) = undefined alg (LeafF x) = undefined
While this compiles, with its undefined
implementations, it obviously doesn't do anything useful. I find, however, that it helps me think. How can you return a value of the type c
from the LeafF
case? You could pass a function argument to the roseTreeF
function and use it with x
:
roseTreeF fl = cata alg . unRoseTreeFix where alg (NodeF x ns) = undefined alg (LeafF x) = fl x
While you could, technically, pass an argument of the type c
to roseTreeF
and then return that value from the LeafF
case, that would mean that you would ignore the x
value. This would be incorrect, so instead, make the argument a function and call it with x
. Likewise, you can deal with the NodeF
case in the same way:
roseTreeF :: (a -> ListFix c -> c) -> (b -> c) -> RoseTreeFix a b -> c roseTreeF fn fl = cata alg . unRoseTreeFix where alg (NodeF x ns) = fn x ns alg (LeafF x) = fl x
This works. Since cata
has the type Functor f => (f a -> a) -> Fix f -> a
, that means that alg
has the type f a -> a
. In the case of RoseTreeF
, the compiler infers that the alg
function has the type RoseTreeF a b c -> c
, which is just what you need!
You can now see what the carrier type c
is for. It's the type that the algebra extracts, and thus the type that the catamorphism returns.
This, then, is the catamorphism for a rose tree. As has been the most common pattern so far, it's a pair, made from two functions. It's still not the only possible catamorphism, since you could trivially flip the arguments to roseTreeF
, or the arguments to fn
.
I've chosen the representation shown here because it's similar to the catamorphism I've shown for a 'normal' tree, just with the added function for leaves.
You can implement most other useful functionality with roseTreeF
. Here's the Bifunctor
instance:
instance Bifunctor RoseTreeFix where bimap f s = roseTreeF (roseNodeF . f) (roseLeafF . s)
Notice how naturally the catamorphism implements bimap
.
From that instance, the Functor
instance trivially follows:
instance Functor (RoseTreeFix a) where fmap = second
You could probably also add Applicative
and Monad
instances, but I find those hard to grasp, so I'm going to skip them in favour of Bifoldable
:
instance Bifoldable RoseTreeFix where bifoldMap f = roseTreeF (\x xs -> f x <> fold xs)
The Bifoldable
instance enables you to trivially implement the Foldable
instance:
instance Foldable (RoseTreeFix a) where foldMap = bifoldMap mempty
You may find the presence of mempty
puzzling, since bifoldMap
takes two functions as arguments. Is mempty
a function?
Yes, mempty
can be a function. Here, it is. There's a Monoid
instance for any function a -> m
, where m
is a Monoid
instance, and mempty
is the identity for that monoid. That's the instance in use here.
Just as RoseTreeFix
is Bifoldable
, it's also Bitraversable
:
instance Bitraversable RoseTreeFix where bitraverse f s = roseTreeF (\x xs -> roseNodeF <$> f x <*> sequenceA xs) (fmap roseLeafF . s)
You can comfortably implement the Traversable
instance based on the Bitraversable
instance:
instance Traversable (RoseTreeFix a) where sequenceA = bisequenceA . first pure
That rose trees are Traversable
turns out to be useful, as a future article will show.
As was the case for 'normal' trees, the catamorphism for rose trees is more powerful than the fold. There are operations that you can express with the Foldable
instance, but other operations that you can't. Consider the tree shown in the diagram at the beginning of the article. This is also the tree that the above C# examples use. In Haskell, using RoseTreeFix
, you can define that tree like this:
exampleTree = roseNodeF 42 ( consF ( roseNodeF 1337 ( consF (roseLeafF "foo") $ consF (roseLeafF "bar") nilF)) $ consF ( roseNodeF 2112 ( consF ( roseNodeF 90125 ( consF (roseLeafF "baz") $ consF (roseLeafF "qux") $ consF (roseLeafF "quux") nilF)) $ consF (roseLeafF "quuz") nilF)) $ consF ( roseLeafF "corge") nilF)
You can trivially calculate the sum of string lengths of all leaves, using only the Foldable
instance:
Prelude RoseTree> sum $ length <$> exampleTree 25
You can also fairly easily calculate a sum of all nodes, using the length of the strings as in the above C# example, but that requires the Bifoldable
instance:
Prelude Data.Bifoldable Data.Semigroup RoseTree> bifoldMap Sum (Sum . length) exampleTree Sum {getSum = 93641}
Fortunately, we get the same result as above.
Counting leaves, or measuring the depth of a tree, on the other hand, is impossible with the Foldable
instance, but interestingly, it turns out that counting leaves is possible with the Bifoldable
instance:
countLeaves :: (Bifoldable p, Num n) => p a b -> n countLeaves = getSum . bifoldMap (const $ Sum 0) (const $ Sum 1)
This works well with the example tree:
Prelude RoseTree> countLeaves exampleTree 7
Notice, however, that countLeaves
works for any Bifoldable
instance. Does that mean that you can 'count the leaves' of a tuple? Yes, it does:
Prelude RoseTree> countLeaves ("foo", "bar") 1 Prelude RoseTree> countLeaves (1, 42) 1
Or what about EitherFix
:
Prelude RoseTree Either> countLeaves $ leftF "foo" 0 Prelude RoseTree Either> countLeaves $ rightF "bar" 1
Notice that 'counting the leaves' of tuples always returns 1
, while 'counting the leaves' of Either
always returns 0
for Left
values, and 1
for Right
values. This is because countLeaves
considers the left, or first, data type to represent internal nodes, and the right, or second, data type to indicate leaves.
You can further follow that train of thought to realise that you can convert both tuples and EitherFix
values to small rose trees:
fromTuple :: (a, b) -> RoseTreeFix a b fromTuple (x, y) = roseNodeF x (consF (roseLeafF y) nilF) fromEitherFix :: EitherFix a b -> RoseTreeFix a b fromEitherFix = eitherF (`roseNodeF` nilF) roseLeafF
The fromTuple
function creates a small rose tree with one internal node and one leaf. The label of the internal node is the first value of the tuple, and the label of the leaf is the second value. Here's an example:
Prelude RoseTree> fromTuple ("foo", 42) RoseTreeFix {unRoseTreeFix = Fix (NodeF "foo" (ListFix (Fix (ConsF (Fix (LeafF 42)) (Fix NilF)))))}
The fromEitherFix
function turns a left value into an internal node with no leaves, and a right value into a leaf. Here are some examples:
Prelude RoseTree Either> fromEitherFix $ leftF "foo" RoseTreeFix {unRoseTreeFix = Fix (NodeF "foo" (ListFix (Fix NilF)))} Prelude RoseTree Either> fromEitherFix $ rightF 42 RoseTreeFix {unRoseTreeFix = Fix (LeafF 42)}
While counting leaves can be implemented using Bifoldable
, that's not the case for measuring the depths of trees (I think; leave a comment if you know of a way to do this with one of the instances shown here). You can, however, measure tree depth with the catamorphism:
treeDepth :: RoseTreeFix a b -> Integer treeDepth = roseTreeF (\_ xs -> 1 + maximum xs) (const 0)
The implementation is similar to the implementation for 'normal' trees. I've arbitrarily decided that leaves have a depth of zero, so the function that handles leaves always returns 0
. The function that handles internal nodes receives xs
as a partially reduced list of depths below the node in question. Take the maximum of those and add 1
, since each internal node has a depth of one.
Prelude RoseTree> treeDepth exampleTree 3
This, hopefully, illustrates that the catamorphism is more capable, and that the fold is just a (list-biased) specialisation.
The catamorphism for rose trees is a pair of functions. One function transforms internal nodes with their partially reduced branches, while the other function transforms leaves.
For a realistic example of using a rose tree in a real program, see Picture archivist in Haskell.
This article series has so far covered progressively more complex data structures. The first examples (Boolean catamorphism and Peano catamorphism) were neither functors, applicatives, nor monads. All subsequent examples, on the other hand, are all of these, and more. The next example presents a functor that's neither applicative nor monad, yet still foldable. Obviously, what functionality it offers is still based on a catamorphism.
Comments
Because of this sentence, in the picture of an example after the containing paragraph, I expected to see a(n) (internal) node with no branches.
Max
will throw an exception when given an internal node with no children. What value do you want to return in that case?Tyson, thank you for writing. You're right that my implementation doesn't properly handle the empty edge case. That's also the case for Haskell's
maximum
function. I find it annoying that it's a partial function.One can handle that edge case by assigning an arbitrary depth to an empty node, just as is the case for leaf nodes. If leaf nodes get assigned a depth of 0, wouldn't it be natural to also give empty internal nodes a depth of 0?
Yes, very natural. In particular, such a definition would be consistent with the corresponding definition for
Tree<>
. More specifically, we want the behaviors to be the same when the two type parameters inIRoseTree<,>
are the same (and the function passed in forleaf
is the same as the one passed in fornode
after fixing the second argument toEnumberable.Empty<TResult>()>
).I think the smallest change to get the depth to be
0
for an internal node with no children is to replaceMax
with a slight variant that returns-1
when there are no children. I don't think this is readable though. It is quite the magic number. But it is just the codification of the thought process that lead to it.It is because of such edge cases that Jeremy Gibbons in his PhD thesis Algebras for Tree Algorithms says (on page 44) that the internal nodes of his rose tree must include at least one child.
I think Jeremy has me convinced. One could say that this heterogenous rose tree was obtained from the homogeneous variant by adding a type for the leaves. The homogeneous variant denoted leaves via an empty list of children. It makes sense then to remove the empty list approach for making a leaf when adding the typed approach. So, I think the best fix then would be to modify your definition of
RoseNode<,>
in your first rose tree article to be the same as Jeremy's (by requiring thatIEnumerable<>
of children is non-empty). This change would also better match your example pictures of a rose tree, which do not include an internal node without children.Yes, it'd definitely be an option to change the definition of an internal node to a NonEmptyCollection.
My underlying motivation for defining the type like I've done in these articles, however, was to provide the underlying abstraction for a functional file system. In order to model a file system, empty nodes should be possible, because they correspond to empty directories.


|
Bitstream Interpretation Library (BIL)
0.1
|
Contains definition of text message constants for bitcorrelate. More...
#include <datagen/bitcorrelate/bitcorrelateMsgs.hpp>
Go to the source code of this file.
Variables | |
| const char *const | SPLASH_MSG = "bitcorrelate version 0.1\nCopyright (c) 2011 Florian Benz\n\n" |
| const char *const | PARSING_XDL_HEADER_MSG = "Parsing XDL header...\n" |
| const char *const | LOADING_DEVICE1_MSG = "Loading device " |
| const char *const | LOADING_DEVICE2_MSG = "... \n" |
| const char *const | PARSING_XDL_MSG = "Parsing XDL...\n" |
| const char *const | LOADING_CFGTILEMAP_MSG = "\nLoading configuration tile map file...\n" |
| const char *const | LOADING_BITFILE_MSG = "\nLoading bitfile...\n" |
| const char *const | DECODING_BITSTREAM_MSG = "Decoding bitstream...\n" |
| const char *const | LOADING_DEVICELIST_MSG = "Loading device list...\n" |
| const char *const | LOADING_ADDRESSLAYOUT1_MSG = "Loading address layout for " |
| const char *const | LOADING_ADDRESSLAYOUT2_MSG = "...\n" |
| const char *const | EXECUTING_BITSTREAM_MSG = "Executing bitstream...\n" |
| const char *const | DOING_CORRELATION_MSG = "\nDoing correlation...\n" |
| const char *const | WRITING_DATABASE_MSG = "\nWriting database...\n" |
| const char *const | WRITING_STATS_MSG = "Writing statistics...\n" |
| const char *const | FINISHED_MSG = "\nFinished.\n" |
| const char *const | INFO_MSG = " of the PIPs and configuration options.\n\n" |
| const char *const | ERROR_MSG = "Error: " |
| const char *const | ERROR_UNKNOWN_MSG = "Unknown error occurred.\n" |
| const char *const | ERROR_TOO_MANY_PARAMETERS_MSG = "Too many parameters!" |
| const char *const | ERROR_UNKNOWN_OPTION_1_MSG = "Unknown option \"" |
| const char *const | ERROR_UNKNOWN_OPTION_2_MSG = "\"!" |
| const char *const | ERROR_NO_BIT_FILE_MSG = "No bitfile specified!" |
| const char *const | ERROR_NO_XDL_FILE_MSG = "No XDL file specified!" |
| const char *const | ERROR_NO_DB_FILE_MSG = "No data base file specified!" |
| const char *const | ERROR_NO_STATSFILE_MSG = "No statistics file specified!" |
| const char *const | ERROR_NO_DATAPATH_MSG = "No data path specified!" |
| const char *const | DEVICE_FILE_EXT = ".dev" |
| const char *const | MAP_FILE_EXT = ".map" |
| const char *const | V5DEVICES_FILENAME = "\\v5devices.lst" |
| const char *const | CAL_FILE_EXT = ".cal" |
Contains definition of text message constants for bitcorrelate.
Definition in file bitcorrelateMsgs.cpp.
| const char* const SPLASH_MSG = "bitcorrelate version 0.1\nCopyright (c) 2011 Florian Benz\n\n" |
Definition at line 9 of file bitcorrelateMsgs.cpp.
| const char* const PARSING_XDL_HEADER_MSG = "Parsing XDL header...\n" |
Definition at line 12 of file bitcorrelateMsgs.cpp.
| const char* const LOADING_DEVICE1_MSG = "Loading device " |
Definition at line 15 of file bitcorrelateMsgs.cpp.
| const char* const LOADING_DEVICE2_MSG = "... \n" |
Definition at line 18 of file bitcorrelateMsgs.cpp.
| const char* const PARSING_XDL_MSG = "Parsing XDL...\n" |
Definition at line 21 of file bitcorrelateMsgs.cpp.
| const char* const LOADING_CFGTILEMAP_MSG = "\nLoading configuration tile map file...\n" |
Definition at line 24 of file bitcorrelateMsgs.cpp.
| const char* const LOADING_BITFILE_MSG = "\nLoading bitfile...\n" |
Definition at line 27 of file bitcorrelateMsgs.cpp.
| const char* const DECODING_BITSTREAM_MSG = "Decoding bitstream...\n" |
Definition at line 30 of file bitcorrelateMsgs.cpp.
| const char* const LOADING_DEVICELIST_MSG = "Loading device list...\n" |
Definition at line 33 of file bitcorrelateMsgs.cpp.
| const char* const LOADING_ADDRESSLAYOUT1_MSG = "Loading address layout for " |
Definition at line 36 of file bitcorrelateMsgs.cpp.
| const char* const LOADING_ADDRESSLAYOUT2_MSG = "...\n" |
Definition at line 39 of file bitcorrelateMsgs.cpp.
| const char* const EXECUTING_BITSTREAM_MSG = "Executing bitstream...\n" |
Definition at line 42 of file bitcorrelateMsgs.cpp.
| const char* const DOING_CORRELATION_MSG = "\nDoing correlation...\n" |
Definition at line 45 of file bitcorrelateMsgs.cpp.
| const char* const WRITING_DATABASE_MSG = "\nWriting database...\n" |
Definition at line 48 of file bitcorrelateMsgs.cpp.
| const char* const WRITING_STATS_MSG = "Writing statistics...\n" |
Definition at line 51 of file bitcorrelateMsgs.cpp.
| const char* const FINISHED_MSG = "\nFinished.\n" |
Definition at line 54 of file bitcorrelateMsgs.cpp.
| const char* const INFO_MSG = " of the PIPs and configuration options.\n\n" |
Definition at line 57 of file bitcorrelateMsgs.cpp.
| const char* const ERROR_MSG = "Error: " |
Definition at line 71 of file bitcorrelateMsgs.cpp.
| const char* const ERROR_UNKNOWN_MSG = "Unknown error occurred.\n" |
Definition at line 74 of file bitcorrelateMsgs.cpp.
| const char* const ERROR_TOO_MANY_PARAMETERS_MSG = "Too many parameters!" |
Definition at line 78 of file bitcorrelateMsgs.cpp.
| const char* const ERROR_UNKNOWN_OPTION_1_MSG = "Unknown option \"" |
Definition at line 81 of file bitcorrelateMsgs.cpp.
| const char* const ERROR_UNKNOWN_OPTION_2_MSG = "\"!" |
Definition at line 84 of file bitcorrelateMsgs.cpp.
| const char* const ERROR_NO_BIT_FILE_MSG = "No bitfile specified!" |
Definition at line 87 of file bitcorrelateMsgs.cpp.
| const char* const ERROR_NO_XDL_FILE_MSG = "No XDL file specified!" |
Definition at line 90 of file bitcorrelateMsgs.cpp.
| const char* const ERROR_NO_DB_FILE_MSG = "No data base file specified!" |
Definition at line 93 of file bitcorrelateMsgs.cpp.
| const char* const ERROR_NO_STATSFILE_MSG = "No statistics file specified!" |
Definition at line 96 of file bitcorrelateMsgs.cpp.
| const char* const ERROR_NO_DATAPATH_MSG = "No data path specified!" |
Definition at line 99 of file bitcorrelateMsgs.cpp.
| const char* const DEVICE_FILE_EXT = ".dev" |
Definition at line 103 of file bitcorrelateMsgs.cpp.
| const char* const MAP_FILE_EXT = ".map" |
Definition at line 105 of file bitcorrelateMsgs.cpp.
| const char* const V5DEVICES_FILENAME = "\\v5devices.lst" |
Definition at line 107 of file bitcorrelateMsgs.cpp.
| const char* const CAL_FILE_EXT = ".cal" |
Definition at line 109 of file bitcorrelateMsgs.cpp.


- Hi! My name is Esraa Ananazeh. I’m 22 and I live in Amman
- which is the capital of jordan. I have three brothers and two sister
- I’m interested in computer science, music, sport and cooking.
- Computers first appered in my life when I was seven.. At first
- I was just playing computer games, but some time later, I noticed that
- I could do a lot more things with the computer,
- so i decide to Entering the university with computer engineering field
- and after graduated from my university since
- two week ago i decided to join with 6-month khedmat watan
- Training course in Luminus Technical University College.
- I wish to complete all the courses and pass all the exam to become a good software developer
- so ennjoy visit my website..have a nice day ^^
my top ten favorit places
- Amman
- ajloun
- alsalt
- aqaba
- irbid
- alkarak
- palstain
- almafrq
- iraq
- syria