The simulation widget that takes information from the Cloth and draws it to the screen, as well as executing the result of any user input. More...
#include <GLWindow.h>
Public Slots | |
| void | toggleWireframe (bool _mode) |
| a slot to toggle wireframe mode | |
| void | setXRotation (double _x) |
| set the X rotation value | |
| void | setYRotation (double _y) |
| set the Y rotation value | |
| void | setZRotation (double _z) |
| set the Z rotation value | |
| void | setXScale (double _x) |
| set the X scale value | |
| void | setYScale (double _y) |
| set the Y scale value | |
| void | setZScale (double _z) |
| set the Z scale value | |
| void | setXPosition (double _x) |
| set the X position value | |
| void | setYPosition (double _y) |
| set the Y position value | |
| void | setZPosition (double _z) |
| set the Z position value | |
| void | setDrawType (int _i) |
| Set the method of drawing the object. | |
| void | togglePaused () |
| Pause the cloth simulation. | |
| void | toggleWind () |
| Apply wind to the cloth. | |
| void | setSelfCollisions (bool _shouldUse) |
| Set whether collisions between cloth particles should be used. | |
| void | setSphereCollisions (bool _shouldUse) |
| Set whether collisions between cloth particles and the sphere should be used. | |
| void | setClothHeight (double _height) |
| Set the height of the cloth geometry. | |
| void | setClothWidth (double _width) |
| Set the width of the cloth geomety. | |
| void | setClothWidthRes (int _num) |
| Set how many particles the cloth has in the X direction. | |
| void | setClothHeightRes (int _num) |
| Set how many particles the cloth has in the Y direction. | |
| void | setSpringConstant (double _constant) |
| Set the spring constant for all the springs. | |
| void | setDampingConstant (double _constant) |
| Set the damping constant for all the springs. | |
| void | setSphereX (double _x) |
| Set the X position of the collision sphere. | |
| void | setSphereY (double _y) |
| Set the Y position of the collision sphere. | |
| void | setSphereZ (double _z) |
| Set the Z position of the collision sphere. | |
| void | setSphereRadius (double _radius) |
| Set the radius of the collision sphere. | |
| void | setGravity (double _gravity) |
| Set the gravity force on the particles. | |
| void | setSimSpeed (double _speed) |
| Set the speed of the cloth simulation. | |
| void | reset () |
| Call reset() on the cloth. | |
| void | setAnchoredBottomLeft (bool _anchor) |
| Set whether the particle in the bottom left corner is anchored. | |
| void | setAnchoredBottomRight (bool _anchor) |
| Set whether the particle in the bottom right corner is anchored. | |
| void | setAnchoredTopLeft (bool _anchor) |
| Set whether the particle in the top left corner is anchored. | |
| void | setAnchoredTopRight (bool _anchor) |
| Set whether the particle in the top right corner is anchored. | |
Public Member Functions | |
| GLWindow (const QGLFormat _format, QWidget *_parent) | |
| Constructor for GLWindow. | |
| ~GLWindow () | |
| dtor | |
Protected Member Functions | |
| void | initializeGL () |
| The following methods must be implimented in the sub class this is called when the window is created. | |
| void | resizeGL (const int _w, const int _h) |
| this is called whenever the window is re-sized | |
| void | paintGL () |
| this is the main gl drawing routine which is called whenever the window needs to be re-drawn | |
| void | createTextures () |
| Loads the cloth texture from the file and creates the OpenGL texture buffers for the position and normal textures. | |
| void | updatePositionTexture () |
| Update the position texture with the new values loaded from the Cloth object. | |
| void | renderNormals () |
| Render the vertex normals to the framebuffer (broken as of the writing of this brief). | |
| void | createVAO () |
| create our mesh | |
| void | updateVAO () |
| Update the mesh with the new vertex positions. | |
| void | timerEvent (QTimerEvent *e) |
| Overloaded function to handle keyboard input. | |
Protected Attributes | |
| ngl::Camera * | m_camera |
| our camera | |
| ngl::Transformation | m_transform |
| our transform for objects | |
| ngl::Transformation | m_sphereTransform |
| The separate transform just for the sphere; this is relative to the main transform. | |
| Cloth | m_cloth |
| Our cloth object. | |
| double | m_time |
| The time since the simulation began; pretty much just used for the cloth's wind function. | |
| ngl::VertexArrayObject * | m_vao |
| mesh data | |
| GLuint | m_clothTexture |
| texture name | |
| GLuint | m_posBuffer |
| Handle of the OpenGL buffer storing the particle positions. | |
| GLuint | m_posBufferTexture |
| Handle of the OpenGL texture that stores the data from the position buffer. | |
| GLuint | m_normalsFramebuffer |
| Handle of the OpenGL framebuffer we (should) write the normals to. | |
| GLuint | m_normalsFramebufferTexture |
| Handle of the OpenGL texture storing the vertex normals. | |
| ngl::VertexArrayObject * | m_viewportVAO |
| A very simple VAO that fills the canonical view volume; used for rendering to the framebuffer. |
The simulation widget that takes information from the Cloth and draws it to the screen, as well as executing the result of any user input.
| GLWindow::GLWindow | ( | const QGLFormat | _format, | |
| QWidget * | _parent | |||
| ) |
| void GLWindow::initializeGL | ( | ) | [protected] |
The following methods must be implimented in the sub class this is called when the window is created.
create our camera
| void GLWindow::resizeGL | ( | const int | _w, | |
| const int | _h | |||
| ) | [protected] |
this is called whenever the window is re-sized
| [in] | _w | the width of the resized window |
| [in] | _h | the height of the resized window |
| void GLWindow::setAnchoredBottomLeft | ( | bool | _anchor | ) | [slot] |
Set whether the particle in the bottom left corner is anchored.
| [in] | _anchor | The value to set. |
| void GLWindow::setAnchoredBottomRight | ( | bool | _anchor | ) | [slot] |
Set whether the particle in the bottom right corner is anchored.
| [in] | _anchor | The value to set. |
| void GLWindow::setAnchoredTopLeft | ( | bool | _anchor | ) | [slot] |
Set whether the particle in the top left corner is anchored.
| [in] | _anchor | The value to set. |
| void GLWindow::setAnchoredTopRight | ( | bool | _anchor | ) | [slot] |
Set whether the particle in the top right corner is anchored.
| [in] | _anchor | The value to set. |
| void GLWindow::setClothHeight | ( | double | _height | ) | [slot] |
Set the height of the cloth geometry.
| [in] | _height | The value to set. |
| void GLWindow::setClothHeightRes | ( | int | _num | ) | [slot] |
Set how many particles the cloth has in the Y direction.
| [in] | _num | The value to set. |
| void GLWindow::setClothWidth | ( | double | _width | ) | [slot] |
Set the width of the cloth geomety.
| [in] | _width | The value to set. |
| void GLWindow::setClothWidthRes | ( | int | _num | ) | [slot] |
Set how many particles the cloth has in the X direction.
| [in] | _num | The value to set. |
| void GLWindow::setDampingConstant | ( | double | _constant | ) | [slot] |
Set the damping constant for all the springs.
| [in] | _constant | The value to set. |
| void GLWindow::setDrawType | ( | int | _i | ) | [slot] |
Set the method of drawing the object.
| [in] | _i | the index of the draw method. |
| void GLWindow::setGravity | ( | double | _gravity | ) | [slot] |
Set the gravity force on the particles.
| [in] | _gravity | The value to set. |
| void GLWindow::setSelfCollisions | ( | bool | _shouldUse | ) | [slot] |
Set whether collisions between cloth particles should be used.
| [in] | _shouldUse | The value to set. |
| void GLWindow::setSimSpeed | ( | double | _speed | ) | [slot] |
Set the speed of the cloth simulation.
| [in] | _speed | The value to set. |
| void GLWindow::setSphereCollisions | ( | bool | _shouldUse | ) | [slot] |
Set whether collisions between cloth particles and the sphere should be used.
| [in] | _shouldUse | The value to set. |
| void GLWindow::setSphereRadius | ( | double | _radius | ) | [slot] |
Set the radius of the collision sphere.
| [in] | _radius | The value to set. |
| void GLWindow::setSphereX | ( | double | _x | ) | [slot] |
Set the X position of the collision sphere.
| [in] | _x | The value to set. |
| void GLWindow::setSphereY | ( | double | _y | ) | [slot] |
Set the Y position of the collision sphere.
| [in] | _y | The value to set. |
| void GLWindow::setSphereZ | ( | double | _z | ) | [slot] |
Set the Z position of the collision sphere.
| [in] | _z | The value to set. |
| void GLWindow::setSpringConstant | ( | double | _constant | ) | [slot] |
Set the spring constant for all the springs.
| [in] | _constant | The value to set. |
| void GLWindow::setXPosition | ( | double | _x | ) | [slot] |
set the X position value
| [in] | _x | the value to set |
| void GLWindow::setXRotation | ( | double | _x | ) | [slot] |
set the X rotation value
| [in] | _x | the value to set |
| void GLWindow::setXScale | ( | double | _x | ) | [slot] |
set the X scale value
| [in] | _x | the value to set |
| void GLWindow::setYPosition | ( | double | _y | ) | [slot] |
set the Y position value
| [in] | _y | the value to set |
| void GLWindow::setYRotation | ( | double | _y | ) | [slot] |
set the Y rotation value
| [in] | _y | the value to set |
| void GLWindow::setYScale | ( | double | _y | ) | [slot] |
set the Y scale value
| [in] | _y | the value to set |
| void GLWindow::setZPosition | ( | double | _z | ) | [slot] |
set the Z position value
| [in] | _z | the value to set |
| void GLWindow::setZRotation | ( | double | _z | ) | [slot] |
set the Z rotation value
| [in] | _z | the value to set |
| void GLWindow::setZScale | ( | double | _z | ) | [slot] |
set the Z scale value
| [in] | _z | the value to set |
| void GLWindow::toggleWireframe | ( | bool | _mode | ) | [slot] |
a slot to toggle wireframe mode
| [in] | _mode | the mode passed from the toggle button |


