PHP to Java bridge
The PHP Java™ Bridge in WebSphere sMash can be used to interact with Java Objects, implement Java™ Interfaces and instantiate and extend Java™ classes.
When to use the PHP to Java bridge
The Java bridge for PHP in IBM® WebSphere® sMash can help provide access to Java classes and functionality in PHP. This feature can help an application developer, for example, who wants to share a WebSphere sMash library built in Java with the rest of the community. The expectation is that all data exchange occurs through the global context and any custom Java object placed by the library in the global context can be accessed in a PHP application through the bridge.
Note: Using the bridge requires PHP developers to read and understand the Javadoc for the classes that they are accessing. This requires PHP developers to understand the Java class.
If you do not want PHP developers to have to understand the Java class you can write an extension to the PHP language using the extension interfaces described in the Extending PHP article. This enables you to provide a PHP view of the function provided by the Java class.
Example
The following code snippet shows how to access Java classes from a PHP script.
<?php $date = new Java("java.util.Date", 70, 9, 4); var_dump($date->toString()); $map = new Java("java.util.HashMap"); $map->put("title", "Java Bridge!"); $map->put("when", $date); echo $map->get("when")->toString()."\n"; echo $map->get("title")."\n"; $array = array(1,2,3,4,5); $map->put("stuff", $array); var_dump($map->get("stuff"))."\n"; $system = new JavaClass("java.lang.System"); echo "OS: ".$system->getProperty("os.name")."\n"; $math = new JavaClass("java.lang.Math"); echo "PI: ".$math->PI."\n"; ?>
The new Java("java.util.Date", 70, 9, 4)
call creates a new instance of the java.util.Date
class using the java.util.Date(int year, int month, int day)
constructor. Methods can then be called on the
object and $date->toString()
string returns the following information 'Sun Oct 04 00:00:00 GMT
1970'
.
The new Java("java.util.HashMap")
call creates a Java hash map. The script puts the date, a string, and an
array into this collection and then retrieves them. Although the script creates a PHP array, what gets put into the hash
map is a standard Java Map
. The same applies to strings. The Java bridge converts a PHP string (essentially
a byte array) into a java.lang.String
string so that the Java class receives argument types that it would
normally expect if the caller were another Java class.
The new JavaClass("java.lang.System")
call provides access to the java.lang.System
class. Static
methods can then be called on the class. The example invokes $system->getProperty()
. The same applies to
the java.lang.Math
class although in this case the example code is accessing a public static field (PI
)
rather than a static method.
Accessing a member
Accessing a member of an instance will first look for bean properties then public fields. For example
print $date->time
will first attempt to be resolved as $date->getTime()
,
then as $date.time
. Both static and instance members can be accessed on an object with this syntax.
Overload resolution is in general a hard problem given the differences in types between the two languages. The Java to PHP bridge employs a simple, but fairly effective, metric for determining which overload is the best match. It chooses the method that has the best matching number of arguments (types are ignored). If there is not an exact match, then if a method exists that has less arguments than provided by the script it will be used. The opposite does not hold true, the Java to PHP bridge will not invoke a Java method that has more arguments than the script provides because Java does not have default arguments. Note that method names in PHP are not case sensitive, potentially increasing the number of overloads from which to select.
Once a method is selected, the parameters are coerced if necessary, possibly with a loss of data (example: double precision floating point numbers could be converted to boolean if that is what the Java method is expecting).
Exception handling
The Java to PHP bridge enables a PHP script to catch exceptions thrown from the Java code.
Since Java exceptions are not the same as PHP exceptions, there is some conversion required. All Java exceptions get converted into a generic PHP exception class called JavaException. The JavaException class allows a catch handler to find out the cause (to find out the Java exception that was thrown). All PHP exceptions inherit from the base PHP Exception class a message and code; for JavaException exceptions the code will always be zero and the message is the message extracted from the native Java exception.
The following sample code passes an invalid argument to getProperty()
and then catches the java.lang.IllegalArgumentException
.
<?php try { $system = new Java("java.lang.System"); $system->getProperty(FALSE); } catch (JavaException $exception) { echo "Cause: ".$exception->getCause()."\n"; echo "Message: ".$exception->getMessage()."\n"; } ?>
The cause is the underlying Java exception. The message in the exception is copied directly from the
Java exception message (in this example the IllegalArgumentException
contains no message
and so displays nothing).
Iterating over Java objects
The Java Bridge allows Java objects implementing Iterable
to be iterated over in PHP.
The following snippet shows a Java ArrayList
being iterated over using a PHP
foreach
statement:
<?php $list = new Java("java.util.ArrayList"); $list->add("Hello World!"); $list->add(FALSE); $list->add(1234567890); foreach ($list as $key => $value) { echo $key." ".$value."\n"; } ?>
Selecting overloads with signatures
The Java Bridge selects a method or constructor based on the number and type of arguments
supplied. If no suitable method or constructor exists then the Java Bridge throws a
JavaException
. This exception can be caught in scripts if required.
If one or methods or constructors exist that have the right number of arguments, but those
arguments are not good matches for the argument types supplied by the caller, then the Java
Bridge selects the first one and tries that. It will also output a notice signalling that a
JavaSignature
should be used to help the Java Bridge resolve which overload to
call (see the following section).
This problem of selecting a suitable overload has been solved in WebSphere® sMash v1.1
with the addition of a new JavaSignature
class. The JavaSignature
class allows a script to specify exactly which constructor or method is invoked by defining
the argument types to look for.
The following sample code shows the JavaSignature
being used to select a
constructor for the Java String
class:
<?php $signature = new JavaSignature(JAVA_STRING); $string = new Java("java.lang.String", $signature, "Hello World!"); ?>
The arguments for JavaSignature
are drawn from the following PHP constants:
-
JAVA_BOOLEAN
-
JAVA_BYTE
-
JAVA_CHAR
-
JAVA_SHORT
-
JAVA_INT
-
JAVA_LONG
-
JAVA_FLOAT
-
JAVA_DOUBLE
-
JAVA_STRING
-
JAVA_OBJECT
Multiple arguments are comma separated, for example, new JavaSignature(JAVA_STRING, JAVA_INT)
.
You can specify arrays of Java types using the JAVA_ARRAY
modifier. For example, the
following selects an array of strings: new JavaSignature(JAVA_STRING | JAVA_ARRAY)
.
The following snippet shows a JavaSignature
selecting an overload of the valueOf
method on java.lang.String
. Note how the signature is passed as the first argument to the
method call. The Java Bridge knows to check there for signatures.
<?php $class = new JavaClass("java.lang.String"); $signature = new JavaSignature(JAVA_INT); var_dump($class->valueOf($signature,<PHONE_NUMBER>)); ?>
Java objects can be passed using the JAVA_OBJECT
argument. The class name for the object
is passed as an argument like this: new JavaSignature(JAVA_OBJECT, "java.lang.String")
.
Case sensitive method names
Methods in PHP are case insensitive, while Java is case sensitive. The Java bridge is case sensitive and so the PHP method name must match the Java method name exactly.
Importing Java classes
The new Java(...)
syntax quickly becomes tedious to use. The Java bridge can import
Java classes in to the PHP runtime using the java_import
extension function.
The following example shows the Java Integer
and Date
classes being imported:
<?php java_import("java.lang.Integer", NULL, FALSE); $value = new Integer(new JavaSignature(JAVA_STRING), "1234567890"); java_import("java.util.Date"); $date = new Date(70, 9, 4); ?>
Importing interfaces
Java interfaces can also be imported - the following sample code shows how to import the
Java Comparable
interface:
<?php java_import("java.lang.Comparable"); echo(ReflectionClass::export("Comparable")); ?>
Running this script in a Web browser produces the following output:
<?php Interface [ <internal> interface Comparable ] { - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [0] { } - Methods [1] { Method [ <internal> abstract public method compareTo ] { } } } ?>
Declaring interfaces
When a java class is imported, the resulting PHP class can optionally be defined to implement PHP interfaces representing imported Java interfaces
The second argument to java_import
is an array of interface names. The imported class
is configured to implement only those interfaces listed in the array. This is a convenience for the
script as many Java classes implement interfaces that are not required in PHP.
The following sample code shows how to import the Java File
class. The PHP class is
configured so that it implements the Comparable
interface. The Comparable
interface must already be in the PHP runtime when this java_import
call is made:
<?php var_dump(java_import("java.io.File", array("Comparable"), FALSE)); $file = new File(new JavaSignature(JAVA_STRING), "/"); ?>
Declaring a super class
java_import
will optionally declare a super class for the class being imported. If
the third argument to java_import
is TRUE
then the imported class is
declared with a super class. The super class must already have been imported into the PHP runtime.
The following sample code shows the Java SecureRandom
being imported so that it
declares a super class of Random
(this matches the Java class hierachy):
<?php java_import("java.security.SecureRandom", NULL, TRUE); ?>
Renaming classes
To avoid class name collisions it is sometimes useful to rename classes during the import.
An optional class name can be passed as the fourth argument to java_import
as follows:
<?php var_dump(java_import("java.lang.Integer", NULL, FALSE, "TestInteger")); $value = new TestInteger(new JavaSignature(JAVA_STRING), "1234567890"); ?>
Inner classes
PHP does not have the concept of an inner class. By default all static inner classes defined in a Java class that is imported will also be imported as top level PHP classes. Only static inner classes can be imported by the Java bridge. When a PHP class is created by importing a Java static inner class, the resulting PHP class is given the name of the inner class without using the name of the enclosing Java class.
For example: If a Java Class named Zoo
which has a static inner class named
Zoo.Tiger,
is imported then this will result in a PHP class named Zoo
and a PHP class named Tiger
.
The fifth and final argument to java_import
specifies whether to also import static inner
classes. The default is true
. If this argument is set to true
or omitted
then any public static inner classes of the class being imported are also imported. The snippet below shows
java.util.Map
being imported without its static inner class Entry
.
<?php java_import("java.util.Map", NULL, FALSE, NULL, FALSE); echo(ReflectionClass::export("Map")); var_dump(class_exists("Entry", FALSE)); // Does not exist! ?>
Static inner classes can also be explicitly imported by specifying their fully qualified name.
The snippet below shows the Entry
static inner class of Map
being explicitly imported
<?php java_import("java.util.Map.Entry"); echo(ReflectionClass::export("Entry")); ?>
Importing static inner classes as top level classes is convenient but has the potential to cause naming conflicts.
Such a conflict can be resolved by choosing to import the outer class without importing inner classes. Any
required static inner classes can then be explicitly imported. If required the inner classes can be renamed on the import.
The snippet below shows the Entry
static inner class of Map
being explicitly imported and renamed:
<?php java_import("java.util.Map", NULL, FALSE, NULL, FALSE); // Import without inner classes java_import("java.util.Map$Entry", NULL, FALSE, "MapEntry", FALSE); // Import the Entry inner class as MapEntry echo(ReflectionClass::export("MapEntry")); ?>
Java Bean Field Access
The Java bridge provides field access to set/get methods. The snippet below shows the
Java File
class being accessed through field gets:
<?php java_import("java.io.File"); $file = new File("/"); var_dump($file->Parent); ?>
The Java bridge turns the call to $file->Parent
into $file->getParent()
.
Setting a field value (Length
in the example below) calls the matching set method:
<?php java_import("java.lang.StringBuffer"); $buffer = new StringBuffer("Hello World!"); $buffer->Length = 5; var_dump($buffer->toString()); // Hello ?>
The field names for gets and sets are case sensitive.
Extending Java classes
The following sample code shows the Java File
class being extended in PHP:
<?php java_import("java.io.File"); class SuperFile extends File { function SuperFile($signature, $path) { parent::__construct($signature, $path); } function isThisCool() { return TRUE; // Way cool } } $file = new SuperFile(new JavaSignature(JAVA_STRING), "/"); var_dump($file->isDirectory()); var_dump($file->isThisCool()); ?>
Limitations
There are a few limitations to the Java bridge:
- PHP classes implemented via the Java bridge cannot use PHP's object callback mechanism.
- Only non final Java classes can be extended.
- It is not possible to extend abstract Java classes in PHP.
- The PHP class and its hierachy is only visible within the PHP runtime.
The ability of the Java Bridge to instantiate and extend Java classes is implemented using proxies. Therefore
whilst a PHP object based on a Java class can be passed outside of the PHP runtime by calling a method on a Java object and
passing a PHP object as an argument, the object passed to the Java method will be an instance of the
java class XAPIObject
rather than an instance of a the proxied Java class.
XAPIObject
is the programmatic (Java) interface to a PHP object. XAPIObject
is an interface and does not extend any Java base class (for example, File
in snippet above).


Deleted User
21-Oct-18 02:35 AM
ok, some news about cancellation of orders,
Whatever the state of the trade, as long as the funds are not received on generated addresses, users can ask for a REFUND.
The logic is :
Whoever asked for the cancel of order is handled, receiver, or sender, depending of the originator, the status move won t go by the same path :
Status codes :
//0 : new trade
//1 : sender confirmed the trade
//2 : receiver confirmed the trade
//3 : both confirmed, waiting for funding from both side
//4 : sender funding tx received
//5 : receiver funding tx received
//6 : both funding tx received
//7 : Swap done sender side
//8 : Swap done receiver side
//10 : Swap Complete !
//21 : Sender Cancelled
//22 : Receiver Cancelled
//25 : Sender cancelled, and both were refunded
//26 : Receiver cancelled, and both are refunded
//27 : Sender cancelled, sender refunded
//28 : Receiver cancelled, sender refunded
//29 : Sender cancelled, receiver refunded
//30 : Receiver cancelled, receiver refunded
Basically, when a trade is cancelled, the scripts will check during a finite amount of time that any other part didn t send in the meantime. If that's the case, the tx and amount received during the cancellation will be used to refund on a refund address (with specific dialog box when cancelling the trade). When this time is passed (maybe 2 days to begin), or whenever the side not refunded clicks as : it s ok, the trade isn t fetched anymore.
The amount of refund will be correlated to the amount received, this will have multiple advantages : If a sender wants to send via multiple tx, that will be possible, the agreeing about the deal will only happen when amounts are matched. A security is done that will ONLY send the amount if it matches exactly the trade, in the case it isn t the case, it will stay stuck until one side or other cancels it and triggers the global refunding.
Another point about that part, is the cancelling of an order will launch a modal to give the refund address. Why this : just because it s too risky to base only on originator address, as it can be multiple if the amount is gathered via multiple txes, the other point is that in case of private addresses, we can't know the originator address, and in the global scheme, the user don't need to input his refund address. This step being optional, it will prevent people from being lost
this specific step will need to be tested, as only the base logic is done atm.
will continue it and implement commands, if steps are handled fine, it will be pretty fast to add "real" commands


TW Assets App
-
Add ERC20 Token
Please fill in the token/project details
Name:
Contract addess:
Logo
Upload
Website:
Explorer:
Short description:
Create PR
Clear
Fill test data


ABOUT US
Talk by Andy, we believe there is much more to a great style than just the cut and color. We feel passionately about encouraging our clients to properly care for their hair after their initial visit. Our staff is extensively trained to always prescribe the appropriate care regimen for your particular needs by educating our clients with our large variety of hair products. We have partnered with Aveda to bring you products that will benefit you through exceptional performance, while continuing to deliver promise of environmental and social responsibility.


udm_find (PHP 4 >= 4.0.5, PHP 5 <= 5.0.5, PECL mnogosearch >= 1.0.0) udm_find — Perform search 说明 resource udm_find ( resource $agent , string $query ) Performs a search. The search itself. The first argument - session, the next one - query itself. To find something just type words you want to find and press SUBMIT button. For example, "mysql odbc". You should not use quotes " in query, they are written here only to divide a query from other text. mnoGoSearch will find all documents that contain word "mysql" and/or word "odbc". Best documents having bigger weights will be displayed first. If you use search mode ALL, search will return documents that contain both (or more) words you entered. In case you use mode ANY, the search will return list of documents that contain any of the words you entered. If you want more advanced results you may use query language. You should select "bool" match mode in the search from. 参数 agent A link to Agent, received after call to udm_alloc_agent(). query mnoGoSearch understands the following boolean operators: & - logical AND. For example, "mysql & odbc". mnoGoSearch will find any URLs that contain both "mysql" and "odbc". | - logical OR. For example "mysql|odbc". mnoGoSearch will find any URLs, that contain word "mysql" or word "odbc". ~ - logical NOT. For example "mysql & ~odbc". mnoGoSearch will find URLs that contain word "mysql" and do not contain word "odbc" at the same time. Note that ~ just excludes given word from results. Query "~odbc" will find nothing! () - group command to compose more complex queries. For example "(mysql | msql) & ~postgres". Query language is simple and powerful at the same time. Just consider query as usual boolean expression. 返回值 Returns a result link identifier on success 或者在失败时返回 FALSE. User Contributed Notes 2 notes =============================================================================== For me (PHP 4.3.3, Mnogo 3.2.15 on FreeBSD) Mnogo doesn't work as described - but very well if done as in the PHP-template distributed by MnogoSearch I had huge problems getting Udm_Find(... to return anything at all. All the other calls worked, like udm_get_doc_count(... but _find seemed to insist on returning nothing, no matter what I tried. However, I had actually a working installation of mnogo, using the PHP template, so it was just to find the difference in the, BTW impressive, work by Sergey 'gluke' Kartashoff. The result was surprising, see below. The parameter UDM_PARAM_QUERY is not mentioned in the manual = 30204) { $dbaddr='mysql://mnogo:mnogo@/mnogo/?dbmode=single'; } else { $dbaddr='mysql://mnogo:mnogo@/mnogo/'; $dbmode='single'; } */ // which contradicts the manual for never versions $iDoItAsInTheManual = true; //Set to false and it works if ($iDoItAsInTheManual) { $res=Udm_Find($udm_agent, $q); } else // This works: { Udm_Set_Agent_Param($udm_agent,UDM_PARAM_QUERY,$q); $res=Udm_Find($udm_agent,"anything here, makes no difference!!"); } $url = udm_get_res_field( $res, //resource res, 0, // int row, UDM_FIELD_URL // int field ); echo $url; // Fails if $iDoItAsInTheManual==true, otherwise it works fine ?> I don't know where something has gone wrong but I hope this may help someone save a little time. =============================================================================== Here is a small snipet of code that will perform a search on mnogosearch and (in not so pretty a way) display the results. Note that it appears that UDM_PARAM_FIRST_DOC starts at 1, but perhaps should be 0. $searchText resulted in $totalMatches matches"; echo "The result set (pagesize) is $pageSize\n"; echo "The first doc is row $firstRow and the last doc is $lastRow \n"; $row=0; for ($i=$firstRow-1;$i<$lastRow;$i++) { $row++; echo "Match $row:"; echo 'Url: '; $url = udm_get_res_field ($mResult,$i,UDM_FIELD_URL); echo "$url"; echo "\nTitle: "; echo udm_get_res_field ($mResult, $i,UDM_FIELD_TITLE); echo "\nMeta Desc:"; echo udm_get_res_field ($mResult, $i,UDM_FIELD_DESC); echo "\nPage Text: \n"; echo udm_get_res_field ($mResult, $i,UDM_FIELD_TEXT); echo "\n


Plugin Information |
|---|
View CollabNet Plugins on the plugin site for more information. |
Older versions of this plugin may not be safe to use. Please review the following warnings before using an older version:
The CollabNet Plugin is an integration with CollabNet TeamForge. Don't have TeamForge yet? Try our free 90-day trial.
Provided features include:
- Authenticate users from TeamForge. If setup as the "Build & Test" application, it can even use Single Sign-On.
- Authorization from TeamForge, including the ability to set permissions in Jenkins based on roles in your TeamForge project.
- Upload the build log or workspace artifacts to the TeamForge Documents.
- Upload workspace artifacts to the TeamForge File Release System, as a post-build publishing task or as a build promotion task.
- Open/update/close TeamForge Tracker artifacts based on the Jenkins build status.
- Upload workspace artifacts to the Lab Management Project Build Library. (Requires CollabNet Lab Management).
Help/Support:
Installation help and configuration help are available on help.collab.net.
Please submit any questions to the TeamForge forum.
FAQ:
1. Does this integrate with / update the SFEE Plugin?
No, the SFEE Plugin is a separate plugin that is not maintained by CollabNet. It works with CollabNet SourceForge 4.4, so it may be a good choice if you have an older version. Our plugin is not a direct upgrade. If you change from using the SFEE Plugin to the CollabNet Plugin, you will have to reconfigure your jobs appropriately. You should be able to use both plugins simultaneously, if you wish, although it might be a bit confusing.
2. Uploads fail when using an SSL-enabled TeamForge server. What do I do?
You'll need to add the server's certificate to your java keystore on the Jenkins server. First dowload the certificate to your Jenkins server. You should be able to get it by opening a browser window on the TeamForge server, viewing the certificate associated with that page, and exporting the certificate file. Then, you'll need to run something like "sudo keytool -keystore $JAVA_HOME/jre/lib/security/cacerts -import -file teamforge.cert". (On Windows, replace $JAVA_HOME with %JAVA_HOME%). If you haven't changed your java keystore's password, it will be "changeit". After you've imported the cert to the java instance that Jenkins is using, it should be able to upload.
3. I'm having problems with login and logout when using CollabNet Authentication. It seems to be redirecting to an unexpected site.
Go to the Jenkins configure page and look in the Email Notifacation section. The CollabNet plugin uses the value of the Jenkins URL set here for redirection. If it's wrong, logins will go astray. Check that it's set to the real Jenkins URL.
4. I've setup authentication, but can no longer get to the "Manage Jenkins" pages.&nbps; How do I get back into the system?
As long as you have access to the machine and user running Jenkins, you'll be able to get back in. Just log into the machine. Find the Jenkins home (by default, this will be the ~/.jenkins or ~/.hudson directory of the user running Jenkins). Edit the config.xml, changing the value for "useSecurity" to false. Restart Jenkins and you should not need to log in to get access.
Changelog:
- Version 1.1.6*: Released 3/12/2011.
- Misc code modernization/cleanup and bug fixes.
- Fix to work with Copy Artifact Plugin when using a build parameter for project name. (JENKINS-8969)
Version 1.1.5: Released 4/22/2010.
- Feature addition: Added configurable authorization cache when using TeamForge authorization to reduce load generated on TeamForge server
- Feature addition: Passwords are stored more securely
Version 1.1.4: Released 3/26/2010.
- Bug fix: SVN tagging plugin does not work with 1.1.3
Version 1.1.3: Released 2/26/2010.
- Bug fix: A ClassCastException that caused builds to fail when the Tracker or Document Uploader component was enabled, is now fixed.
- Feature addition: CollabNet Build & Test reauthenticates when TeamForge Single Sign On tokens from another user are observed.
- Feature addition: A Hudson job that is not associated with a TeamForge project can now be viewed and configured by all authenticated users.
Version 1.1.2: Released 12/21/2009.
- Bug fix: FRS now can upload when using master/slave configuration
- Bug fix: Error message related to Promoted Build plugin during startup
- Bug fix: Having a trailing "/" in a CollabNet TeamForge URL ended the user's session and prevented single sign-on with Hudson
- Feature addition: You can now use TeamForge's ScmViewer as the subversion repository viewer
- Feature addition: You can enable/disable SSO between Hudson and CollabNet TeamForge
Version 1.1.1: Released 09/03/2009.
- Bug fix: Fixed a 500 error when the plugin is installed using some browsers (IE 8 and Chrome)
- Bug fix: Fixed problem where triggered builds in Hudson (e.g., periodic build or poll scm) won't run if CollabNet Authorization is in use.
- Bug fix: Fixed problems that caused incorrect redirection on logging
- Bug fix: Fixed problem where, for some users, the 'Assigned to' field in the Tracker component could not be set
Version 1.1: Released 07/20/2009:
- Fix to make file uploads faster (as of r17463).
- Feature addition: Allow system-wide shared authentication which can be overridden for individual components (as of r18043).
- Bug fix: Fixed errors that occurred when running Hudson in an iFrame in IE (r18646).
- Bug fix: Fixed bug where SSO was not working on very first page load (r18684).
Version 1.0: Released 04/14/2009.


Nice Experience with TodoMVC Oct 26
I learned a style tip about prototypal inheritance a few days ago from my study of BackboneJS, and I got to encounter the friendly folks behind TodoMVC.
I noticed a parameter that wasn't strictly necessary to the behavior of a function.
Here are the functions:
filterOne: function(todo){ todo.trigger('visible'); } filterAll: function(){ app.todos.each(this.filterOne, this); }
Here is the change you can make to filterAll
without breaking the behavior:
filterAll: function(){ app.todos.each(this.filterOne); }
I received a reply to my filed issue in less than a few hours. @passy let me know that, while not strictly necessary, passing in the extra this
helps by keeping the current object around in case the filterOne
function needs it in the future.
This sort of situation is not one that I have encountered in object-oriented programming, where you can't reassign the context of a function. In Javascript, this is really easy and, as I found out, something you encounter right away.
Do check out TodoMVC if you're poking around modern Javascript frameworks. There is nothing like looking at real implementations. They responded to my issue filing right away, and I've learned a lot from their code so far.


Weather Dashboard
Find Me
° C
° F
Search for city:
Search
Clear History
Temperature:
Humidity:
Wind Speed:
UV Index:
5-Day forecast:


|
Nana C++ Library An open-source C++ framework project The Programmer's Guide |
||||||||||||||||||||
|
nana::paint::image_process::selector Description The class selector is used for configuring the algorithms of image processing. Model of None Public base classes None Members
File nana/paint/image_process_selector.hpp Notes 1, If users give a non-existing name for choosing an image processor, the call succeed, but no image processor would be replaced. 2, The image processors that Nana provides are: Stretch algorithms:
Blend algorithm:
Line algorithm:
Examples This is an example which creates a form to display an image, and when the size of form is changed, it makes the image fit the form. In addtion, the example also shows the way to switch the stretch image processing algorithm. #include <nana/gui/wvl.hpp> #include <nana/gui/drawing.hpp> #include <nana/paint/image_process_selector.hpp> class tsform : public nana::gui::form { public: tsform() { img_.open(STR("image01.bmp")); //Open the image file. //Copy the image to the window nana::size sz = size(); nana::gui::drawing dw(*this); dw.bitblt(0, 0, sz.width, sz.height, img_, 0, 0); dw.update(); //Register events make_event<nana::gui::events::click>(*this, &tsform::_m_click); make_event<nana::gui::events::size>(*this, &tsform::_m_size); } private: //Switchs the algorithm between two algorithms in every click on the form. void _m_click() { static bool interop; nana::paint::image_process::selector sl; sl.stretch(interop ? "bilinear interoplation" : "proximal interoplation"); interop = !interop; } //When the window size is changed, it stretches the image to fit the window. void _m_size() { nana::gui::drawing dw(*this); dw.clear(); //Before stretch, it should clear the operations that are generated before. dw.stretch(nana::rectangle(size()), img_, nana::rectangle(img_.size())); dw.update(); } private: nana::paint::image img_; }; int main() { tsform fm; fm.show(); nana::gui::exec(); } Result of application: Stretch the image through bilinear interoplation Stretch the image through proximal interoplation See also None. Move to The Nana Programmer's Guide Main Page |
||||||||||||||||||||


Brad Diesel
Call me whenever you can...
4 Hours Ago
John Pierce
I got your message bro
4 Hours Ago
Nora Silvester
The subject goes here
4 Hours Ago
See All Messages
15 Notifications
4 new messages
3 mins
8 friend requests
12 hours
3 new reports
2 days
See All Notifications
Phone case
Home
Phonecases
Add company
Add Company
Model Name
2D
3D
4D
Company Name
Select one
Samsung
Oppo
Vivo
Model Name
2d image slider
Choose file
2d image cover
Choose file
2d image mask
Choose file
2d-Size
2d-Price
2d-Description
3d image slider
Choose file
3d image cover
Choose file
3d image mask
Choose file
3d-Size
3d-Price
3d-Description
4d image slider
Choose file
4d-Size
4d-Price
4d-Description


IVAN THE TERRIBLE A film review by Mark R. Leeper Copyright 1990 Mark R. Leeper
Capsule review: How better to start April than getting out of the way Eisenstein's great quasi-historical pseudo- epic IVAN THE TERRIBLE (Parts I and II)? You won't learn much history but you will be able to tell people you've seen it.
It has come time to review another undiscovered classic of early film. This one shows up on public television every once in a long while but has been completely forgotten by anyone who doesn't watch PBS. The film is really two Soviet films by Serge Eisenstein, IVAN THE TERRIBLE (Part I) and IVAN THE TERRIBLE (Part II). It is difficult to decide if this is really one film or two.  About all that is tied up is the current sentence. Talk about leaving room for a sequel! Eisenstein doesn't just leave ROOM, he leaves the whole house! An historical note on Eisenstein: he appears to be the only Jew revered by the Soviets since Karl Marx. Apparently he hid his religion by not asking to leave.
As with most films about conflict, the IVANs tell the story of the unending struggle between pretty people and ugly people, with ugly people being the bad guys. (This struggle may be more recent than we tend to think. In Dickens's time it was more a struggle of people with funny names such as Twist and Nickleby against people with ugly names such as Mr. Scrooge or Miss Zits.) It is only with the more realistic Schwarzenegger and Stallone films of the 1980s that the good guys are ugly too (and in Stallone's case they are making up for lost time).  From a distance Ivan looks ugly: his hair is greasy and slicked down and he looks like he probably has fleas. But it turns out Ivan may not be ugly after all; it may be a plot by his aunt who has a face like a corn-grinding stone. It was probably she who put the Penzoil in his Vitalis.
The film opens with Ivan's coronation, which is more long and expensive than it is interesting, but then that is true of a lot of Russian films. They were made that way to prove to the world that Communism works so well that they can afford to waste film. But you know that Ivan is in big trouble because the place is just teeming with *ugly* people. There are a few pretty people who are saying loyal sorts of things, but there are far more uglies and they are not at all happy that Ivan is being crowned. Be warned, however, that some of the pretty people may well turn out to be villains. You will know this is happening when the camera starts showing them in unflattering close-ups.
Following the coronation there is a reception and banquet that turns out to be the funniest meal on screen since Blake Edwards's THE PARTY, except I guess it came before. During the course of a one-hour meal:
1. people plot against Ivan,
2. Ivan's best friend announces he cannot support Ivan and exiles himself,
3. there is a peasants' revolt where they burn the outskirts of the city,
4. the peasants storm the palace,
5. Ivan fights with one peasant in hand-to-hand combat,
6. Ivan announces he is going to be the People's Czar, in spite of the fact he is ugly,
7. the peasants return to their homes, the Mongol ambassador arrives and demands tribute,
8. and Ivan declares war on the Mongols.
And you never get to see the dessert.
The second film has some definite stylistic differences from the first film. During the course of making the two films, Eisenstein became more anti-West as time went along. By the time he made the second film the anti-foreigner sentiment is obvious. He puts much more bright light at the bottom of the screen so the subtitles will be almost impossible to read. At the same time, this makes the plot more complex and harder to follow.
I wouldn't say this about Part I, but IVAN THE TERRIBLE (Part II) ranks up there with the original PHANTOM OF THE OPERA, the original HELL'S ANGELS, THE RETURN OF DRACULA, and SHE'S GOTTA HAVE IT as a film that suddenly goes from black-and-white to color in the middle for no obvious reason. It is quite a shock. Presumably the Soviet economy took an upturn during the shooting. Unfortunately, the blues on the colored stock have been lost to time but the reds are somewhere between vibrant and oppressive, much like Ivan himself. Part II has enough songs to rank almost as a musical and some odd dance numbers, including one around a peasant dressed like the Statue of Liberty.
The two film together are fairly long but the plot is not difficult to follow because it moves so slowly. Other than the banquet scene, in any given fifteen-minute stretch you can be reasonably sure that not much as happened. In fact, even in two films about Ivan, we learn almost nothing about the man or anything he did. The snail-paced plot instead gives plenty of time for meaningful looks and poses. It is as if every frame was intended to be a great--if not very realistic--painting.
In all, I would say that IVAN THE TERRIBLE is two classic films you may want to see some time. (Mediocre classics don't get ratings on the -4 to +4 scale.)
Mark R. Leeper att!mtgzx!leeper<EMAIL_ADDRESS>.
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


PAGER (Pattern Analysis of Gene Expression in Root) is a pipeline designed to analyse and visualize gene and reporter expression patterns in root.
PAGER work with data coming from the CellSet image analysis tool and is based on the Root System Markup Language (RSML).
PAGER perfoms two main analysis: 1. A pair-wise comparison for reporter flourescence levels for each combinaison of reporter lines. For each combinaison, PAGER perfoms a MANOVA analysis and computes an r-square, Pearson and Spearman (ranked) correlation factors. 2. A pair-wise comparison of the reporter fluorescence levels data and expression data (microarray) for each line. For each combinaison, PAGER computes an r-square, Pearson and Spearman (ranked) correlation factors.
PAGER has been developed as a Shiny app, to ease its maintenance and deployment. If you want to try the app, with sample data, try the online version:
Or, if you want to use your own data, launch it from your own computer: 1. Install R (if you do not have the latest version of R, it will help to update it) 2. (Optional) Install RStudio 3. Open R and, in the console, type in the following code:
install.packages("shiny") library("shiny") shiny::runGitHub("PAGERoot/PAGER-Shiny", "PAGERoot")
PAGER will open, either in a new window if you are using RStudio, or in your favorite web browser.
PAGER requires two types of datafiles to run: 1. An RSML file that contains the fluoresence data 2. A datafile (.csv) that contains the gene expression data For each of these files, the data needs to be organised by cell types. The types allowed are : - Columella - Stele - Cortex - Quiecent center - Endodermis - Exodermis - Lateral root cap View user manual
PAGER was build to work with data store in a Root System Markup Language (RSML) file.
The RSML format was indeed created as common format for storing root system information, and accomodates well for the storage of fluoresence data.
PAGER what born from a collaboration between researchers from the Carnegie Science Institute (José Dinneny) and the Forschungszentrum Juelich (Guillaume Lobet). PAGER what first used here:
A synthetic biology pipeline identifies a common regulatory mechanism between stress and development in roots Rui Wu, Lina Duan, José Pruneda-Paz, Guillaume Lobet, Shahram Emami, Dong-ha Oh, Micheal Pound, Jonah Kornbluh, Muh-ching Yee, Steve Kay, and José R. Dinneny


Questionaire
Please take the time to answer these short questions. They will help us form a personal path to help you reach your goals.


JMServices has now expanded coverage of the Bootcamp across various schools in Leicester, as far as Evington (Judge Meadow School), with exceptional feedback on the quality of the sessions. To the left are few scenes of our 3 week bootcamp in action at Beaumont Leys School. The creativity which the students demonstrated was fascinating. Ideas involved using dynamic technologies including app development to provide various solutions to common problems in today's society.
Our Reviews1 Hour Sessions For £25 each
£43 for 2 Hour Packaged Sessions
"inspirational personna, creative visionary"
"great rapport with students, role model"


{% extends 'layout.html' %} {% block pageTitle %} NHS login - {{ data.primaryUserFirstName or 'Alice' }} has sent you an invite {% endblock %} {# {% block beforeContent %} {{ breadcrumb({ href: "/", text: "Home" }) }} {% endblock %} #} {% block content %} {% if emailSent === 'true' %} {{ warningCallout({ "heading": "Email has been sent", "HTML": "
Check the user's email inbox.
" }) }} {% endif %}{{ data.primaryUserFirstName or 'Alice' }} is inviting you to enter their {{ data.service or 'stepWell' }} account and act on their behalf.
If you do not already have a {{ data.service or 'stepWell' }} account, you must create one and share some of your NHS login information with {{ data.service or 'stepWell' }}.
You will be added to {{ data.primaryUserFirstName or 'Alice' }}'s NHS login as their {{ data.relationship or 'carer'}} and will be able to act on their behalf. This means {{ data.primaryUserFirstName or 'Alice' }} will be able to see your name in the account management area of their NHS login.
On behalf of Alice, you will be able to:
You will not be able to see Alice's medical records.


--- title: "THE WEAVERS' STORIES" date: "2000-01-01 21:09:10 -06:00" categories: - fall - lecture subtitle: "" event-notes: "" layout: "events" event-image: "weavers-stories1.jpg" event-dates: "2021 date to be announced" event-location: "Red Butte Garden Richard K. Hemingway Orangerie" button-type: "register" tickets-link: "#" tickets-button: "hide" registration-info: "N/A" instructor-info: "N/A" member-cost: "free event" public-cost: "free event" refund-policy: "hide" published: true ---
We regret to announce that the 2020 Weavers' Stories event has been cancelled this year.
Please visit The Adopt-A-Native-Elder website to find out how you can help support Native American Elders.
2017 CNN Hero and Founder of Adopt-A-Native-Elder, Linda Myers, will speak about her 30-year experience of serving traditional Elders living on the Navajo Reservation. Ms. Myers will share personal stories of the women who rely on weaving as a powerful tool in their fight against poverty. Elderly Navajo often struggle living on their own in very remote areas of the Reservation. Most of the traditional weavers are over 80 years old.
Event from 5:30-8PM
Beautiful authentic traditional Navajo rugs and jewelry will be displayed and presented for sale.
100% of the proceeds go directly to the weavers. For many, this is the Weaver's sole means of support.
Free admission for this event only from 5:30-8PM.
Adopt-A-Native-Elder is a 501(c)(3), tax-exempt, non-profit charitable organization. Visit The Adopt-A-Native-Elder website.


Programmers can use fixed point data types as easily as any other data types in C language, to describe fixed point arithmetic operations. Explicit support for fixed point types in programming language will allow compiler developers to design fixed point specific optimisations in compilers [36]. It also provides a standardised mechanism to define and use fixed point data types.
DSP-C defines the following fixed point data types:


This is my personal web space where I muse about technology, design & food among other things. You can read more about me or contact me. Also check out my tools of the trade page and my recomended books site.
February 8, 2013
Leadership, inovation, project management and creativity.
February 2, 2013
Some fine articles about life , productivity and finding balance.
January 27, 2013
Articles of interest on front-end web design, markup and performance.
January 19, 2013
First edition of the weekly articles of interest post.
I am a digital strategist, creative director and user experience expert with broad-based online experience, including digital strategy, digital marketing, responsive design and development, social media outreach, email marketing, content strategy and user experience. I have been a frequent speaker on developing a meaningful digital presence for organizations and non-profits.
Until recently, I was the digital director for a global humanitarian aid organization. The digital team, which I built from the ground up, managed front and back end development, online branding, user experience, information architecture and email marketing.
View my resume


#include <stMetricTree.h>
Inheritance diagram for stMetricTree< ObjectType, EvaluatorType >:
Public Types | |
| typedef ObjectType | tObject |
| typedef EvaluatorType | tMetricEvaluator |
| typedef stResult< ObjectType > | tResult |
Public Member Functions | |
| stMetricTree (stPageManager *pageman) | |
| stMetricTree (stPageManager *pageman, EvaluatorType *metricEval) | |
| virtual | ~stMetricTree () |
| stPageManager * | GetPageManager () |
| virtual double | GetMinOccupation () |
| virtual stCount | GetMaxOccupation () |
| virtual stCount | GetHeight () |
| virtual long | GetNumberOfObjects () |
| virtual long | GetNodeCount () |
| virtual stDistance | GetDistanceLimit () |
| virtual stTreeInfoResult * | GetTreeInfo () |
Protected Attributes | |
| stPageManager * | myPageManager |
Developers are encouraged to use this class as the interface to manipulate all trees in their applications (polymorphism).
Marcos Rodrigues Vieira<EMAIL_ADDRESS>Josiel Maimone de Figueiredo<EMAIL_ADDRESS>Adriano Siqueira Arantes<EMAIL_ADDRESS>Definition at line 104 of file stMetricTree.h.
|
|
This is the class that abstracts the metric evaluator used by this metric tree. Reimplemented from stMetricAccessMethod< ObjectType, EvaluatorType >. Reimplemented in stDummyTree< ObjectType, EvaluatorType >, stGHTree< ObjectType, EvaluatorType >, and stVPTree< ObjectType, EvaluatorType >. Definition at line 115 of file stMetricTree.h. Referenced by stMetricTree< ObjectType, EvaluatorType >::stMetricTree(). |
|
|
This is the class that abstracts the object used by this metric tree. Reimplemented from stMetricAccessMethod< ObjectType, EvaluatorType >. Reimplemented in stDummyTree< ObjectType, EvaluatorType >, stGHTree< ObjectType, EvaluatorType >, and stVPTree< ObjectType, EvaluatorType >. Definition at line 109 of file stMetricTree.h. |
|
|
This is the class that abstracs an result set. Reimplemented from stMetricAccessMethod< ObjectType, EvaluatorType >. Reimplemented in stDBMTree< ObjectType, EvaluatorType >, stDFTree< ObjectType, EvaluatorType >, stDummyTree< ObjectType, EvaluatorType >, stGHTree< ObjectType, EvaluatorType >, stMTree< ObjectType, EvaluatorType >, stSlimTree< ObjectType, EvaluatorType >, and stVPTree< ObjectType, EvaluatorType >. Definition at line 120 of file stMetricTree.h. |
|
|
Creates a new metric tree using a given page manager. This instance will not claim the ownership of the given page manager. It means that the application must dispose the page manager when it is no loger necessary.
Definition at line 130 of file stMetricTree.h. References stMetricAccessMethod< ObjectType, EvaluatorType >::myMetricEvaluator, stMetricTree< ObjectType, EvaluatorType >::myPageManager, and stMetricTree< ObjectType, EvaluatorType >::tMetricEvaluator. |
|
|
Creates a new metric tree using a given page manager and metric evaluator. This instance will not claim the ownership of the given page manager and metric evaluator. It means that the application must dispose them when they are no loger necessary. It allows the metric evaluator to be shared by other objects.
Definition at line 149 of file stMetricTree.h. References stMetricTree< ObjectType, EvaluatorType >::myPageManager. |
|
|
Disposes this instance and release all associated resources. The page manager will never be disposed by this destructor. Definition at line 161 of file stMetricTree.h. References stMetricAccessMethod< ObjectType, EvaluatorType >::myMetricEvaluator. |
|
|
Returns the limit distance between 2 objects in the tree. That is . In other words, there is no distance greater than this.
Reimplemented in stMTree< ObjectType, EvaluatorType >, and stSlimTree< ObjectType, EvaluatorType >. Definition at line 226 of file stMetricTree.h. References stDistance. |
|
|
Returns the height of the tree.
Reimplemented in stDBMTree< ObjectType, EvaluatorType >, stDFTree< ObjectType, EvaluatorType >, stGHTree< ObjectType, EvaluatorType >, stMTree< ObjectType, EvaluatorType >, stSlimTree< ObjectType, EvaluatorType >, and stVPTree< ObjectType, EvaluatorType >. Definition at line 197 of file stMetricTree.h. References stCount. |
|
|
Returns the maximum occupation in a node of the tree. If not implemented, returns 0. Reimplemented in stDBMTree< ObjectType, EvaluatorType >, stDFTree< ObjectType, EvaluatorType >, stDummyTree< ObjectType, EvaluatorType >, stMTree< ObjectType, EvaluatorType >, and stSlimTree< ObjectType, EvaluatorType >. Definition at line 187 of file stMetricTree.h. References stCount. |
|
|
Returns the minimum occupation in a node of the tree. If not implemented, returns -1. Reimplemented in stDBMTree< ObjectType, EvaluatorType >, stDFTree< ObjectType, EvaluatorType >, stMTree< ObjectType, EvaluatorType >, and stSlimTree< ObjectType, EvaluatorType >. Definition at line 179 of file stMetricTree.h. |
|
|
Returns the number of nodes of this tree.
Reimplemented in stDBMTree< ObjectType, EvaluatorType >, stDFTree< ObjectType, EvaluatorType >, stDummyTree< ObjectType, EvaluatorType >, stMTree< ObjectType, EvaluatorType >, and stSlimTree< ObjectType, EvaluatorType >. Definition at line 215 of file stMetricTree.h. |
|
|
Returns the number of objetcs of this tree.
Reimplemented in stDBMTree< ObjectType, EvaluatorType >, stDFTree< ObjectType, EvaluatorType >, stDummyTree< ObjectType, EvaluatorType >, stGHTree< ObjectType, EvaluatorType >, stMTree< ObjectType, EvaluatorType >, stSlimTree< ObjectType, EvaluatorType >, and stVPTree< ObjectType, EvaluatorType >. Definition at line 206 of file stMetricTree.h. |
|
|
Returns the page manager used by this slim tree. Definition at line 171 of file stMetricTree.h. References stMetricTree< ObjectType, EvaluatorType >::myPageManager. |
|
|
This method returns information about the tree like FatFactor, mean object size and others.
Reimplemented in stDBMTree< ObjectType, EvaluatorType >, stDFTree< ObjectType, EvaluatorType >, stMTree< ObjectType, EvaluatorType >, and stSlimTree< ObjectType, EvaluatorType >. Definition at line 236 of file stMetricTree.h. |
|
|
The page manager used by thismetric tree. Definition at line 243 of file stMetricTree.h. Referenced by stMetricTree< ObjectType, EvaluatorType >::GetPageManager(), stMetricTree< ObjectType, EvaluatorType >::stMetricTree(), and stDummyTree< ObjectType, EvaluatorType >::~stDummyTree(). |


Mention the project you want now!
The width of the border of a box, around the content and padding areas and before ... The border width, combined with border style and border color, can also be .
The width of the border of a box, around the content and padding areas and before ... The border width, combined with border style and border color, can also be .


I'm a 23 year old software engineer from Edmonton Alberta. I studied computer engineering at the University of Alberta before moving into web development.
A catalog of things I think are cool, solutions to problems that I could't find well documented online, and general thoughts about programming and life.
Email<EMAIL_ADDRESS>Git: lucasgauk


Links to resources
The Kraaij-Pohlmann stemming algorithm is an ANSI C program for stemming in Dutch. Although
advertised as an algorithm, it is in fact a program without an accompanying
algorithmic description. It is possible to produce a fairly clean Snowball
version, but only by sacrificing exact functional equivalence. But that does not
matter too much, since in the demonstration vocabulary only 32 words out of over
45,000 stem differently. Here they are:
|
source | | ANSI C stemmer | | Snowball stemmer
| | airways | | airways | | airway
| | algerije | | algerije | | alrije
| | assays | | assays | | assay
| | bruys | | bruys | | bruy
| | cleanaways | | cleanaways | | cleanaway
| | creys | | creys | | crey
| | croyden | | croyd | | croy
| | edele | | edel | | edeel
| | essays | | essays | | essay
| | gedijen | | gedij | | dij
| | geoff | | of | | off
| | gevrey | | gevrey | | vrey
| | geysels | | ysel | | gey
| | grootmeesteres | | grootmee | | grootmeest
| | gr•otmeesteres | | gr•otmee | | gr•otmeest
| | hectares | | hectaar | | hect
| | huys | | huys | | huy
| | kayen | | kayen | | kaay
| | lagerwey | | lagerwey | | larwey
| | mayen | | mayen | | maay
| | meesteres | | meester | | meest
| | oppasseres | | oppasser | | oppas
| | pays | | pays | | pay
| | royale | | royale | | royaal
| | schilderes | | schilder | | schild
| | summerhayes | | summerhayes | | summerhaye
| | tyumen | | tyuum | | tyum
| | verheyen | | verheyen | | verheey
| | verleideres | | verleider | | verleid
| | ytsen | | yts | | ytsen
| | yves | | yve | | yves
| | zangeres | | zanger | | zang
|
The Kraaij-Pohmann stemmer can make fairly drastic reductions to a word. For
example, infixed ge is removed, so geluidgevoelige stems to
luidvoel. Often, therefore, the original word cannot be easily guessed from
the stemmed form.
Here then is the Snowball equivalent of the Kraaij-Pohlmann algorithm.
|


--- layout: post title: Meat Fresh? date: 2006-07-04 00:00:00 category: amusing ---
Now you can get air fresheners that capture the fragrance you really crave... MEAT!


Dividing
问题描述 :
Marsha and Bill own a collection of marbles. They want to split the collection among themselves so that both receive an equal share of the marbles. This would be easy if all the marbles had the same value, because then they could just split the collection in half. But unfortunately, some of the marbles are larger, or more beautiful than others. So, Marsha and Bill start by assigning a value, a natural number between one and six, to each marble. Now they want to divide the marbles so that each of them gets the same total value. Unfortunately, they realize that it might be impossible to divide the marbles in this way (even if the total value of all marbles is even). For example, if there are one marble of value 1, one of value 3 and two of value 4, then they cannot be split into sets of equal value. So, they ask you to write a program that checks whether there is a fair partition of the marbles.
输入:
Each line in the input file describes one collection of marbles to be divided. The lines contain six non-negative integers n1 , . . . , n6 , where ni is the number of marbles of value i. So, the example from above would be described by the input-line “1 0 1 2 0 0″. The maximum total number of marbles will be 20000.
The last line of the input file will be “0 0 0 0 0 0″; do not process this line.
The last line of the input file will be “0 0 0 0 0 0″; do not process this line.
输出:
For each collection, output “Collection #k:”, where k is the number of the test case, and then either “Can be divided.” or “Can’t be divided.”.
Output a blank line after each test case.
Output a blank line after each test case.
样例输入:
1 0 1 2 0 0 1 0 0 0 1 1 0 0 0 0 0 0
样例输出:
Collection #1: Can't be divided. Collection #2: Can be divided.
解题代码:
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader read = new BufferedReader(new InputStreamReader( System.in)); String[] s; int[] marbles; int sum; int part; int times = 0; while (true) { marbles = new int[6]; sum = 0; s = read.readLine().split(" "); for (int i = 0; i < 6; i++) { marbles[i] = Integer.parseInt(s[i]); } if (marbles[5] > 5) { marbles[5] = 4 + marbles[5] % 2; } if (marbles[4] > 6) { marbles[4] = 6 - marbles[4] % 2; } if (marbles[3] > 5) { marbles[3] = 4 + marbles[3] % 2; } if (marbles[2] > 5) { marbles[2] = 4 + marbles[2] % 2; } if (marbles[1] > 4) { marbles[1] = 4 - marbles[1] % 2; } for (int i = 0; i < 6; i++) { sum += marbles[i] * (i + 1); } if (sum == 0) { break; } times++; System.out.printf("Collection #%d:\n", times); if (sum % 2 != 0) { System.out.println("Can't be divided."); System.out.println(); continue; } part = sum / 2; if (search(part, marbles)) { System.out.println("Can be divided."); } else { System.out.println("Can't be divided."); } System.out.println(); } } public static boolean search(int part, int[] marbles) { int[] flg = new int[part + 1]; flg[0] = 1; for (int i = 0; i < 6; i++) { for (int j = 1; j <= marbles[i]; j++) { int base = j * (i + 1); if (base > part) { break; } for (int k = part - (i + 1); k >= base - i - 1; k--) { if (flg[k] != 0) { flg[k + i + 1] = 1; } if (flg[part] != 0) { return true; } } } } return flg[part] != 0; } }
(adsbygoogle = window.adsbygoogle || []).push({});
使用ListNodeWrapper很蹩脚的感觉，没有更好的解决办法？
在方法1里面：
//遍历所有的边，计算入度
for(int i=0; i<V; i++)
{
degree = 0;
for (j = adj .begin(); j != adj .end(); ++j)
{
degree[*j]++;
}
}
为什么每遍历一条链表，要首先将每个链表头的顶点的入度置为0呢？
比如顶点5，若在顶点1、2、3、4的链表中出现过顶点5，那么要增加顶点5的入度，但是在遍历顶点5的链表时，又将顶点5的入度置为0了，那之前的从顶点1234到顶点5的边不是都没了吗？
对于输出格式不用控制？？还是直接使用cout输出。？？
博主的C++功底真是好
[…] 答案：http://www.acmerblog.com/interview-2-1549/ […]
不错，赞一个！
Dijkstra 不适合有负权值的边吧
第二块代码if(it != mp.end())应改为if(it != mp.end() && (i+1)!=(it->second +1))；因为第二种解法如果数组有重复元素 就不正确
很好，注释很详细啊
漏了一个"不"，已修正:)
很高兴你会喜欢这个网站。目前还没有一个开发团队，网站是我一个人在维护，都是用的开源系统，也没有太多需要开发的部分，主要是内容整理。非常感谢你的关注。
https://coding.net/moon/miracle
不错，值得借鉴


Predictions of alpha diversity are fitted from presence data, first abundance is modeled from occupancy models and then, several diversity indices are calculated and finally GLM models are used to predict diversity in different environments and select priority areas.
| Version: | 1.0.6 |
| Depends: | R (≥ 3.2.2), MuMIn, unmarked |
| Imports: | dplyr, ggplot2, glmulti, qpcR, raster, vegan |
| Suggests: | knitr, rgdal, rmarkdown |
| Published: | 2017-03-02 |
| Author: | Derek Corcoran [aut, cre], Dylan Kesler [aut], Lisa Webb [aut], Giorgia Graells [aut], Nicole Michel [ctb], Mike Meredith [ctb] |
| Maintainer: | Derek Corcoran <derek.corcoran.barrios at gmail.com> |
| License: | GPL-3 |
| NeedsCompilation: | no |
| Materials: | README |
| CRAN checks: | DiversityOccupancy results |
| Reference manual: | DiversityOccupancy.pdf |
| Vignettes: |
R package DiversityOccu: Alpha diversity modeled from Occupancy |
| Package source: | DiversityOccupancy_1.0.6.tar.gz |
| Windows binaries: | r-devel: DiversityOccupancy_1.0.6.zip, r-release: DiversityOccupancy_1.0.6.zip, r-oldrel: DiversityOccupancy_1.0.6.zip |
| OS X binaries: | r-release: DiversityOccupancy_1.0.6.tgz, r-oldrel: DiversityOccupancy_1.0.6.tgz |
| Old sources: | DiversityOccupancy archive |
Please use the canonical form https://CRAN.R-project.org/package=DiversityOccupancy to link to this page.


Staff
Coordination
- Lycan - Event Lead
Music
- Luck Rock - Staff
- ExplodingPonyToast - Staff
- Blackened Blue - Staff
A/V
- Larscis - Lead
Design
- HauntedTuba - Staff
Social Media
- Kevin from TrotCon - Lead
Discord
- Fizzbuzz - Lead
- Gajinka - Assistant Lead
- Midnight Aegis - Moderator
Changelings
- Jamis - Staff
- Katharine Berry - Staff
Charity
- Perrydotto - Lead


 Those glorious trees are all gone. The oak trees in the region of Bashan should also be like people who are wailing, because enemies have cut down the oak trees in the dense forest.
3 And listen to the shepherds crying because the fertile pastures have been ruined. Listen to the lions roar; they roar because the thick forest where they live near the Jordan River has been ruined.
4 This is what Yahweh my God said to me: "I want you to supervise this flock of sheep until the flock perishes.
5 The dealers in sheep will kill the sheep, and no one will punish them. Those who sell the sheep will say, 'I praise Yahweh, because I will become rich!' And the shepherds whom the owners hire do not feel sorry for the sheep.
6 And similarly, I no longer feel sorry for the people of this country. I am going to allow their fellow countrymen and their king, to oppress them. They will ruin this country, and I will not rescue any of them."
7 So I became the shepherd of a flock of sheep that dealers were going to slaughter and to sell the meat. Then I took two shepherds' staffs. I named the one staff 'Kindness' and the other staff 'Union.' This is how I began to shepherd the sheep.
8 But the three shepherds who had been with the flock detested me, and I became impatient with the owners who had hired us all. Within one month I had destroyed those shepherds.
9 So I said to the dealers, "I will no longer be a shepherd for you. I will allow the ones that are dying to die. I will allow the ones that are getting lost to perish. And I will not prevent those that remain from eating each other."
10 Then I took the staff that I had named 'Kindness,' and I broke it. I did this because Yahweh had told me to cancel the covenant that he had made with all his tribes of Israel.
11 So that covenant was ended on that very day. The dealers who were watching me knew by seeing what I was doing that I was giving them a message from Yahweh.
12 I told them, "If you think it is right, pay me for my work. If you do not think it is right, do not pay me." So they paid me only thirty pieces of silver.
13 Then Yahweh said to me, "That is a ridiculously small amount of money that they have for your work. So put it into the treasury." So I took the silver to the temple of Yahweh, and I deposited it in the treasury there.
14 Then I broke my second staff, the one that I had named "Union." That indicated that Judah and Israel would no longer be together as brothers.
15 Then Yahweh said to me, "Take again the things that a foolish shepherd uses,
16 because I am going to appoint a new shepherd for the people, one who will not take care of my people.  As for the healthy sheep, he will not feed them; instead, he will butcher them for his own food and will tear off their hooves.
17 But terrible things will happen to that foolish shepherd who abandons the flock. May his enemies strike his arm and his right eye with their swords. May he have no more strength in his arm, and may his right eye become completely blind."


[Gecode] Interaction between shared variables and idempotency
Christian Schulte
schulte at imit.kth.se
Tue Jun 7 16:29:35 CEST 2005
Dear all,
initially, the tests for sharing and equality on views was meant to address
issues with shared variables for idempotent propagators.
As a reminder, a propagator returns ES_FIX if it is at a fixpoint and
ES_NOFIX if it is not at a fixpoint. For efficiency, the propagator should
try hard to tell ES_FIX most of the times when it is actually at fixpoint.
However, this is difficult for propagators computing on shared views:
performing an operation on a view also narrows the domain of the shared
view.
Here are three strategies for finding out whether a propagator is at
fixpoint with shared views.
1. Suppose a propagator that only performs at most one write operation to a
view. Typical examples are "smart" propagators such as distinct, regular,
etc. They work by first computing new domain information for each view and
then writing or posting this information back to the views. Here one can use
a trick to find out whether one has computed a fixpoint or not: a view x
provides an operation x.modified(). When a propagator starts execution
modified() is false for all views. Only after a modification has taken
place, it becomes true. So the following works: before the propagator posts
to the view x, it checks whether x is already modified. If yes, the
propagator might not be at a fixpoint. Otherwise, it is.
2. The propagator computes in a loop until a fixpoint is reached. The
propagator must make sure that this loop really computes a fixpoint! For
example, when the loop is based until no view changes this also must
consider that no shared view has been changed. Here the trick with modified
is not available.
3. Check for sharing once and for all. If none of the above works, just
check whether the propagator has shared views or not. If it has, ALWAYS
report ES_NOFIX! This can be achieved most efficiently by making the
propagator generic with respect to whether to return ES_FIX and ES_NOFIX
through a template.
Here comes also an example why this matters. Assume domain consistent
distinct and variables x with domain {1,2} and y both with domain {2,3} and
the following three views v1 := x+0, v2 := x+1, v3 := y. Propagation should
yield x=1 and y=3 directly! However, if the propagator does not detect that
v1 and v2 are shared it will only propagate that x=1 and y in {2,3}!
 And yes, almost all propagators are faulty (but
linear and bool!)...
Christian
--
Christian Schulte, http://www.imit.kth.se/~schulte/
More information about the gecode-users
mailing list


Assembly Biosciences (ASMB) Presents At Biotech Focus Day: Boston Area Innovation - Slideshow
by SA Transcripts, https://seekingalpha.com/author/sa-transcriptsThe following slide deck was published by Assembly Biosciences, Inc. in conjunction with this event.


Patrol boat
test send
local network
mainnet network
ropsten network
custom
Mimi W.
CCO (Chief Cat Officer)
send
call
sendTransaction
Test Token
1,320.123545


--- layout: post title: "Composed assertions with Unquote" description: "With F# and Unquote, you can write customized, composable assertions." date: 2014-03-21 8:52 UTC tags: [F#, Unit Testing] --- {% include JB/setup %}
{{ page.description }}
Yesterday, I wrote this unit test:
[<Theory; UnitTestConventions>] let PostReturnsCorrectResult (sut : TasksController) (task : TaskRendition) = let result : IHttpActionResult = sut.Post task verify <@ result :? Results.StatusCodeResult @> verify <@ HttpStatusCode.Accepted = (result :?> Results.StatusCodeResult).StatusCode @>
For the record, here's the SUT:
type TasksController() = inherit ApiController() member this.Post(task : TaskRendition) = this.StatusCode HttpStatusCode.Accepted :> IHttpActionResult
There's not much to look at yet, because at that time, I was just getting started, and as always, I was using Test-Driven Development. The TasksController class is an ASP.NET Web API 2 Controller. In this incarnation, it merely accepts an HTTP POST, ignores the input, and returns 202 (Accepted).
The unit test uses AutoFixture.Xunit to create an instance of the SUT and a DTO record, but that's not important in this context. It also uses Unquote for assertions, although I've aliased the test
function to verify
. Although Unquote is an extremely versatile assertion module, I wasn't happy with the assertions I wrote.
The problem is the duplication of logic. First, it verifies that result
is, indeed, an instance of StatusCodeResult. Second, if that's the case, it casts result
to StatusCodeResult in order to access its concrete StatusCode property; it feels like I'm almost doing the same thing twice.
You may say that this isn't a big deal in a test like this, but in my experience, this is a smell. The example looks innocuous, but soon, I'll find myself writing slightly more complicated assertions, where I need to type check and cast more than once. This can rapidly lead to Assertion Roulette.
For a minute there, I caught myself missing xUnit.net's Assert.IsAssignableFrom<T>
method, because it returns a value of type T
if the conversion is possible. That would have enabled me to write something like:
let scr = Assert.IsAssignableFrom<Results.StatusCodeResult> result
Assert.Equal(HttpStatusCode.Accepted, scr.StatusCode)
It seems a little nicer, although in my experience, this quickly turns to spaghetti, too. Still, I found myself wondering if I could do something similar with Unquote.
At this point, you are welcome to pull GOOS at me and quote: listen to your tests! If the tests are difficult to write, you should reconsider your design; I agree, but I can't change the API of ASP.NET Web API. In Web API 1, my preferred return type for Controller actions were HttpResponseMessage, but it was actually a bit inconvenient to work with in unit tests. Web API 2 introduces various IHttpActionResult implementations that are easier to unit test. Perhaps this could be better, but it seems like a step in the right direction.
In any case, I can't change the API, so coming up with a better way to express the above assertion is warranted.
To overcome this little obstacle, I wrote this function:
let convertsTo<'a> candidate = match box candidate with | :? 'a as converted -> Some converted | _ -> None
(You have to love a language that let's you write match box
! There's also a hint of such nice over Some converted
...)
The convertsTo function takes any object as input, and returns an Option containing the converted value, if the conversion is possible; otherwise, it returns None. In other words, the signature of the convertsTo function is obj -> 'a option
.
This enables me to write the following Unquote assertion:
[<Theory; UnitTestConventions>] let PostReturnsCorrectResult (sut : TasksController) (task : TaskRendition) = let result : IHttpActionResult = sut.Post task verify <@ result |> convertsTo<Results.StatusCodeResult> |> Option.map (fun x -> x.StatusCode) |> Option.exists ((=) HttpStatusCode.Accepted) @>
While this looks more verbose than my two original assertions, this approach is more composable.
The really beautiful part of this is that Unquote can still tell me what goes wrong, if the test doesn't pass. As an example, if I change the SUT to:
type TasksController() = inherit ApiController() member this.Post(task : TaskRendition) = this.Ok() :> IHttpActionResult
The assertion message is:
System.Web.Http.Results.OkResult |> Dsl.convertsTo |> Option.map (fun x -> x.StatusCode) |> Option.exists ((=) Accepted) None |> Option.map (fun x -> x.StatusCode) |> Option.exists ((=) Accepted) None |> Option.exists ((=) Accepted) false
Notice how, in a series of reductions, Unquote breaks down for me exactly what went wrong. The top line is my original expression. The next line shows me the result of evaluating System.Web.Http.Results.OkResult |> Dsl.convertsTo
; the result is None. Already at this point, it should be quite evident what the problem is, but in the next line again, it shows the result of evaluating None |> Option.map (fun x -> x.StatusCode)
; again, the result is None. Finally, it shows the result of evaluating None |> Option.exists ((=) Accepted)
, which is false.
Here's another example. Assume that I change the SUT to this:
type TasksController() = inherit ApiController() member this.Post(task : TaskRendition) = this.StatusCode HttpStatusCode.OK :> IHttpActionResult
In this example, instead of returning the wrong implementation of IHttpActionResult, the SUT does return a StatusCodeResult instance, but with the wrong status code. Unquote is still very helpful:
System.Web.Http.Results.StatusCodeResult |> Dsl.convertsTo |> Option.map (fun x -> x.StatusCode) |> Option.exists ((=) Accepted) Some System.Web.Http.Results.StatusCodeResult |> Option.map (fun x -> x.StatusCode) |> Option.exists ((=) Accepted) Some OK |> Option.exists ((=) Accepted) false
Notice that it still uses a series of reductions to show how it arrives at its conclusion. Again, the first line is the original expression. The next line shows the result of evaluating System.Web.Http.Results.StatusCodeResult |> Dsl.convertsTo
, which is Some System.Web.Http.Results.StatusCodeResult
. So far so good; this is as required. The third line shows the result of evaluating Some System.Web.Http.Results.StatusCodeResult |> Option.map (fun x -> x.StatusCode)
, which is Some OK
. Still good. Finally, it shows the result of evaluating Some OK |> Option.exists ((=) Accepted)
, which is false. The value in the option was HttpStatusCode.OK, but should have been HttpStatusCode.Accepted.
Unquote is a delight to work with. As the project site explains, it's not an API or a DSL. It just evaluates and reports on the expressions you write. If you already know F#, you already know how to use Unquote, and you can write your assertion expressions as expressive and complex as you want.


C* Primer
Cassandra and Modelling Basics
cqlsh> SELECT * FROM presenters WHERE eventname='CassandraPrimer' AND company='ING'; eventname | company | name | title | area | twitter -----------------+---------+---------------------+--------------+------+----------- CassandraPrimer | ING | Christopher Reedijk | Dev Engineer | NL | @creedijk CassandraPrimer | ING | Gary Stewart | Dev Engineer | NL | @Gaz_GandA (2 rows)
ING Netherlands (@ingnl)
a little bit about us
Gary Stewart
Christopher Reedijk
- Dev Engineer
- Love/hate relationship with C*
- 14 years of experience in IT
- @ING since: 01-01-2012
- Dev Engineer
- Back-end guy
- 10 years of experience in IT
- @ING since: 01-01-2011
3 Challenges
challenge 1 Improve availability
without trading consistency
availability & consistency
Consequences of not being available
source: nu.nl
availability & consistency
Consequences of not being consistent
challenge 2
Aim to be easier scalable
Changes are happening at an increasing pace
easier scalable
Stop focusing on the
expected loadyesterday
source: bradfrostweb.com
easier scalable
Start focusing on the
unexpected load
      today tomorrow   source: bradfrostweb.com
challenge 3
Adopt new ways of thinking
Become the top engineering company
new way of thinking
ING's culture is changing fast.
Waterfall to Scrum to DevOps in less than 2 years
new way of thinking
Aim to approach problems as green field
"Un-learn" principles that don't scale
Use cache correctly!
Reduce locking (transaction)
Cassandra Internals
Objectives
Introduction into Apache Cassandra and Datastax
Learn about the drivers
Learn about partitioning, replication factor and consistency levels
Learn about the network topology
Learn about the write and read path
DataStax and Cassandra
Founded in 2010 by Jonathan Ellis and Matt Pfeil
80% Apache Cassandra code contribution
Offer commercial support for DataStax Enterprise version of Cassandra
DataStax Enterprise integrates Search and Analytics
Head Quarter in San Francisco Bay area
EMEA office opened in March 2013
Native Protocol / DataStax Drivers
CQL3 Only
Fully asynchronous protocol, using Netty
Server notifications
Java, C#, Python, node.js and Ruby, ...
Many policies, including:
TokenAwarePolicy, DowngradeConsistencyRetryPolicy, etc...
Metrics (codahale) included
com.datastax.cassandra cassandra-driver-core 2.0.8
Apache Cassandra
Created by Avinash Lakshman and Prashant Malik at Facebook
Cassandra is
Cassandra is not
- A distributed database
- Highly scalable
- Fault tolerant
- Consistency is tunable
- High throughput
- Network topology aware
- Multi-DC Active-Active
- Written in Java
- A column family
- CQL3
- ACID compliant database
- A relational database
- ANSI SQL compliant
- A document database
Logical Grouping
Keyspace: group of tables
Table: group of data
Replication Factor:
Number of copies of data
Cassandra Replication Strategy
Token Range 0 -> 2127-1 in Ring Formation
Consistent Hashing Algorithm
Default: Murmur3 Partitioner
Replica nodes in clockwise
Gossip protocol between nodes
Replication Factor (RF) = 3
Cassandra Replication Strategy - Questions
- What is the function of the (murmur3)partitioner?
- Can a node hold a partition with a token outside its primary range?
- In a 3 node cluster with RF=2, how much total data volume does each node own?
Network Topology Awareness
Tuneable Consistency
Configureable Consistency Level (CL)
per read and write action
Writes
- Any
- One
- Two
- Three
- Local_Quorum
- Quorum
- Each_Quorum
- All
Reads
- One
- Two
- Three
- Local_Quorum
- Quorum
- Each_Quorum
- All
Strong Consistency
CAP – Consistency, Availability, Partition Tolerance
Consistency is achieved with W + R > RF
Quorum = (Integer) RF / 2 + 1
Questions
- How many nodes can act as a coordinator?
- What is role of the forwarder?
- How could RF and CL be tuned to ensure strong consistency?
Write Path
Read Path
Write/Read path - Questions
- What is flushing?
- How is the partition key cache populated?
- Will compaction impact performance?
Summary
- Cassandra is a masterless NoSQL storage engine
- Cassandra's consistency is tuneable per query
- Replication factor is defined per keyspace
- Partitioning is used to determine which node contains the data
- Write path writes to both commitlog and Memtables
- The commitlog is an append-only log, replayed to restore a downed node's Memtables
- Read path is designed to limit i/o as much as possible
- SStables are immutable
Data Modelling
Objectives
Learn basic modelling techniques
Learn how to use Cassandra DDL
(Data Definition Language)
Learn how to use Cassandra DML
(Data Manipulation Language)
Apache Thrift, Hector, Astyanax
Column col = new Column(ByteBuffer.wrap("product".getBytes()))); col.setValue(ByteBuffer.wrap("phone".getBytes()); col.setTimestamp(System.currentTimeMillis()); ColumnOrSuperColumn c = new ColumnOrSuperColumn(); c.setColumn(col); Mutation m = new Mutation(); m.setColumn_or_supercolumn(c); List<Mutations> ms = new ArrayList<Mutation>(); ms.add(m); Map<String, List<Mutations>> cf = new HashMap<String, List<Mutations>>(); cf.put("products", m); Map<ByteBuffer, Map<String, List<Mutation>>> records = new HashMap<ByteBuffer, Map<String, List<Mutation>>>(); records.put(ByteBuffer.wrap("key".getBytes()), cf); client.batch_mutate(records, consistencyLevel);
CQL3
INSERT INTO products (product_id, product) VALUES (“id12321”, “phone”);
Why CQL3?
Usability
Readability
Familiarity
Excellent for modelling data
Programming language agnostic
Keyspace
CREATE KEYSPACE "primer" WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', 'datacenter1' : 3 }; USE primer;
Primary Key
The Primary Key
- The key that uniquely identifies a row
- A primary key consists of:
- A (composite) partition key
- One or more clustering columns
e.g. PRIMARY KEY (partition key, cluster columns, ...)- The partition key determines on which node the partition resides
- Data is ordered in cluster column order within the partition
Simple Table
CREATE TABLE party_account ( id varchar, account varchar, type varchar, name varchar, PRIMARY KEY (id) );
INSERT INTO party_account (id, account, type, name) VALUES ('11111', 'NL00INGB1111111111','Payment','Chris');
SELECT * FROM party_account WHERE id ='11111'; id | account | name | type ------+--------------------+-------+--------- 11111 | NL00INGB1111111111 | Chris | Payment
Simple Table - Question
What do you expect the output to be?
DROP TABLE party_account; CREATE TABLE party_account ( id varchar, account varchar, type varchar, name varchar, PRIMARY KEY (id) );
INSERT INTO party_account (id, account, type, name) VALUES ('11111', 'NL00INGB1111111111','Payment','Chris'); INSERT INTO party_account (id, account, type, name) VALUES ('11111', 'NL00INGB2222222222','Loan','Chris'); INSERT INTO party_account (id, account, type, name) VALUES ('55555', 'NL00INGB5555555555','Payment', 'Gary');
SELECT * FROM party_account WHERE id in ('11111','55555');
Option - A id | account | name | type ------+--------------------+-------+--------- 11111 | NL00INGB2222222222 | Chris | Loan 55555 | NL00INGB5555555555 | Gary | Payment
Option - B id | account | name | type ------+--------------------+-------+--------- 11111 | NL00INGB1111111111 | Chris | Payment 11111 | NL00INGB2222222222 | Chris | Loan 55555 | NL00INGB5555555555 | Gary | Payment
Composite Partition Key
Note the extra brackets in the primary key!
CREATE TABLE party_account ( id varchar, account varchar, type varchar, name varchar, PRIMARY KEY ( ( id , account ) ) );
INSERT INTO party_account (id, account, type, name) VALUES ('11111', 'NL00INGB1111111111','Payment','Chris'); INSERT INTO party_account (id, account, type, name) VALUES ('11111', 'NL00INGB2222222222','Loan','Chris');
SELECT * FROM party_account WHERE id = '11111' AND account IN ('NL00INGB1111111111','NL00INGB2222222222'); id | account | name | type ------+--------------------+-------+--------- 11111 | NL00INGB1111111111 | Chris | Payment 11111 | NL00INGB2222222222 | Chris | Loan
Composite Partition Key - Question
CREATE TABLE party_account ( id varchar, account varchar, type varchar, name varchar, PRIMARY KEY ( ( id , account ) ) );
Will the following query work?
SELECT * FROM party_account WHERE id = '11111'
Clustering Columns
CREATE TABLE party_account ( id varchar, account varchar, type varchar, name varchar, PRIMARY KEY ( id , account ) );
INSERT INTO party_account (id, account, type, name) VALUES ('11111', 'NL00INGB1111111111','Payment','Chris'); INSERT INTO party_account (id, account, type, name) VALUES ('11111', 'NL00INGB2222222222','Loan','Chris');
SELECT * FROM party_account WHERE id = '11111' ; id | account | name | type ------+--------------------+-------+--------- 11111 | NL00INGB1111111111 | Chris | Payment 11111 | NL00INGB2222222222 | Chris | Loan
(Clustering) Order By
SELECT * FROM party_account WHERE id = '11111' ORDER BY account DESC;
CREATE TABLE party_account ( id varchar, account varchar, type varchar, name varchar, PRIMARY KEY ( id , account ) ) WITH CLUSTERING ORDER BY (account DESC);
Partition keys are not ordered!
You can only order by a clustering column
Data will be ordered ASCending by default
Clustering Columns - Question
CREATE TABLE party_account ( id varchar, account varchar, type varchar, name varchar, PRIMARY KEY ( id , account ) );
Will the following query work?
SELECT * FROM party_account WHERE id = '11111' AND account IN ('NL00INGB1111111111','NL00INGB2222222222');
Static Columns
Introduced in Cassandra 2.0
CREATE TABLE party_account ( id varchar, account varchar, type varchar, name varchar STATIC, PRIMARY KEY ( id , account ) );
INSERT INTO party_account (id, account, type, name) VALUES ('11111', 'NL00INGB1111111111','Payment','Chris'); INSERT INTO party_account (id, account, type ) VALUES ('11111', 'NL00INGB2222222222','Loan');
SELECT * FROM party_account WHERE id = '11111' ; id | account | name | type ------+--------------------+-------+--------- 11111 | NL00INGB1111111111 | Chris | Payment 11111 | NL00INGB2222222222 | Chris | Loan
Updates versus Inserts
INSERT INTO party_account (id, account, type, name) VALUES ('11111','NL00INGB2222222222','Payment','Chris'); UPDATE party_account SET type = 'Payment', name = 'Chris' WHERE id = '11111' AND account = 'NL00INGB2222222222';
Inserts and Updates are almost always the same
Updates will insert when row does not exist!
Unique constraint errors do not exist in Cassandra!
Collections
CREATE TABLE collections_example ( id int PRIMARY KEY, set_example set<text>, list_example list<text>, map_example map<int, text>, );
INSERT INTO collections_example (id, set_example, list_example, map_example) VALUES (1, {'set A', 'setB'}, ['list A', 'list B'], { 1 : 'map A', 2 : 'map B'}); UPDATE collections_example SET set_example = set_example + {'set C'} WHERE id = 1;
SELECT * FROM collections_example WHERE id = 1 ; id | list_example | map_example | set_example ---+----------------------+--------------------------+---------------------------- 1 | ['list A', 'list B'] | {1: 'map A', 2: 'map B'} | {'set A', 'set C', 'setB'}
Batches
BEGIN BATCH INSERT INTO party_account (id, account, type, name) VALUES ('11111', 'NL00INGB1111111111','Payment','Chris'); INSERT INTO party_account (id, account, type, name) VALUES ('11111','NL00INGB2222222222','Payment','Chris'); APPLY BATCH;
Use batches for atomicity not performance!
Use asynchronous queries for performance!
Time to Live (TTL)
CREATE TABLE party_account ( id varchar, account varchar, type varchar, name varchar, PRIMARY KEY ( id , account ) );
INSERT INTO party_account (id, account, type, name) VALUES ('11111', 'NL00INGB2222222222','Loan','Chris') USING TTL 3600; // Expires data in one hour
Time to Live (TTL) - Question
What do you expect the output to be after 10 seconds?
CREATE TABLE party_account ( id varchar, account varchar, type varchar, name varchar, PRIMARY KEY ( id , account ) );
INSERT INTO party_account (id, account, type, name) VALUES ('11111', 'NL00INGB2222222222','Loan','Chris'); INSERT INTO party_account (id, account, name) VALUES ('11111', 'NL00INGB2222222222','Chris') USING TTL 10; SELECT * FROM party_account WHERE id = '11111'
Option - A id | account | name | type ------+--------------------+-------+--------- 11111 | NL00INGB2222222222 | null | Loan
Option - B id | account | name | type ------+--------------------+-------+--------- 11111 | NL00INGB2222222222 | Chris | Loan
Counters
CREATE TABLE party_counter ( id varchar, num_accounts counter, PRIMARY KEY (id) );
UPDATE party_counter SET num_accounts = num_accounts + 1 WHERE id = '11111'
Counter tables can only consist of primary key and counters
Warning - not idem-potent
Lightweight Transactions
Introduced in Cassandra 2.0
CREATE TABLE party_account ( id varchar, account varchar, type varchar, name varchar, PRIMARY KEY ( id , account ) ); INSERT INTO party_account (id, account, type, name) VALUES ('11111', 'NL00INGB1111111111','Payment','Chris');
UPDATE party_account SET name = 'Gary' WHERE id = '11111' AND account = 'NL00INGB1111111111' IF name = 'Chris'; [applied] ----------- True
UPDATE party_account SET name = 'Gary' WHERE id = '11111' AND account = 'NL00INGB1111111111' IF name = 'Chris'; [applied] | name -----------+------ False | Gary
De-normalize
Don't do this Do this instead CREATE TABLE party_account ( id varchar, account varchar, type varchar, name varchar, PRIMARY KEY ( id , account ) ); CREATE INDEX party_account_name ON party_account (name); CREATE INDEX party_account_type ON party_account (type); SELECT * FROM party_account WHERE name='Gary' AND type ='Loan' ALLOW FILTERING;
CREATE TABLE party_account ( id varchar, account varchar, type varchar, name varchar, PRIMARY KEY ( id , account ) ); CREATE TABLE party_account_by_name_type ( id varchar, account varchar, type varchar, name varchar, PRIMARY KEY ( (name , type), id ) );
Time Series
CREATE TABLE sensor_data ( sensor_id int, date varchar, time timeuuid, value int, PRIMARY KEY ( ( sensor_id, date ), time) ) WITH CLUSTERING ORDER BY (time DESC);
INSERT INTO sensor_data (sensor_id, date, time, value) VALUES (1, '20130908', now(), 432) USING TTL 604800;
SELECT time, value, TTL (value) FROM sensor_data WHERE sensor_id = 1 AND date = '20130908' AND time > maxTimeuuid('2014-11-08 10:05+0000') AND time < minTimeuuid('2014-11-08 15:00+0000');
time | value | ttl(value) -------------------------------------+-------+------------ db45f4c0-753c-11e4-94c9-2d63f07021c6 | 432 | 604257 db45f4c0-753c-11e4-94c9-2d63f07021c7 | 433 | 604452
Data Types
Performance Considerations
The best queries are in a single partition
i.e. WHERE partition key = <something> Queries that span multiple partitions
are s-l-o-wi.e. WHERE partition key IN ( <something> , <something> , ... ); Queries that span multiple cluster columns are fast
i.e. WHERE partition key = <something> and clustering key = <something> "Table scan" - slow!
(Limited to 10.000 rows by default)Use LIMIT keyword to choose fewer or more rows Collections - Often more efficient to denormalise further
Especially for larger data sets and
also favour sets over listUse lightweight transactions only where necessary
Great for 1% of your application
Tracing
cqlsh:primer> tracing on; select * from party_account where id ='11111' ; ... activity | timestamp | source | source_elapsed ---------------------------------------------------------------+--------------+-----------+---------------- execute_cql3_query | 05:30:05,777 | <IP_ADDRESS> | 0 Parsing select * from party_account where id ='11111'; | 05:30:05,777 | <IP_ADDRESS> | 199 Preparing statement | 05:30:05,777 | <IP_ADDRESS> | 518 Sending message to /<IP_ADDRESS> | 05:30:05,780 | <IP_ADDRESS> | 3113 ... Executing single-partition query on party_account | 05:30:05,799 | <IP_ADDRESS> | 17915 Enqueuing response to /<IP_ADDRESS> | 05:30:05,799 | <IP_ADDRESS> | 16772 Acquiring sstable references | 05:30:05,799 | <IP_ADDRESS> | 17940 Merging memtable tombstones | 05:30:05,799 | <IP_ADDRESS> | 17982 Skipped 0/0 non-slice-. sstables, included 0 due to tombstones | 05:30:05,799 | <IP_ADDRESS> | 18038 Merging data from memtables and 0 sstables | 05:30:05,799 | <IP_ADDRESS> | 18052 Read 3 live and 0 tombstoned cells | 05:30:05,799 | <IP_ADDRESS> | 18132 ... Message received from /<IP_ADDRESS> | 05:30:05,822 | <IP_ADDRESS> | 45282 Processing response from /<IP_ADDRESS> | 05:30:05,822 | <IP_ADDRESS> | 45338 Request complete | 05:30:05,822 | <IP_ADDRESS> | 45694
Summary
- CQL3 is similar to SQL
- Primary key is made up of partition key and clustering columns
- Partition key is required to find your data fast
- Column family provides modelling flexibility
- Use batches for atomicity
- De-normalize where necessary to satisfy queries
- Solve your reads with your writes
- TTL can be used to expire data
- Static columns and Lightweight Transactions are useful 2.x features
all challenges appear again...
Improve availability
Aim to be scalable
Adopt new ways of thinking
3 Facts
fact 1
Availability is easier
availability is easier, because
Masterless architecture
No outages in contrast to master-slave architecture
This does make C* chatty
availability is easier, because
Replication of data
Replication factor is configurable per keyspace
Increasing nodes does not mean higher availability
Increasing the replication factor does
fact 2
Performance is easier
performance is easier, and
Solve your reads
with your writes
De-normalization is acceptable for solving reads
performance is easier, but
Know your partitions
Large partitions will hurt!
performance is easier, because
Linear scalable
Adding nodes will increase your throughput through sharding
source: Datastax
fact 3
Consistency is harder
consistency is harder, and
Application developer has much more responsibility
Focus on the data model and the flow of data is key
noSQL versus SQL
consistency is harder, because
CAP Theorem
Consistency (do you get identical results, regardless which node is queried?)
Availability (can the cluster respond to very high write and read volumes?)
Partition tolerance (is the cluster still available when part of it goes dark?)
consistency is harder, because
Transactions and queuing are anti-patterns
C* v2.0 reduces the complexity by using lightweight transactions (paxos)
all facts appear...
Availability is easier | challenge 1: availability & consistency
Performance is easier | challenge 2 easier scalable
Consistency is harder | challenge * availability & consistency, easier scalable, new way of thinking
all challenges covered...
C*@ING
Confluence
3 Questions - Bonus
question 1
What risk do we have with
2 DC's and using Write/Read CL of LOCAL_QUORUM?
question 1
Split-brain
Who wins? Neither side knows the other side!
question 1
CAP theorem - choose wisely
Use QUORUM but risk availability
when there are issues with the WAN link
Arrange a third DC... €€€
Applications apply DC stickiness
whilst processing data which increases complexity
question 2
Does QUORUM read and QUORUM write guarantee consistency?
question 2
No - it gives strong consistency
NTP must be set-up correctly
Know your flow of data
Model as idem-potent-ly as possible
question 3
Will C* solve all your IT issues?
question 3
No - but it will help solve a lot of your problems
Performance and availability are tuneable based on needs and costs
Consistency is solved by design and knowing the flow of data
Going from SQL to noSQL is a paradigm shift
Skills are not readily available
Some issues are better solved by relational databases
Thank you
...graceful bow
Contact
<EMAIL_ADDRESS>@creedijk
<EMAIL_ADDRESS>@Gaz_GandA
this presentation is created using:
reveal.js


--- title: rdivide sidebar: function_reference_sidebar permalink: embedding.rdivide.html folder: function_reference toc: false ---
implements e ./ c and c ./ e
If e
is a matrix of embeddings and c
is a matrix of coefficients then e ./ c
is again a matrix of embeddings defined by
\[ [\mathrm{e ./ c}]_{j\ell} = mathrm{e}_{j\ell} / \mathrm{c}_{j \ell}\]
| e, e1, e2 | embedding |
| c | double |
| out | embedding |


{{ block title }}Results{{ endblock }} {{ block content }} {{ if player.id_in_group == 1 }}
You chose to send participant B {{ group.sent_amount }}. Participant B returned {{ group.sent_back_amount }}.
You were initially endowed with {{ C.ENDOWMENT }}, chose to send {{ group.sent_amount }}, received {{ group.sent_back_amount }} thus you now have: {{ C.ENDOWMENT }}-{{ group.sent_amount }}+{{ group.sent_back_amount }}={{ player.payoff }}
{{ else }}Participant A sent you {{ group.sent_amount }}. They were tripled so you received {{ tripled_amount }}. You chose to return {{ group.sent_back_amount }}.
You received {{ tripled_amount }}, chose to return {{ group.sent_back_amount }} thus you now have: ({{ tripled_amount }})-({{ group.sent_back_amount }})={{ player.payoff }}
. {{ endif }}{{ next_button }}
{{ include_sibling 'instructions.html' }} {{ endblock }}


“If you want to go fast, go alone. If you want to go far, go together.”
African proverb
Help us build Trustroots!
Nobody can do everything, but everyone can do something.
We are a group of hospitality exchange enthusiasts with backgrounds in some notable projects. The same people who also brought you Hitchwiki, Trashwiki, Nomadwiki & more.
All current board members are also members of the founding team. We will have non-founding members in the board at some point,
Working on big freegan/travel projects such as Hitchwiki, Hitchgathering festival, Trashwiki and Nomadwiki since 2008. In the past has volunteered for BeWelcome (2013). Active open source contributor and visionary free/gift-economics activist. A developer at Automattic.
Founded multiple popular and trusted websites such as Hitchwiki, Trashwiki, Nomadwiki, Couchwiki and Deletionpedia. Volunteered for CouchSurfing as a tech team coordinator in 2006 and 2007 and for BeWelcome since 2007. Loves paradoxes, makes money with moneyless.org.
Callum and Carlos were also part of the founding team.


Government Ministers to meet Midlands ESB workers as plants set to close
A number of Government Ministers will today meet and brief workers affected by the planned closure of ESB power stations at Lanesboro and Shannon Bridge.
The ESB said it submitted an application to An Bord Pleanála in 2018 seeking planning permission to transition West Offaly Power from peat to biomass over a number of years starting in 2020. However, the planning application was rejected by An Bord Pleanála in July of this year.
Up to 90 workers are believed to be affected by the planned closures.
Climate Action Minister Richard Bruton is travelling to the Midlands today along with Finance Minister Paschal Donohoe, Heritage Minister Josepha Madigan and Minister of State for the OPW, Kevin Boxer Moran.
The Government recently announced the creation of a €6m Just Transition Fund for the Midlands, and the ESB has announced that it will make an additional contribution of €5m to the fund.
Minister Bruton said the Government is determined to show solidarity and comittment to support communities during the transition away from peat.
"In the Budget we set aside significant funds, we have achieved support from the European Union PSO subsidy system to support bog rehabilitation, and we've appointed Kieran Mulvey as a just transition commissioner.
"We need to work on the changes we can put in place that will allow the Midlands make a transition from the brown past, if you like, to the green future."
"The Government is determined to show solidarity and a commitment to a just transition," he said.
"We want to sit down with workers and wider interests in the Midlands region to discuss how we're going to manage this and achieve a just transiton."


Here is my favorite collection from this week. Grit is a great book on how to discover your passion and improve your perseverance.
Great deal of information on how to discover your passion and achieving your goal. Discuss in detail different aspects of Grit
and how to become more Grittier
. Basic components of Grit
intorduced as
Listen, Think, Act
. I had an opportunity to listen to , Dr. Jamie Van Leeuwen, CEO of Global Livingston Institute. They have done amazing projects to improve lives of people in Uganda. Please check out what they have done and donate if possible.


Friday, Memphis Police arrested 18-year-old Kyoko Smith for the gruesome crime.

She also allegedly took the dog's heart and put it in the freezer.
“I really hate to hear that; why someone would do that to a dog? I have no idea. Just sad to hear, very sad to hear,” said neighbor Kevin Gause.
One neighbor on Millers Pond Circle, who didn’t want to be identified, told WMC a chilling story of finding Smith looking over their fence late one night, staring at their dog.
“I asked her, 'Hey, what are you doing?' She said, 'Oh, your dog is cold. Your dog is cold.' That's the only thing she'd say,” one neighbor said.
The neighbors said Lucy’s owners are good people. One person even said they were helping to take care of their granddaughter, who was having problems.
“They're good neighbors. They came over, helped me out with my yard. I help them. So they're very friendly neighbors,” said Gause.
According to a police affidavit, Smith admitted to one of the dog's owners that she killed the dog. And they received pictures of the dead animal from Smith's mother.
Smith is charged with intentionally killing an animal, a felony.
Neighbors say their thoughts are with the dog's owners.
Smith is currently out on bond. She is due in court on Monday.
Read the original version of this article at wmcactionnews5.com.