Get a print-out of each push made to a repository.
Subscribe in BERGCloud Remote.
If you want, you can check out the source code on GitHub.


{% extends "base.html" %} {% block page_title %}DAF - Home{% endblock %} {% block content %}
Created {{ article.created }} by {{ article.author }}


Lennie James: Generations of lives at risk if care charities are not funded
Actor Lennie James has said that generations of young lives are at risk of being lost if the UK’s care charities are not properly funded.
The Walking Dead star, 54, who is Barnardo’s ambassador for children in and leaving care, said those in charge of the system were showing “less and less commitment”.
James, who spent eight years in care following the death of his mother when he was 10, added that charities such as Barnardo’s had become “the experts” to fill this void.
He told the PA news agency: “If charities like Barnardo’s didn’t exist then a lot of lives would have been lost. A lot of lives would have been ruined.
 But it would be generational. It would go on and on.
“One of the basic things that Barnardo’s provides is a safety net.
“And they are providing a safety net at a time when arguably the people who are providing it are showing less and less commitment.
“Thank God Barnardo’s and other charities like them are not going that way and are actually trying to step up and do more.
“It’s partly because they have to, but it’s also because they have become the experts now.”
James was born in Nottingham and raised in Streatham, London, following the death of his mother, later training at the Guildhall School of Music and Drama.
He has starred in a number of Hollywood blockbusters including Guy Ritchie’s Snatch and Blade Runner 2049, and appeared as DCI Tony Gates in Line Of Duty.
Although James said he had a “broadly good experience of council care”, he said he wanted to remove the “stigma” surrounding the label.
James said: “A terrible thing happened in the sense that me and my brother lost our mum and we ended up in a children’s home.
“It so happened that if something like that happens, you would hope to end up in a good children’s home.
“I think people are much more used to hearing bad stories about children’s homes than good ones.”
On Tuesday, he also launched the multimillion-pound Positive Futures appeal with Barnardo’s, pledging to fund-raise the first £50,000 with his wife Giselle.
He has named his year-long campaign after his birth and foster mother, Phyllis and Pam.
Barnardo’s is also aiming to build 50 gap homes around the country, where young people leaving care are taught life skills which will help them become independent.
James added: “I think it is vital. I think it is really important. I think that if we are not looking after the kids in care, then I don’t know why we are calling it care. It’s just lip service.
“They deserve more. It’s through no fault of their own but sometimes you feel like it is, when you are in that situation. You feel like it is your fault that this is happening to you.
“The situation that some of those kids are in, and the things they have experienced, and the lives they are living, the very least we can do is help them enter the world in the best way possible to live successful lives.
“I don’t think that is too much to ask.”
Earlier in the day, James visited Barnardo’s YouthBuild service at a centre in Lewisham, south London, where he took part in sessions aiming to teach young people construction skills.
After the sessions, James posed for selfies and spoke with a number of those enrolled in the programme, some half of whom had been in care, the charity said.


Waiting...
Waiting for remote device to connect with code “
{{ pairCode }}
”.
Connected.
Connect
Additional Controls:
App Button: Tap / Hold 2 fingers Home Button: Tap / Hold 3 fingers


Location {{vm.location.locationName}}
- Client Name
-
{{vm.location.clientName}}
- Location Name
-
{{vm.location.locationName}}
- Country
-
{{vm.location.country}}
- State
-
{{vm.location.state}}
- District
-
{{vm.location.district}}
- Locality
-
{{vm.location.locality}}
- Client
-
{{vm.location.clientName}}


This is a demo webapp showing off basic usage of the abstract-state-router library using a few different templating libraries.


Analyzing App Usage
This guide shows how to use app metrics to provide rich visualizations regarding app usage that can then drive development planning, for example, when should support for version x.y of app end?'
Viewing Dashboards
There are many visualisations available in the default dashboards in Grafana. There are 2 dashboards where App Metrics data is shown:
-
Mobile Service Dashboard (Summary data in the 'Mobile App Metrics' section)
-
Mobile App Metrics Dashboard
In general, the summary data that is visible on the 'Mobile Services' Dashboard is also available on the 'Mobile App Metrics' dashboard, but in more detail.
Analyzing App launches
An App launch is a metric event that occurs when an App is launched on a device. The total number of App launches for a given time shows how many times an App was launched in that time, regardless of if it was the same device or different devices. It can be useful as a gauge on how much activity the App has. However, as it doesn’t take into account multiple launches from the same device, it isn’t useful as a gauge for 'stickiness' of the App.
Analyzing unique clients
Every metric event has a unique client identifier associated with it. This unique client identifier is generated the first time an App is started. It is worth noting this identifier will be regenerated if a user re-installs an App. The total number of unique clients for a given time shows how many users launched an App at least once. This can be useful as a gauge on how many active App users there currently are. The time range is an important factor when viewing the number of unique clients. Viewing unique clients for the last year gives a very different insight than for the last week. In Grafana, the time range can be changed in the top right of the Dashboard view.
Analyzing unique clients per App
Every metric event has an App identifier associated with it. An App identifier uniquely identifies an App. It is bundled with the App binary. There can be more than 1 App (each with a different App identifier) sending metrics events to the same Metrics Service. For example, there might be an Admin Portal App and a Field Worker App both using the same back-end services and same Mobile Metrics Service. The number of unique clients per App gives a breakdown of all users by the App they are using. However, if you only have 1 App there is no difference between the number of unique clients and the number of unique clients per App.
Analyzing unique clients per platform
Every metric event has the platform associated with it. An example of a platform is Android or iOS. This can be useful for making decisions about which platform to put effort into. However, if all your Apps are on a single platform, there is no difference between the number of unique clients and the number of unique clients per platform.
Analyzing unique clients per sdk version
Every metric event has the AeroGear sdk version associated with it. This can be useful for making decisions about what features to deprecate or drop support for, or applying backwards incompatible server changes/updates. This metric will be more valuable as more versions of an App (with different sdk versions) are published.
Analyzing unique clients per app version
Every metric event has the App version associated with it. The App version is set by the developer. Like the sdk version, this can be useful for making decisions about what features to deprecate or drop support for, or applying backwards incompatible server changes/updates. It can also be useful to see the uptake rate of newly published versions of an App.
Related Information
See Grafana documentation for more information on the following topics:


Inspire future scientists
Education and Outreach
Science educators are needed to break down complicated scientific concepts into simple ideas for the broader community. Work as a K-12 teacher to inspire future scientists, or take the nontraditional route by working for a museum, camp or enrichment program. Other organizations and nonprofits need outreach coordinators and event planners to raise awareness and make science relevant to the public.
Sample Job Titles
Relevant Skills


CryptoTrust
Apps
Documentation
Home
OnlyKey Web Access Apps
OnlyKey Encryption Tool
Encrypt messages in your browser using
kbpgp.js
Encrypt
Thanks to
pgp2go
OnlyKey Console Messages Appear Below


I think it is a great approach where the focus is not solely on coding but also on developing and encouraging positive soft skills such as empathy, kindness, mindfulness, etc.
My impressions are, overall, positive. This will take a great deal of time and effort and good preparation is key!
I see myself fitting in quite well in this type of culture. Individually we will all bring different experiences and qualities and going forward we help each other where we can.
No. I still expect to put in a lot of effort and work as a team!
I'm very excited and slightly nervous beacuse there is still some fear that I won't be prepared enough by the time bootcamp starts!


{% load static %}
CoffeeClique
Users in Cafe: {{ num_users }}
Logout
Report
You can use this form to report inappropriate behaviour to the admin team if you need to.
{% csrf_token %} {% for field in form %}
{{field.label_tag}}
{{field}}
{% endfor %}
Report
Dashboard


Hind Al-Charabi was found lying ‘naked and broken on the cold tiled floor’ at home in Ealing, west London, on November 17 last year.
Her carer Sibusisiwe Msipha, 38, told police the pensioner fell out of bed and she had been unable to lift her back up, but failed to call for help.
During the subsequent investigation it emerged Msipha had fake identity documents and no right to be in the country, which may have been the reason for her reluctance to raise the alarm.
Msipha was arrested walking away from the address with a suitcase and taken to a North London police station.
She eventually pleaded guilty to wilful neglect causing death as well as fraud and was jailed for a total of 33 months.
Mrs Al-Charabi’s son, Khaldoun Zeitouni, said his mother was a ‘gentle and kind lady’ who had always been ‘chatty, caring and very loving’ towards the entire family.
Advertisement Advertisement
He added: ‘She was so generous with her time and emotional support. She was everything to me: my best friend, the person I would go to, often my companion, and my mum.
‘What makes it even worse is the thought of how she died. I have so many unanswered questions as to what happened, the extent of her injuries, whether she was in any pain, how long it had taken for her to pass away and was she calling out for me or for help?’
Detective inspector James Howarth, said: ‘Sibusisiwe Msipha should have had the care of a vulnerable 89-year-old lady as her top priority. She failed in that duty.
‘Msipha inexcusably abandoned Mrs Hind Al-Charabi to pass away on her own and showed a total disregard for the safety and security of a fellow human being.
‘Mrs Al-Charabi’s family have suffered intolerably and whilst no sentence can ever make up for the loss of a loved one, we are pleased that justice has been served today.’
Got a story for Metro.co.uk?
Get in touch with our news team by emailing us at<EMAIL_ADDRESS>For more stories like this, check our news page.


public class Random extends Object implements Serializable
If two instances of Random
are created with the same
seed, and the same sequence of method calls is made for each, they
will generate and return identical sequences of numbers. In order to
guarantee this property, particular algorithms are specified for the
class Random
. Java implementations must use all the algorithms
shown here for the class Random
, for the sake of absolute
portability of Java code. However, subclasses of class Random
are permitted to use other algorithms, so long as they adhere to the
general contracts for all the methods.
The algorithms implemented by class Random
use a
protected
utility method that on each invocation can supply
up to 32 pseudorandomly generated bits.
Many applications will find the method Math.random()
simpler to use.
Instances of java.util.Random
are threadsafe.
However, the concurrent use of the same java.util.Random
instance across threads may encounter contention and consequent
poor performance. Consider instead using
ThreadLocalRandom
in multithreaded
designs.
Instances of java.util.Random
are not cryptographically
secure. Consider instead using SecureRandom
to
get a cryptographically secure pseudo-random number generator for use
by security-sensitive applications.
| Constructor and Description |
|---|
Random()
Creates a new random number generator.
|
Random(long seed)
Creates a new random number generator using a single
long seed. |
| Modifier and Type | Method and Description |
|---|---|
DoubleStream |
doubles()
Returns an effectively unlimited stream of pseudorandom
double values, each between zero (inclusive) and one
(exclusive). |
DoubleStream |
doubles(double randomNumberOrigin,
double randomNumberBound)
Returns an effectively unlimited stream of pseudorandom
double values, each conforming to the given origin (inclusive) and bound
(exclusive). |
DoubleStream |
doubles(long streamSize)
Returns a stream producing the given
streamSize number of
pseudorandom double values, each between zero
(inclusive) and one (exclusive). |
DoubleStream |
doubles(long streamSize,
double randomNumberOrigin,
double randomNumberBound)
Returns a stream producing the given
streamSize number of
pseudorandom double values, each conforming to the given origin
(inclusive) and bound (exclusive). |
IntStream |
ints()
Returns an effectively unlimited stream of pseudorandom
int
values. |
IntStream |
ints(int randomNumberOrigin,
int randomNumberBound)
Returns an effectively unlimited stream of pseudorandom
int values, each conforming to the given origin (inclusive) and bound
(exclusive). |
IntStream |
ints(long streamSize)
Returns a stream producing the given
streamSize number of
pseudorandom int values. |
IntStream |
ints(long streamSize,
int randomNumberOrigin,
int randomNumberBound)
Returns a stream producing the given
streamSize number
of pseudorandom int values, each conforming to the given
origin (inclusive) and bound (exclusive). |
LongStream |
longs()
Returns an effectively unlimited stream of pseudorandom
long
values. |
LongStream |
longs(long streamSize)
Returns a stream producing the given
streamSize number of
pseudorandom long values. |
LongStream |
longs(long randomNumberOrigin,
long randomNumberBound)
Returns an effectively unlimited stream of pseudorandom
long values, each conforming to the given origin (inclusive) and bound
(exclusive). |
LongStream |
longs(long streamSize,
long randomNumberOrigin,
long randomNumberBound)
Returns a stream producing the given
streamSize number of
pseudorandom long , each conforming to the given origin
(inclusive) and bound (exclusive). |
protected int |
next(int bits)
Generates the next pseudorandom number.
|
boolean |
nextBoolean()
Returns the next pseudorandom, uniformly distributed
boolean value from this random number generator's
sequence. |
void |
nextBytes(byte[] bytes)
Generates random bytes and places them into a user-supplied
byte array.
|
double |
nextDouble()
Returns the next pseudorandom, uniformly distributed
double value between 0.0 and
1.0 from this random number generator's sequence. |
float |
nextFloat()
Returns the next pseudorandom, uniformly distributed
float
value between 0.0 and 1.0 from this random
number generator's sequence. |
double |
nextGaussian()
Returns the next pseudorandom, Gaussian ("normally") distributed
double value with mean 0.0 and standard
deviation 1.0 from this random number generator's sequence. |
int |
nextInt()
Returns the next pseudorandom, uniformly distributed
int
value from this random number generator's sequence. |
int |
nextInt(int bound)
Returns a pseudorandom, uniformly distributed
int value
between 0 (inclusive) and the specified value (exclusive), drawn from
this random number generator's sequence. |
long |
nextLong()
Returns the next pseudorandom, uniformly distributed
long
value from this random number generator's sequence. |
void |
setSeed(long seed)
Sets the seed of this random number generator using a single
long seed. |
public Random()
public Random(long seed)
long
seed.
The seed is the initial value of the internal state of the pseudorandom
number generator which is maintained by method next(int)
.
The invocation new Random(seed)
is equivalent to:
Random rnd = new Random();
rnd.setSeed(seed);
seed
- the initial seedsetSeed(long)
public void setSeed(long seed)
long
seed. The general contract of setSeed
is
that it alters the state of this random number generator object
so as to be in exactly the same state as if it had just been
created with the argument seed
as a seed. The method
setSeed
is implemented by class Random
by
atomically updating the seed to
(seed ^ 0x5DEECE66DL) & ((1L << 48) - 1)
and clearing the haveNextNextGaussian
flag used by nextGaussian()
.
The implementation of setSeed
by class Random
happens to use only 48 bits of the given seed. In general, however,
an overriding method may use all 64 bits of the long
argument as a seed value.
seed
- the initial seedprotected int next(int bits)
The general contract of next
is that it returns an
int
value and if the argument bits
is between
1
and 32
(inclusive), then that many low-order
bits of the returned value will be (approximately) independently
chosen bit values, each of which is (approximately) equally
likely to be 0
or 1
. The method next
is
implemented by class Random
by atomically updating the seed to
(seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1)
and returning
(int)(seed >>> (48 - bits))
.
This is a linear congruential pseudorandom number generator, as
defined by D. H. Lehmer and described by Donald E. Knuth in
The Art of Computer Programming, Volume 3:
Seminumerical Algorithms, section 3.2.1.bits
- random bitspublic void nextBytes(byte[] bytes)
The method nextBytes
is implemented by class Random
as if by:
public void nextBytes(byte[] bytes) {
for (int i = 0; i < bytes.length; )
for (int rnd = nextInt(), n = Math.min(bytes.length - i, 4);
n-- > 0; rnd >>= 8)
bytes[i++] = (byte)rnd;
}
bytes
- the byte array to fill with random bytesNullPointerException
- if the byte array is nullpublic int nextInt()
int
value from this random number generator's sequence. The general
contract of nextInt
is that one int
value is
pseudorandomly generated and returned. All 232 possible
int
values are produced with (approximately) equal probability.
The method nextInt
is implemented by class Random
as if by:
public int nextInt() {
return next(32);
}
int
value from this random number generator's sequencepublic int nextInt(int bound)
int
value
between 0 (inclusive) and the specified value (exclusive), drawn from
this random number generator's sequence. The general contract of
nextInt
is that one int
value in the specified range
is pseudorandomly generated and returned. All bound
possible
int
values are produced with (approximately) equal
probability. The method nextInt(int bound)
is implemented by
class Random
as if by:
public int nextInt(int bound) {
if (bound <= 0)
throw new IllegalArgumentException("bound must be positive");
if ((bound & -bound) == bound) // i.e., bound is a power of 2
return (int)((bound * (long)next(31)) >> 31);
int bits, val;
do {
bits = next(31);
val = bits % bound;
} while (bits - val + (bound-1) < 0);
return val;
}
The hedge "approximately" is used in the foregoing description only
because the next method is only approximately an unbiased source of
independently chosen bits. If it were a perfect source of randomly
chosen bits, then the algorithm shown would choose int
values from the stated range with perfect uniformity.
The algorithm is slightly tricky. It rejects values that would result in an uneven distribution (due to the fact that 2^31 is not divisible by n). The probability of a value being rejected depends on n. The worst case is n=2^30+1, for which the probability of a reject is 1/2, and the expected number of iterations before the loop terminates is 2.
The algorithm treats the case where n is a power of two specially: it returns the correct number of high-order bits from the underlying pseudo-random number generator. In the absence of special treatment, the correct number of low-order bits would be returned. Linear congruential pseudo-random number generators such as the one implemented by this class are known to have short periods in the sequence of values of their low-order bits. Thus, this special case greatly increases the length of the sequence of values returned by successive calls to this method if n is a small power of two.
bound
- the upper bound (exclusive). Must be positive.int
value between zero (inclusive) and bound
(exclusive)
from this random number generator's sequenceIllegalArgumentException
- if bound is not positivepublic long nextLong()
long
value from this random number generator's sequence. The general
contract of nextLong
is that one long
value is
pseudorandomly generated and returned.
The method nextLong
is implemented by class Random
as if by:
public long nextLong() {
return ((long)next(32) << 32) + next(32);
}
Because class Random
uses a seed with only 48 bits,
this algorithm will not return all possible long
values.long
value from this random number generator's sequencepublic boolean nextBoolean()
boolean
value from this random number generator's
sequence. The general contract of nextBoolean
is that one
boolean
value is pseudorandomly generated and returned. The
values true
and false
are produced with
(approximately) equal probability.
The method nextBoolean
is implemented by class Random
as if by:
public boolean nextBoolean() {
return next(1) != 0;
}
boolean
value from this random number generator's
sequencepublic float nextFloat()
float
value between 0.0
and 1.0
from this random
number generator's sequence.
The general contract of nextFloat
is that one
float
value, chosen (approximately) uniformly from the
range 0.0f
(inclusive) to 1.0f
(exclusive), is
pseudorandomly generated and returned. All 224 possible
float
values of the form m x 2-24,
where m is a positive integer less than 224, are
produced with (approximately) equal probability.
The method nextFloat
is implemented by class Random
as if by:
public float nextFloat() {
return next(24) / ((float)(1 << 24));
}
The hedge "approximately" is used in the foregoing description only
because the next method is only approximately an unbiased source of
independently chosen bits. If it were a perfect source of randomly
chosen bits, then the algorithm shown would choose float
values from the stated range with perfect uniformity.
[In early versions of Java, the result was incorrectly calculated as:
return next(30) / ((float)(1 << 30));
This might seem to be equivalent, if not better, but in fact it
introduced a slight nonuniformity because of the bias in the rounding
of floating-point numbers: it was slightly more likely that the
low-order bit of the significand would be 0 than that it would be 1.]float
value between 0.0
and 1.0
from this
random number generator's sequencepublic double nextDouble()
double
value between 0.0
and
1.0
from this random number generator's sequence.
The general contract of nextDouble
is that one
double
value, chosen (approximately) uniformly from the
range 0.0d
(inclusive) to 1.0d
(exclusive), is
pseudorandomly generated and returned.
The method nextDouble
is implemented by class Random
as if by:
public double nextDouble() {
return (((long)next(26) << 27) + next(27))
/ (double)(1L << 53);
}
The hedge "approximately" is used in the foregoing description only
because the next
method is only approximately an unbiased
source of independently chosen bits. If it were a perfect source of
randomly chosen bits, then the algorithm shown would choose
double
values from the stated range with perfect uniformity.
[In early versions of Java, the result was incorrectly calculated as:
return (((long)next(27) << 27) + next(27))
/ (double)(1L << 54);
This might seem to be equivalent, if not better, but in fact it
introduced a large nonuniformity because of the bias in the rounding
of floating-point numbers: it was three times as likely that the
low-order bit of the significand would be 0 than that it would be 1!
This nonuniformity probably doesn't matter much in practice, but we
strive for perfection.]double
value between 0.0
and 1.0
from this
random number generator's sequenceMath.random()
public double nextGaussian()
double
value with mean 0.0
and standard
deviation 1.0
from this random number generator's sequence.
The general contract of nextGaussian
is that one
double
value, chosen from (approximately) the usual
normal distribution with mean 0.0
and standard deviation
1.0
, is pseudorandomly generated and returned.
The method nextGaussian
is implemented by class
Random
as if by a threadsafe version of the following:
private double nextNextGaussian;
private boolean haveNextNextGaussian = false;
public double nextGaussian() {
if (haveNextNextGaussian) {
haveNextNextGaussian = false;
return nextNextGaussian;
} else {
double v1, v2, s;
do {
v1 = 2 * nextDouble() - 1; // between -1.0 and 1.0
v2 = 2 * nextDouble() - 1; // between -1.0 and 1.0
s = v1 * v1 + v2 * v2;
} while (s >= 1 || s == 0);
double multiplier = StrictMath.sqrt(-2 * StrictMath.log(s)/s);
nextNextGaussian = v2 * multiplier;
haveNextNextGaussian = true;
return v1 * multiplier;
}
}
This uses the polar method of G. E. P. Box, M. E. Muller, and
G. Marsaglia, as described by Donald E. Knuth in The Art of
Computer Programming, Volume 3: Seminumerical Algorithms,
section 3.4.1, subsection C, algorithm P. Note that it generates two
independent values at the cost of only one call to StrictMath.log
and one call to StrictMath.sqrt
.double
value with mean 0.0
and
standard deviation 1.0
from this random number
generator's sequencepublic IntStream ints(long streamSize)
streamSize
number of
pseudorandom int
values.
A pseudorandom int
value is generated as if it's the result of
calling the method nextInt()
.
streamSize
- the number of values to generateint
valuesIllegalArgumentException
- if streamSize
is
less than zeropublic IntStream ints()
int
values.
A pseudorandom int
value is generated as if it's the result of
calling the method nextInt()
.
int
valuespublic IntStream ints(long streamSize, int randomNumberOrigin, int randomNumberBound)
streamSize
number
of pseudorandom int
values, each conforming to the given
origin (inclusive) and bound (exclusive).
A pseudorandom int
value is generated as if it's the result of
calling the following method with the origin and bound:
int nextInt(int origin, int bound) {
int n = bound - origin;
if (n > 0) {
return nextInt(n) + origin;
}
else { // range not representable as int
int r;
do {
r = nextInt();
} while (r < origin || r >= bound);
return r;
}
}
streamSize
- the number of values to generaterandomNumberOrigin
- the origin (inclusive) of each random valuerandomNumberBound
- the bound (exclusive) of each random valueint
values,
each with the given origin (inclusive) and bound (exclusive)IllegalArgumentException
- if streamSize
is
less than zero, or randomNumberOrigin
is greater than or equal to randomNumberBound
public IntStream ints(int randomNumberOrigin, int randomNumberBound)
int
values, each conforming to the given origin (inclusive) and bound
(exclusive).
A pseudorandom int
value is generated as if it's the result of
calling the following method with the origin and bound:
int nextInt(int origin, int bound) {
int n = bound - origin;
if (n > 0) {
return nextInt(n) + origin;
}
else { // range not representable as int
int r;
do {
r = nextInt();
} while (r < origin || r >= bound);
return r;
}
}
randomNumberOrigin
- the origin (inclusive) of each random valuerandomNumberBound
- the bound (exclusive) of each random valueint
values,
each with the given origin (inclusive) and bound (exclusive)IllegalArgumentException
- if randomNumberOrigin
is greater than or equal to randomNumberBound
public LongStream longs(long streamSize)
streamSize
number of
pseudorandom long
values.
A pseudorandom long
value is generated as if it's the result
of calling the method nextLong()
.
streamSize
- the number of values to generatelong
valuesIllegalArgumentException
- if streamSize
is
less than zeropublic LongStream longs()
long
values.
A pseudorandom long
value is generated as if it's the result
of calling the method nextLong()
.
long
valuespublic LongStream longs(long streamSize, long randomNumberOrigin, long randomNumberBound)
streamSize
number of
pseudorandom long
, each conforming to the given origin
(inclusive) and bound (exclusive).
A pseudorandom long
value is generated as if it's the result
of calling the following method with the origin and bound:
long nextLong(long origin, long bound) {
long r = nextLong();
long n = bound - origin, m = n - 1;
if ((n & m) == 0L) // power of two
r = (r & m) + origin;
else if (n > 0L) { // reject over-represented candidates
for (long u = r >>> 1; // ensure nonnegative
u + m - (r = u % n) < 0L; // rejection check
u = nextLong() >>> 1) // retry
;
r += origin;
}
else { // range not representable as long
while (r < origin || r >= bound)
r = nextLong();
}
return r;
}
streamSize
- the number of values to generaterandomNumberOrigin
- the origin (inclusive) of each random valuerandomNumberBound
- the bound (exclusive) of each random valuelong
values,
each with the given origin (inclusive) and bound (exclusive)IllegalArgumentException
- if streamSize
is
less than zero, or randomNumberOrigin
is greater than or equal to randomNumberBound
public LongStream longs(long randomNumberOrigin, long randomNumberBound)
long
values, each conforming to the given origin (inclusive) and bound
(exclusive).
A pseudorandom long
value is generated as if it's the result
of calling the following method with the origin and bound:
long nextLong(long origin, long bound) {
long r = nextLong();
long n = bound - origin, m = n - 1;
if ((n & m) == 0L) // power of two
r = (r & m) + origin;
else if (n > 0L) { // reject over-represented candidates
for (long u = r >>> 1; // ensure nonnegative
u + m - (r = u % n) < 0L; // rejection check
u = nextLong() >>> 1) // retry
;
r += origin;
}
else { // range not representable as long
while (r < origin || r >= bound)
r = nextLong();
}
return r;
}
randomNumberOrigin
- the origin (inclusive) of each random valuerandomNumberBound
- the bound (exclusive) of each random valuelong
values,
each with the given origin (inclusive) and bound (exclusive)IllegalArgumentException
- if randomNumberOrigin
is greater than or equal to randomNumberBound
public DoubleStream doubles(long streamSize)
streamSize
number of
pseudorandom double
values, each between zero
(inclusive) and one (exclusive).
A pseudorandom double
value is generated as if it's the result
of calling the method nextDouble()
.
streamSize
- the number of values to generatedouble
valuesIllegalArgumentException
- if streamSize
is
less than zeropublic DoubleStream doubles()
double
values, each between zero (inclusive) and one
(exclusive).
A pseudorandom double
value is generated as if it's the result
of calling the method nextDouble()
.
double
valuespublic DoubleStream doubles(long streamSize, double randomNumberOrigin, double randomNumberBound)
streamSize
number of
pseudorandom double
values, each conforming to the given origin
(inclusive) and bound (exclusive).
A pseudorandom double
value is generated as if it's the result
of calling the following method with the origin and bound:
double nextDouble(double origin, double bound) {
double r = nextDouble();
r = r * (bound - origin) + origin;
if (r >= bound) // correct for rounding
r = Math.nextDown(bound);
return r;
}
streamSize
- the number of values to generaterandomNumberOrigin
- the origin (inclusive) of each random valuerandomNumberBound
- the bound (exclusive) of each random valuedouble
values,
each with the given origin (inclusive) and bound (exclusive)IllegalArgumentException
- if streamSize
is
less than zeroIllegalArgumentException
- if randomNumberOrigin
is greater than or equal to randomNumberBound
public DoubleStream doubles(double randomNumberOrigin, double randomNumberBound)
double
values, each conforming to the given origin (inclusive) and bound
(exclusive).
A pseudorandom double
value is generated as if it's the result
of calling the following method with the origin and bound:
double nextDouble(double origin, double bound) {
double r = nextDouble();
r = r * (bound - origin) + origin;
if (r >= bound) // correct for rounding
r = Math.nextDown(bound);
return r;
}
randomNumberOrigin
- the origin (inclusive) of each random valuerandomNumberBound
- the bound (exclusive) of each random valuedouble
values,
each with the given origin (inclusive) and bound (exclusive)IllegalArgumentException
- if randomNumberOrigin
is greater than or equal to randomNumberBound
Dracula Javadoc Sample, Made with Allan Im.


Try It Online
What is TIO?
TIO is a family of online interpreters for an evergrowing list of practical and recreational programming languages.
To use TIO, simply click the arrow below, pick a programming language, and start typing. Once you click the run button, your code is sent to a TIO arena, executed in a sandboxed environment, and the results are sent back to your browser. You can share your code by generating a client-side permalink that encodes code and input directly in the URL.
Why TIO?
- TIO hosts practical and recreational programming languages, for a total of languages.
- TIO listens: languages and features are added by request all the time. If you have a request or want to report a bug, use any of the contact options listed below.
- The TIO web app is free of charge, ad-free, and doesn't use tracking cookies or third-party analytic scripts.
- The software that powers TIO is open source (MIT) and can be found on github.com/TryItOnline.
- TIO works great on mobile devices.
Contact
If you want to share your opinion, request a feature, report a bug, or ask a question, please visit gitter.im/tryitonline or send an email to<EMAIL_ADDRESS>In addition, Stack Exchange users with at least 20 reputation can chat on talk.tryitonline.net.
If you want to keep in touch and receive announcements and status updates, you can follow @Try_It_Online on Twitter.
Major Donors
Donations
The web server of Try It Online and the arenas (where user code is executed) are currently run on three separate servers. TIO is getting more and more traffic, so additional arenas will be required. Also, server-side permalinks will eventually require a separate storage. With your help, I hope to ensure a smooth operation of all TIO services.
Bitcoins can be donated to the address 1TryittLK3yAScCKavr5pg1eCZgpTdqYH. This is the preferred donation channel.
For other donation channels, please contact<EMAIL_ADDRESS>Referrals
TIO is powered by DigitalOcean. Their virtual private servers are affordable, fast, scalable, and (most importantly) professionally managed.
If you're looking for a VPS and decide to rent one from DigitalOcean, you can sign up by clicking the link above. You'll get $100 in DO credit for using my referral link and, as soon as you spend the minimum amount on their products, I'll get $25 credit myself to help cover my server costs.
Plain URL
HTML
Wiki markup
Markdown
Code Golf submission (Stack Exchange)
BBCode
To get started, select a language.


The Maven Indexer can be used by IDE plugins for local class searches. It does not affect Artifactory's built-in search and indexing behavior.


fun connect(): Boolean
Asynchronously connect to a server. Must be called on the main UI thread. Connection state change callbacks are guaranteed to be called on the main UI thread.
Return
True if connection was initiated, a callback will be invoked later to notify about connection status changes
False if connection was not initiated, no callbacks will be invoked


<script src="RGraph.common.core.js"></script> <script src="RGraph.hprogress.js"></script>Put this where you want the chart to show up:
<div style="margin-bottom: 20px"> <canvas id="cvs" width="600" height="100">[No canvas support]</canvas> </div>This is the code that generates the chart - it should be placed AFTER the canvas tag(s):


refresh length
remove demo
{{outer.count}}
add count
=> {{outer.count}}
outercount => {{outer.count}}
Not ok => {{outer.count}}


import functools import logging import os from typing import TYPE_CHECKING, Dict, List, Optional, Set, Tuple, cast from pip._vendor.packaging.utils import canonicalize_name from pip._vendor.packaging.version import parse as parse_version from pip._vendor.resolvelib import BaseReporter, ResolutionImpossible from pip._vendor.resolvelib import Resolver as RLResolver from pip._vendor.resolvelib.structs import DirectedGraph from pip._internal.cache import WheelCache from pip._internal.exceptions import InstallationError from pip._internal.index.package_finder import PackageFinder from pip._internal.operations.prepare import RequirementPreparer from pip._internal.req.req_install import ( InstallRequirement, check_invalid_constraint_type, ) from pip._internal.req.req_set import RequirementSet from pip._internal.resolution.base import BaseResolver, InstallRequirementProvider from pip._internal.resolution.resolvelib.provider import PipProvider from pip._internal.resolution.resolvelib.reporter import ( PipDebuggingReporter, PipReporter, ) from pip._internal.utils.deprecation import deprecated from pip._internal.utils.filetypes import is_archive_file from pip._internal.utils.misc import dist_is_editable from .base import Candidate, Constraint, Requirement from .factory import Factory if TYPE_CHECKING: from pip._vendor.resolvelib.resolvers import Result as RLResult Result = RLResult[Requirement, Candidate, str] logger = logging.getLogger(__name__) class Resolver(BaseResolver): _allowed_strategies = {"eager", "only-if-needed", "to-satisfy-only"} def __init__( self, preparer, # type: RequirementPreparer finder, # type: PackageFinder wheel_cache, # type: Optional[WheelCache] make_install_req, # type: InstallRequirementProvider use_user_site, # type: bool ignore_dependencies, # type: bool ignore_installed, # type: bool ignore_requires_python, # type: bool force_reinstall, # type: bool upgrade_strategy, # type: str py_version_info=None, # type: Optional[Tuple[int, ...]] ): super().__init__() assert upgrade_strategy in self._allowed_strategies self.factory = Factory( finder=finder, preparer=preparer, make_install_req=make_install_req, wheel_cache=wheel_cache, use_user_site=use_user_site, force_reinstall=force_reinstall, ignore_installed=ignore_installed, ignore_requires_python=ignore_requires_python, py_version_info=py_version_info, ) self.ignore_dependencies = ignore_dependencies self.upgrade_strategy = upgrade_strategy self._result = None # type: Optional[Result] def resolve(self, root_reqs, check_supported_wheels): # type: (List[InstallRequirement], bool) -> RequirementSet constraints = {} # type: Dict[str, Constraint] user_requested = {} # type: Dict[str, int] requirements = [] for i, req in enumerate(root_reqs): if req.constraint: # Ensure we only accept valid constraints problem = check_invalid_constraint_type(req) if problem: raise InstallationError(problem) if not req.match_markers(): continue assert req.name, "Constraint must be named" name = canonicalize_name(req.name) if name in constraints: constraints[name] &= req else: constraints[name] = Constraint.from_ireq(req) else: if req.user_supplied and req.name: canonical_name = canonicalize_name(req.name) if canonical_name not in user_requested: user_requested[canonical_name] = i r = self.factory.make_requirement_from_install_req( req, requested_extras=() ) if r is not None: requirements.append(r) provider = PipProvider( factory=self.factory, constraints=constraints, ignore_dependencies=self.ignore_dependencies, upgrade_strategy=self.upgrade_strategy, user_requested=user_requested, ) if "PIP_RESOLVER_DEBUG" in os.environ: reporter = PipDebuggingReporter() # type: BaseReporter else: reporter = PipReporter() resolver = RLResolver( provider, reporter, ) # type: RLResolver[Requirement, Candidate, str] try: try_to_avoid_resolution_too_deep = 2000000 result = self._result = resolver.resolve( requirements, max_rounds=try_to_avoid_resolution_too_deep ) except ResolutionImpossible as e: error = self.factory.get_installation_error( cast("ResolutionImpossible[Requirement, Candidate]", e), constraints, ) raise error from e req_set = RequirementSet(check_supported_wheels=check_supported_wheels) for candidate in result.mapping.values(): ireq = candidate.get_install_requirement() if ireq is None: continue # Check if there is already an installation under the same name, # and set a flag for later stages to uninstall it, if needed. installed_dist = self.factory.get_dist_to_uninstall(candidate) if installed_dist is None: # There is no existing installation -- nothing to uninstall. ireq.should_reinstall = False elif self.factory.force_reinstall: # The --force-reinstall flag is set -- reinstall. ireq.should_reinstall = True elif parse_version(installed_dist.version) != candidate.version: # The installation is different in version -- reinstall. ireq.should_reinstall = True elif candidate.is_editable or dist_is_editable(installed_dist): # The incoming distribution is editable, or different in # editable-ness to installation -- reinstall. ireq.should_reinstall = True elif candidate.source_link and candidate.source_link.is_file: # The incoming distribution is under file:// if candidate.source_link.is_wheel: # is a local wheel -- do nothing. logger.info( "%s is already installed with the same version as the " "provided wheel. Use --force-reinstall to force an " "installation of the wheel.", ireq.name, ) continue looks_like_sdist = ( is_archive_file(candidate.source_link.file_path) and candidate.source_link.ext != ".zip" ) if looks_like_sdist: # is a local sdist -- show a deprecation warning! reason = ( "Source distribution is being reinstalled despite an " "installed package having the same name and version as " "the installed package." ) replacement = "use --force-reinstall" deprecated( reason=reason, replacement=replacement, gone_in="21.2", issue=8711, ) # is a local sdist or path -- reinstall ireq.should_reinstall = True else: continue link = candidate.source_link if link and link.is_yanked: # The reason can contain non-ASCII characters, Unicode # is required for Python 2. msg = ( "The candidate selected for download or install is a " "yanked version: {name!r} candidate (version {version} " "at {link})\nReason for being yanked: {reason}" ).format( name=candidate.name, version=candidate.version, link=link, reason=link.yanked_reason or "<none given>", ) logger.warning(msg) req_set.add_named_requirement(ireq) reqs = req_set.all_requirements self.factory.preparer.prepare_linked_requirements_more(reqs) return req_set def get_installation_order(self, req_set): # type: (RequirementSet) -> List[InstallRequirement] """Get order for installation of requirements in RequirementSet. The returned list contains a requirement before another that depends on it. This helps ensure that the environment is kept consistent as they get installed one-by-one. The current implementation creates a topological ordering of the dependency graph, while breaking any cycles in the graph at arbitrary points. We make no guarantees about where the cycle would be broken, other than they would be broken. """ assert self._result is not None, "must call resolve() first" graph = self._result.graph weights = get_topological_weights( graph, expected_node_count=len(self._result.mapping) + 1, ) sorted_items = sorted( req_set.requirements.items(), key=functools.partial(_req_set_item_sorter, weights=weights), reverse=True, ) return [ireq for _, ireq in sorted_items] def get_topological_weights(graph, expected_node_count): # type: (DirectedGraph[Optional[str]], int) -> Dict[Optional[str], int] """Assign weights to each node based on how "deep" they are. This implementation may change at any point in the future without prior notice. We take the length for the longest path to any node from root, ignoring any paths that contain a single node twice (i.e. cycles). This is done through a depth-first search through the graph, while keeping track of the path to the node. Cycles in the graph result would result in node being revisited while also being it's own path. In this case, take no action. This helps ensure we don't get stuck in a cycle. When assigning weight, the longer path (i.e. larger length) is preferred. """ path = set() # type: Set[Optional[str]] weights = {} # type: Dict[Optional[str], int] def visit(node): # type: (Optional[str]) -> None if node in path: # We hit a cycle, so we'll break it here. return # Time to visit the children! path.add(node) for child in graph.iter_children(node): visit(child) path.remove(node) last_known_parent_count = weights.get(node, 0) weights[node] = max(last_known_parent_count, len(path)) # `None` is guaranteed to be the root node by resolvelib. visit(None) # Sanity checks assert weights[None] == 0 assert len(weights) == expected_node_count return weights def _req_set_item_sorter( item, # type: Tuple[str, InstallRequirement] weights, # type: Dict[Optional[str], int] ): # type: (...) -> Tuple[int, str] """Key function used to sort install requirements for installation. Based on the "weight" mapping calculated in ``get_installation_order()``. The canonical package name is returned as the second member as a tie- breaker to ensure the result is predictable, which is useful in tests. """ name = canonicalize_name(item[0]) return weights[name], name


--- layout: post title: 'Example Facebook PHP SDK: Post to Friend''s wall' date: 2011-08-21 02:46:29.000000000 +02:00 type: post published: true status: publish categories: - Coding tags: - api - facebook - php - sdk - stream_publish meta: _edit_last: '1' _thumbnail_id: '1155' dsq_thread_id: '391737682' author: login: bbWebdesign email<EMAIL_ADDRESS>display_name: Bob first_name: Bob last_name: Belderbos ---
I got a question from one of my readers how to automatically post to the Wall of a friend. I started to code a quick example, but I realized it might be valuable to more people, so here is the code and a short howto.
This example is in PHP. You first create an app at the Facebook developer page, then you get the Facebook PHP SDK 3.0 and download it to the defined folder (localhost/whatever/). The complete code example is here
Here you can see how this looks :
The SDK comes with an example php page, copy it over to the root of your project
For this exercise you need the extended permission publish_stream, which you append here:
Now when you login to the App you are asked for the normal and this extended permission:
Now that your user is logged in you can get the friends with this bit of code:
I embedded this in a form to choose the friend I want to message:
The user selects his/her friend, writes a message / and/or puts in a link, and clicks submit. Index.php receives these 3 post variables and embeds them in the $facebook->api 'post' call.
And that's it. It seems much work, but by adding the SDK you can make it a much more powerful application. Needless to say, you need to validate the ouputs obtained through this form. This is beyond the scope of this example. I zipped the code here to play with it yourself. Don't forget to first create your own App and put the App ID and Secret in the index.php page!
Here you see the form in action and the result on Roberto's wall:


Package org.drip.capital.allocation
Class EntityCapitalAssignmentSetting
java.lang.Object
org.drip.capital.allocation.EntityCapitalAssignmentSetting
public class EntityCapitalAssignmentSetting
extends java.lang.Object
EntityCapitalAssignmentSetting holds the Correlation Elasticities for the different Capital
Components as well as the Entity's Correlation Category. The References are:
- Bank for International Supervision(2005): Stress Testing at Major Financial Institutions: Survey Results and Practice https://www.bis.org/publ/cgfs24.htm
- Glasserman, P. (2004): Monte Carlo Methods in Financial Engineering Springer
- Kupiec, P. H. (2000): Stress Tests and Risk Capital Risk 2 (4) 27-39
- Module = Portfolio Core Module
- Library = Capital Analytics
- Project = Basel Market Risk and Operational Capital
- Package = Economic Risk Capital Entity Allocation
- Author:
- Lakshmi Krishnamurthy
-
Constructor Summary
Constructors Constructor Description EntityCapitalAssignmentSetting(int allocationCorrelationCategory, int noStressAllocationCategory, int noStressAllocationScheme, int systemicAllocationCategory, int gsstAllocationScheme, int correlatedAllocationCategory, int correlatedAllocationScheme, int idiosyncraticAllocationCategory, int idiosyncraticAllocationScheme)
EntityCapitalAssignmentSetting Constructor -
Method Summary
Modifier and Type Method Description int
allocationCorrelationCategory()
Retrieve the Allocation Correlation Category of the Capital Entityint
correlatedAllocationCategory()
Retrieve the Allocation Category for the Correlated Capital Componentint
correlatedAllocationScheme()
Retrieve the Allocation Scheme for the Correlated Capital Componentint
idiosyncraticAllocationCategory()
Retrieve the Allocation Category for the Idiosyncratic Capital Componentint
idiosyncraticAllocationScheme()
Retrieve the Allocation Scheme for the Idiosyncratic Capital Componentint
noStressAllocationCategory()
Retrieve the Allocation Category for the "No-Stress" Capital Componentint
noStressAllocationScheme()
Retrieve the Allocation Scheme for the "No-Stress" Capital Componentint
systemicAllocationCategory()
Retrieve the Systemic Allocation Category of the Capital Entityint
systemicAllocationScheme()
Retrieve the Allocation Scheme for the Systemic Capital Componentstatic EntityCapitalAssignmentSetting
UniformBeta(int allocationCorrelationCategory, int noStressAllocationCategory, int systemicAllocationCategory, int correlatedAllocationCategory, int idiosyncraticAllocationCategory)
Construct the Uniform Beta Instance of EntityCapitalAssignmentSettingstatic EntityCapitalAssignmentSetting
UniformBetaIdiosyncraticProRata(int allocationCorrelationCategory, int noStressAllocationCategory, int systemicAllocationCategory, int correlatedAllocationCategory, int idiosyncraticAllocationCategory)
Construct the Idiosyncratic Pro-Rata + Others Beta Instance of EntityCapitalAssignmentSettingMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
EntityCapitalAssignmentSetting
public EntityCapitalAssignmentSetting(int allocationCorrelationCategory, int noStressAllocationCategory, int noStressAllocationScheme, int systemicAllocationCategory, int gsstAllocationScheme, int correlatedAllocationCategory, int correlatedAllocationScheme, int idiosyncraticAllocationCategory, int idiosyncraticAllocationScheme) throws java.lang.ExceptionEntityCapitalAssignmentSetting Constructor- Parameters:
allocationCorrelationCategory
- Allocation Correlation Category of the Capital EntitynoStressAllocationCategory
- Allocation Category for the "No-Stress" Capital ComponentnoStressAllocationScheme
- Allocation Scheme for the "No-Stress" Capital ComponentsystemicAllocationCategory
- Allocation Category for the Systemic Capital ComponentgsstAllocationScheme
- Allocation Scheme for the Systemic Capital ComponentcorrelatedAllocationCategory
- Allocation Category for the Correlated Capital ComponentcorrelatedAllocationScheme
- Allocation Scheme for the Correlated Capital ComponentidiosyncraticAllocationCategory
- Allocation Category for the Idiosyncratic Capital ComponentidiosyncraticAllocationScheme
- Allocation Scheme for the Idiosyncratic Capital Component- Throws:
java.lang.Exception
- Thrown if the Inputs are Invalid
-
-
Method Details
-
UniformBeta
public static final EntityCapitalAssignmentSetting UniformBeta(int allocationCorrelationCategory, int noStressAllocationCategory, int systemicAllocationCategory, int correlatedAllocationCategory, int idiosyncraticAllocationCategory)Construct the Uniform Beta Instance of EntityCapitalAssignmentSetting- Parameters:
allocationCorrelationCategory
- Allocation Correlation Category of the Capital EntitynoStressAllocationCategory
- Allocation Category for the "No-Stress" Capital ComponentsystemicAllocationCategory
- Allocation Category for the Systemic Capital ComponentcorrelatedAllocationCategory
- Allocation Category for the Correlated Capital ComponentidiosyncraticAllocationCategory
- Allocation Category for the Idiosyncratic Capital Component- Returns:
- Uniform Beta Instance of EntityCapitalAssignmentSetting
-
UniformBetaIdiosyncraticProRata
public static final EntityCapitalAssignmentSetting UniformBetaIdiosyncraticProRata(int allocationCorrelationCategory, int noStressAllocationCategory, int systemicAllocationCategory, int correlatedAllocationCategory, int idiosyncraticAllocationCategory)Construct the Idiosyncratic Pro-Rata + Others Beta Instance of EntityCapitalAssignmentSetting- Parameters:
allocationCorrelationCategory
- Allocation Correlation Category of the Capital EntitynoStressAllocationCategory
- Allocation Category for the "No-Stress" Capital ComponentsystemicAllocationCategory
- Allocation Category for the Systemic Capital ComponentcorrelatedAllocationCategory
- Allocation Category for the Correlated Capital ComponentidiosyncraticAllocationCategory
- Allocation Category for the Idiosyncratic Capital Component- Returns:
- Idiosyncratic Pro-Rata + Others Beta Instance of EntityCapitalAssignmentSetting
-
allocationCorrelationCategory
public int allocationCorrelationCategory()Retrieve the Allocation Correlation Category of the Capital Entity- Returns:
- TRUE - The Allocation Correlation Category of the Capital Entity
-
noStressAllocationCategory
public int noStressAllocationCategory()Retrieve the Allocation Category for the "No-Stress" Capital Component- Returns:
- The Allocation Category for the "No-Stress" Capital Component
-
noStressAllocationScheme
public int noStressAllocationScheme()Retrieve the Allocation Scheme for the "No-Stress" Capital Component- Returns:
- The Elasticity for the "No-Stress" Capital Component
-
systemicAllocationCategory
public int systemicAllocationCategory()Retrieve the Systemic Allocation Category of the Capital Entity- Returns:
- TRUE - The Systemic Allocation Category of the Capital Entity
-
systemicAllocationScheme
public int systemicAllocationScheme()Retrieve the Allocation Scheme for the Systemic Capital Component- Returns:
- The Allocation Scheme for the Systemic Capital Component
-
idiosyncraticAllocationCategory
public int idiosyncraticAllocationCategory()Retrieve the Allocation Category for the Idiosyncratic Capital Component- Returns:
- The Allocation Category for the Idiosyncratic Capital Component
-
idiosyncraticAllocationScheme
public int idiosyncraticAllocationScheme()Retrieve the Allocation Scheme for the Idiosyncratic Capital Component- Returns:
- The Allocation Scheme for the Idiosyncratic Capital Component
-