|
Max API
8.2.0
|
Data Structures | |
| struct | t_messlist |
| A list of symbols and their corresponding methods, complete with typechecking information. More... | |
| struct | t_tinyobject |
| The tiny object structure sits at the head of any object to which you may pass messages (and which you may feed to freeobject()). More... | |
| struct | t_object |
| The structure for the head of any object which wants to have inlets or outlets, or support attributes. More... | |
Macros | |
| #define | NOGOOD(x) |
| Returns true if a pointer is not a valid object. | |
| #define | object_method_direct(rt, sig, x, s, ...) |
| do a strongly typed direct call to a method of an object More... | |
Enumerations | |
| enum | |
| Magic number used to determine if memory pointed to by a t_object* is valid. | |
| enum | |
| Maximum number of arguments that can be passed as a typed-list rather than using A_GIMME. More... | |
Functions | |
| long | object_classname_compare (void *x, t_symbol *name) |
| Determines if a particular object is an instance of a given class. More... | |
| void * | object_alloc (t_class *c) |
| Allocates the memory for an instance of an object class and initialize its object header. More... | |
| void * | object_new (t_symbol *name_space, t_symbol *classname,...) |
| Allocates the memory for an instance of an object class and initialize its object header internal to Max. More... | |
| void * | object_new_typed (t_symbol *name_space, t_symbol *classname, long ac, t_atom *av) |
| Allocates the memory for an instance of an object class and initialize its object header internal to Max. More... | |
| t_max_err | object_free (void *x) |
| Call the free function and release the memory for an instance of an internal object class previously instantiated using object_new(), object_new_typed() or other new-style object constructor functions (e.g. More... | |
| void * | object_method (void *x, t_symbol *s,...) |
| Sends an untyped message to an object. More... | |
| t_max_err | object_method_typed (void *x, t_symbol *s, long ac, t_atom *av, t_atom *rv) |
| Sends a type-checked message to an object. More... | |
| t_max_err | object_method_typedfun (void *x, t_messlist *mp, t_symbol *s, long ac, t_atom *av, t_atom *rv) |
| Currently undocumented. More... | |
| method | object_getmethod (void *x, t_symbol *s) |
| Retrieves an object's method for a particular message selector. More... | |
| t_symbol * | object_classname (void *x) |
| Retrieves an object instance's class name. More... | |
| void * | object_register (t_symbol *name_space, t_symbol *s, void *x) |
| Registers an object in a namespace. More... | |
| void * | object_findregistered (t_symbol *name_space, t_symbol *s) |
| Determines a registered object's pointer, given its namespace and name. More... | |
| t_max_err | object_findregisteredbyptr (t_symbol **name_space, t_symbol **s, void *x) |
| Determines the namespace and/or name of a registered object, given the object's pointer. More... | |
| t_max_err | object_register_getnames (t_symbol *name_space, long *namecount, t_symbol ***names) |
| Returns all registered names in a namespace. More... | |
| void * | object_attach (t_symbol *name_space, t_symbol *s, void *x) |
| Attaches a client to a registered object. More... | |
| t_max_err | object_detach (t_symbol *name_space, t_symbol *s, void *x) |
| Detach a client from a registered object. More... | |
| t_max_err | object_attach_byptr (void *x, void *registeredobject) |
| Attaches a client to a registered object. More... | |
| t_max_err | object_attach_byptr_register (void *x, void *object_to_attach, t_symbol *reg_name_space) |
| A convenience function wrapping object_register() and object_attach_byptr(). More... | |
| t_max_err | object_detach_byptr (void *x, void *registeredobject) |
| Detach a client from a registered object. More... | |
| void * | object_subscribe (t_symbol *name_space, t_symbol *s, t_symbol *classname, void *x) |
| Subscribes a client to wait for an object to register. More... | |
| t_max_err | object_unsubscribe (t_symbol *name_space, t_symbol *s, t_symbol *classname, void *x) |
| Unsubscribe a client from a registered object, detaching if the object is registered. More... | |
| t_max_err | object_unregister (void *x) |
| Removes a registered object from a namespace. More... | |
| t_max_err | object_notify (void *x, t_symbol *s, void *data) |
| Broadcast a message (with an optional argument) from a registered object to any attached client objects. More... | |
| t_class * | object_class (void *x) |
| Determines the class of a given object. More... | |
| t_max_err | object_getvalueof (void *x, long *ac, t_atom **av) |
Retrieves the value of an object which supports the getvalueof/setvalueof interface. More... | |
| t_max_err | object_setvalueof (void *x, long ac, t_atom *av) |
Sets the value of an object which supports the getvalueof/setvalueof interface. More... | |
| t_max_err | object_obex_lookup (void *x, t_symbol *key, t_object **val) |
| Retrieves the value of a data stored in the obex. More... | |
| t_max_err | object_obex_store (void *x, t_symbol *key, t_object *val) |
| Stores data in the object's obex. More... | |
| void | object_obex_dumpout (void *x, t_symbol *s, long argc, t_atom *argv) |
| Sends data from the object's dumpout outlet. More... | |
| t_dictionary * | object_dictionaryarg (long ac, t_atom *av) |
| Retrieve a pointer to a dictionary passed in as an atom argument. More... | |
| void * | object_super_method (t_object *x, t_symbol *s,...) |
| Sends an untyped message to an object using superclass methods. More... | |
| void * | object_this_method (t_object *x, t_symbol *s,...) |
| Sends an untyped message to an object, respects a thread specific class stack from object_super_method() calls. More... | |
| t_max_err | object_attr_touch (t_object *x, t_symbol *attrname) |
| Mark an attribute as being touched by some code not from the attribute setter. More... | |
| t_max_err | object_attr_touch_parse (t_object *x, char *attrnames) |
| Mark one or more attributes as being touched by some code not from the attribute setter. More... | |
| t_max_err | object_method_parse (t_object *x, t_symbol *s, C74_CONST char *parsestr, t_atom *rv) |
| Convenience wrapper for object_method_typed() that uses atom_setparse() to define the arguments. More... | |
| t_max_err | object_method_format (t_object *x, t_symbol *s, t_atom *rv, C74_CONST char *fmt,...) |
| Convenience wrapper for object_method_typed() that uses atom_setformat() to define the arguments. More... | |
| t_max_err | object_method_char (t_object *x, t_symbol *s, unsigned char v, t_atom *rv) |
| Convenience wrapper for object_method_typed() that passes a single char as an argument. More... | |
| t_max_err | object_method_long (t_object *x, t_symbol *s, long v, t_atom *rv) |
| Convenience wrapper for object_method_typed() that passes a single long integer as an argument. More... | |
| t_max_err | object_method_float (t_object *x, t_symbol *s, float v, t_atom *rv) |
| Convenience wrapper for object_method_typed() that passes a single 32bit float as an argument. More... | |
| t_max_err | object_method_double (t_object *x, t_symbol *s, double v, t_atom *rv) |
| Convenience wrapper for object_method_typed() that passes a single 64bit float as an argument. More... | |
| t_max_err | object_method_sym (t_object *x, t_symbol *s, t_symbol *v, t_atom *rv) |
| Convenience wrapper for object_method_typed() that passes a single t_symbol* as an argument. More... | |
| t_max_err | object_method_obj (t_object *x, t_symbol *s, t_object *v, t_atom *rv) |
| Convenience wrapper for object_method_typed() that passes a single t_object* as an argument. More... | |
| t_max_err | object_method_char_array (t_object *x, t_symbol *s, long ac, unsigned char *av, t_atom *rv) |
| Convenience wrapper for object_method_typed() that passes an array of char values as an argument. More... | |
| t_max_err | object_method_long_array (t_object *x, t_symbol *s, long ac, t_atom_long *av, t_atom *rv) |
| Convenience wrapper for object_method_typed() that passes an array of long integers values as an argument. More... | |
| t_max_err | object_method_float_array (t_object *x, t_symbol *s, long ac, float *av, t_atom *rv) |
| Convenience wrapper for object_method_typed() that passes an array of 32bit floats values as an argument. More... | |
| t_max_err | object_method_double_array (t_object *x, t_symbol *s, long ac, double *av, t_atom *rv) |
| Convenience wrapper for object_method_typed() that passes an array of 64bit float values as an argument. More... | |
| t_max_err | object_method_sym_array (t_object *x, t_symbol *s, long ac, t_symbol **av, t_atom *rv) |
| Convenience wrapper for object_method_typed() that passes an array of t_symbol* values as an argument. More... | |
| t_max_err | object_method_obj_array (t_object *x, t_symbol *s, long ac, t_object **av, t_atom *rv) |
| Convenience wrapper for object_method_typed() that passes an array of t_object* values as an argument. More... | |
| void | object_openhelp (t_object *x) |
| Open the help patcher for a given instance of an object. More... | |
| void | object_openrefpage (t_object *x) |
| Open the reference page for a given instance of an object. More... | |
| void | object_openquery (t_object *x) |
| Open a search in the file browser for files with the name of the given object. More... | |
| void | classname_openhelp (char *classname) |
| Open the help patcher for a given object class name. More... | |
| void | classname_openrefpage (char *classname) |
| Open the reference page for a given object class name. More... | |
| void | classname_openquery (char *classname) |
| Open a search in the file browser for files with the name of the given class. More... | |
| t_object * | newobject_sprintf (t_object *patcher, C74_CONST char *fmt,...) |
| Create a new object in a specified patcher with values using a combination of attribute and sprintf syntax. More... | |
| t_object * | newobject_fromboxtext (t_object *patcher, const char *text) |
| Create an object from the passed in text. More... | |
| t_object * | newobject_fromdictionary (t_object *patcher, t_dictionary *d) |
| Place a new object into a patcher. More... | |
| #define object_method_direct | ( | rt, | |
| sig, | |||
| x, | |||
| s, | |||
| ... | |||
| ) |
do a strongly typed direct call to a method of an object
| rt | The type of the return value (double, void*, void...) |
| sig | the actual signature of the function in brackets ! something like (t_object *, double, long) |
| x | The object where the method we want to call will be looked for, it will also always be the first argument to the function call |
| s | The message selector |
| ... | Any arguments to the call, the first one will always be the object (x) |
getcolorat
on the object pwindow
which is declared like: t_jrgba pwindow_getcolorat(t_object *window, double x, double y) | anonymous enum |
| void classname_openhelp | ( | char * | classname | ) |
Open the help patcher for a given object class name.
| classname | The class name for which to open the help patcher. |
| void classname_openquery | ( | char * | classname | ) |
Open a search in the file browser for files with the name of the given class.
| classname | The class name for which to query. |
| void classname_openrefpage | ( | char * | classname | ) |
Open the reference page for a given object class name.
| classname | The class name for which to open the reference page. |
Create an object from the passed in text.
The passed in text is in the same format as would be typed into an object box. It can be used for UI objects or text objects so this is the simplest way to create objects from C.
| patcher | An instance of a patcher object. |
| text | The text as if typed into an object box. |
| t_object* newobject_fromdictionary | ( | t_object * | patcher, |
| t_dictionary * | d | ||
| ) |
Place a new object into a patcher.
The new object will be created based on a specification contained in a Dictionary.
Create a new dictionary populated with values using a combination of attribute and sprintf syntax.
| patcher | An instance of a patcher object. |
| d | A dictionary containing an object specification. |
Create a new object in a specified patcher with values using a combination of attribute and sprintf syntax.
| patcher | An instance of a patcher object. |
| fmt | An sprintf-style format string specifying key-value pairs with attribute nomenclature. |
| ... | One or more arguments which are to be substituted into the format string. |
| void* object_alloc | ( | t_class * | c | ) |
Allocates the memory for an instance of an object class and initialize its object header.
It is used like the traditional function newobject, inside of an object's new
method, but its use is required with obex-class objects.
| c | The class pointer, returned by class_new() |
Attaches a client to a registered object.
Once attached, the object will receive notifications sent from the registered object (via the object_notify() function), if it has a notify
method defined and implemented.
| name_space | The namespace of the registered object. This should be the same value used in object_register() to register the object. If you don't know the registered object's namespace, the object_findregisteredbyptr() function can be used to determine it. |
| s | The name of the registered object in the namespace. If you don't know the name of the registered object, the object_findregisteredbyptr() function can be used to determine it. |
| x | The client object to attach. Generally, this is the pointer to your Max object. |
name_space
and s
arguments) if successful, or NULL if unsuccessful.Referenced by jit_object_attach().
| t_max_err object_attach_byptr | ( | void * | x, |
| void * | registeredobject | ||
| ) |
Attaches a client to a registered object.
Unlike object_attach(), the client is specified by providing a pointer to that object rather than the registered name of that object.
Once attached, the object will receive notifications sent from the registered object (via the object_notify() function), if it has a notify
method defined and implemented.
| x | The attaching client object. Generally, this is the pointer to your Max object. |
| registeredobject | A pointer to the registered object to which you wish to attach. |
| t_max_err object_attach_byptr_register | ( | void * | x, |
| void * | object_to_attach, | ||
| t_symbol * | reg_name_space | ||
| ) |
A convenience function wrapping object_register() and object_attach_byptr().
| x | The attaching client object. Generally, this is the pointer to your Max object. |
| object_to_attach | A pointer to the object to which you wish to registered and then to which to attach. |
| reg_name_space | The namespace in which to register the object_to_attach. |
Mark an attribute as being touched by some code not from the attribute setter.
This will notify clients that the attribute has changed.
| x | The object whose attribute has been changed |
| attrname | The attribute name |
Mark one or more attributes as being touched by some code not from the attribute setter.
This will notify clients that the attributes have changed. Utility to call object_attr_touch() for several attributes
| x | The object whose attribute has been changed |
| attrnames | The attribute names as a space separated string |
| t_class* object_class | ( | void * | x | ) |
Determines the class of a given object.
| x | The object to test |
Referenced by jit_object_class(), and max_jit_obex_new().
| t_symbol* object_classname | ( | void * | x | ) |
Retrieves an object instance's class name.
| x | The object instance whose class name is being queried |
Referenced by jit_object_classname().
| long object_classname_compare | ( | void * | x, |
| t_symbol * | name | ||
| ) |
Determines if a particular object is an instance of a given class.
| x | The object to test |
| name | The name of the class to test this object against |
Detach a client from a registered object.
| name_space | The namespace of the registered object. This should be the same value used in object_register() to register the object. If you don't know the registered object's namespace, the object_findregisteredbyptr() function can be used to determine it. |
| s | The name of the registered object in the namespace. If you don't know the name of the registered object, the object_findregisteredbyptr() function can be used to determine it. |
| x | The client object to attach. Generally, this is the pointer to your Max object. |
Referenced by jit_object_detach().
| t_max_err object_detach_byptr | ( | void * | x, |
| void * | registeredobject | ||
| ) |
Detach a client from a registered object.
| x | The attaching client object. Generally, this is the pointer to your Max object. |
| registeredobject | The object from which to detach. |
| t_dictionary* object_dictionaryarg | ( | long | ac, |
| t_atom * | av | ||
| ) |
Retrieve a pointer to a dictionary passed in as an atom argument.
Use this function when working with classes that have dictionary constructors to fetch the dictionary.
| ac | The number of atoms. |
| av | A pointer to the first atom in the array. |
Determines a registered object's pointer, given its namespace and name.
| name_space | The namespace of the registered object |
| s | The name of the registered object in the namespace |
Referenced by jit_object_findregistered().
Determines the namespace and/or name of a registered object, given the object's pointer.
| name_space | Pointer to a t_symbol *, to receive the namespace of the registered object |
| s | Pointer to a t_symbol *, to receive the name of the registered object within the namespace |
| x | Pointer to the registered object |
Referenced by jit_object_findregisteredbyptr().
| t_max_err object_free | ( | void * | x | ) |
Call the free function and release the memory for an instance of an internal object class previously instantiated using object_new(), object_new_typed() or other new-style object constructor functions (e.g.
hashtab_new()). It is, at the time of this writing, a wrapper for the traditional function freeobject(), but its use is suggested with obex-class objects.
| x | The pointer to the object to be freed. |
Referenced by jit_object_free().
Retrieves an object's method for a particular message selector.
| x | The object whose method is being queried |
| s | The message selector |
Referenced by jit_object_getmethod().
Retrieves the value of an object which supports the getvalueof/setvalueof
interface.
See part 2 of the pattr SDK for more information on this interface.
| x | The object whose value is of interest |
| ac | Pointer to a long variable to receive the count of arguments in av . The long variable itself should be set to 0 previous to calling this function. |
| av | Pointer to a t_atom *, to receive object data. The t_atom * itself should be set to NULL previous to calling this function. |
getvalueof
, like so: getvalueof
method should be prototyped as: Referenced by max_jit_obex_gimmeback_dumpout().
| void* object_method | ( | void * | x, |
| t_symbol * | s, | ||
| ... | |||
| ) |
Sends an untyped message to an object.
There are some caveats to its use, however, particularly for 64-bit architectures. object_method_direct() should be used in cases where floating-point or other non-integer types are being passed on the stack or in return values.
| x | The object that will receive the message |
| s | The message selector |
| ... | Any arguments to the message |
bang
to the object bang_me
: Referenced by jit_attr_symcompare().
Convenience wrapper for object_method_typed() that passes a single char as an argument.
| x | The object to which the message will be sent. |
| s | The name of the method to call on the object. |
| v | An argument to pass to the method. |
| rv | The address of an atom to hold a return value. |
| t_max_err object_method_char_array | ( | t_object * | x, |
| t_symbol * | s, | ||
| long | ac, | ||
| unsigned char * | av, | ||
| t_atom * | rv | ||
| ) |
Convenience wrapper for object_method_typed() that passes an array of char values as an argument.
| x | The object to which the message will be sent. |
| s | The name of the method to call on the object. |
| ac | The number of arguments to pass to the method. |
| av | The address of the first of the array of arguments to pass to the method. |
| rv | The address of an atom to hold a return value. |
Convenience wrapper for object_method_typed() that passes a single 64bit float as an argument.
| x | The object to which the message will be sent. |
| s | The name of the method to call on the object. |
| v | An argument to pass to the method. |
| rv | The address of an atom to hold a return value. |
| t_max_err object_method_double_array | ( | t_object * | x, |
| t_symbol * | s, | ||
| long | ac, | ||
| double * | av, | ||
| t_atom * | rv | ||
| ) |
Convenience wrapper for object_method_typed() that passes an array of 64bit float values as an argument.
| x | The object to which the message will be sent. |
| s | The name of the method to call on the object. |
| ac | The number of arguments to pass to the method. |
| av | The address of the first of the array of arguments to pass to the method. |
| rv | The address of an atom to hold a return value. |
Convenience wrapper for object_method_typed() that passes a single 32bit float as an argument.
| x | The object to which the message will be sent. |
| s | The name of the method to call on the object. |
| v | An argument to pass to the method. |
| rv | The address of an atom to hold a return value. |
| t_max_err object_method_float_array | ( | t_object * | x, |
| t_symbol * | s, | ||
| long | ac, | ||
| float * | av, | ||
| t_atom * | rv | ||
| ) |
Convenience wrapper for object_method_typed() that passes an array of 32bit floats values as an argument.
| x | The object to which the message will be sent. |
| s | The name of the method to call on the object. |
| ac | The number of arguments to pass to the method. |
| av | The address of the first of the array of arguments to pass to the method. |
| rv | The address of an atom to hold a return value. |
| t_max_err object_method_format | ( | t_object * | x, |
| t_symbol * | s, | ||
| t_atom * | rv, | ||
| C74_CONST char * | fmt, | ||
| ... | |||
| ) |
Convenience wrapper for object_method_typed() that uses atom_setformat() to define the arguments.
| x | The object to which the message will be sent. |
| s | The name of the method to call on the object. |
| rv | The address of an atom to hold a return value. |
| fmt | An sprintf-style format string specifying values for the atoms. |
| ... | One or more arguments which are to be substituted into the format string. |
Convenience wrapper for object_method_typed() that passes a single long integer as an argument.
| x | The object to which the message will be sent. |
| s | The name of the method to call on the object. |
| v | An argument to pass to the method. |
| rv | The address of an atom to hold a return value. |
| t_max_err object_method_long_array | ( | t_object * | x, |
| t_symbol * | s, | ||
| long | ac, | ||
| t_atom_long * | av, | ||
| t_atom * | rv | ||
| ) |
Convenience wrapper for object_method_typed() that passes an array of long integers values as an argument.
| x | The object to which the message will be sent. |
| s | The name of the method to call on the object. |
| ac | The number of arguments to pass to the method. |
| av | The address of the first of the array of arguments to pass to the method. |
| rv | The address of an atom to hold a return value. |
Convenience wrapper for object_method_typed() that passes a single t_object* as an argument.
| x | The object to which the message will be sent. |
| s | The name of the method to call on the object. |
| v | An argument to pass to the method. |
| rv | The address of an atom to hold a return value. |
| t_max_err object_method_obj_array | ( | t_object * | x, |
| t_symbol * | s, | ||
| long | ac, | ||
| t_object ** | av, | ||
| t_atom * | rv | ||
| ) |
Convenience wrapper for object_method_typed() that passes an array of t_object* values as an argument.
| x | The object to which the message will be sent. |
| s | The name of the method to call on the object. |
| ac | The number of arguments to pass to the method. |
| av | The address of the first of the array of arguments to pass to the method. |
| rv | The address of an atom to hold a return value. |
| t_max_err object_method_parse | ( | t_object * | x, |
| t_symbol * | s, | ||
| C74_CONST char * | parsestr, | ||
| t_atom * | rv | ||
| ) |
Convenience wrapper for object_method_typed() that uses atom_setparse() to define the arguments.
| x | The object to which the message will be sent. |
| s | The name of the method to call on the object. |
| parsestr | A C-string to parse into an array of atoms to pass to the method. |
| rv | The address of an atom to hold a return value. |
Convenience wrapper for object_method_typed() that passes a single t_symbol* as an argument.
| x | The object to which the message will be sent. |
| s | The name of the method to call on the object. |
| v | An argument to pass to the method. |
| rv | The address of an atom to hold a return value. |
| t_max_err object_method_sym_array | ( | t_object * | x, |
| t_symbol * | s, | ||
| long | ac, | ||
| t_symbol ** | av, | ||
| t_atom * | rv | ||
| ) |
Convenience wrapper for object_method_typed() that passes an array of t_symbol* values as an argument.
| x | The object to which the message will be sent. |
| s | The name of the method to call on the object. |
| ac | The number of arguments to pass to the method. |
| av | The address of the first of the array of arguments to pass to the method. |
| rv | The address of an atom to hold a return value. |
Sends a type-checked message to an object.
| x | The object that will receive the message |
| s | The message selector |
| ac | Count of message arguments in av |
| av | Array of t_atoms; the message arguments |
| rv | Return value of function, if available |
rv
. Otherwise, rv
will contain an A_NOTHING atom. Referenced by jit_object_method_typed(), max_jit_attr_args(), max_jit_obex_gimmeback(), and max_jit_obex_gimmeback_dumpout().
| t_max_err object_method_typedfun | ( | void * | x, |
| t_messlist * | mp, | ||
| t_symbol * | s, | ||
| long | ac, | ||
| t_atom * | av, | ||
| t_atom * | rv | ||
| ) |
Currently undocumented.
| x | The object that will receive the message |
| mp | Undocumented |
| s | The message selector |
| ac | Count of message arguments in av |
| av | Array of t_atoms; the message arguments |
| rv | Return value of function, if available |
rv
. Otherwise, rv
will contain an A_NOTHING atom. Allocates the memory for an instance of an object class and initialize its object header internal to Max.
It is used similarly to the traditional function newinstance(), but its use is required with obex-class objects.
| name_space | The desired object's name space. Typically, either the constant CLASS_BOX, for obex classes which can instantiate inside of a Max patcher (e.g. boxes, UI objects, etc.), or the constant CLASS_NOBOX, for classes which will only be used internally. Developers can define their own name spaces as well, but this functionality is currently undocumented. |
| classname | The name of the class of the object to be created |
| ... | Any arguments expected by the object class being instantiated |
Allocates the memory for an instance of an object class and initialize its object header internal to Max.
It is used similarly to the traditional function newinstance(), but its use is required with obex-class objects. The object_new_typed() function differs from object_new() by its use of an atom list for object arguments—in this way, it more resembles the effect of typing something into an object box from the Max interface.
| name_space | The desired object's name space. Typically, either the constant CLASS_BOX, for obex classes which can instantiate inside of a Max patcher (e.g. boxes, UI objects, etc.), or the constant CLASS_NOBOX, for classes which will only be used internally. Developers can define their own name spaces as well, but this functionality is currently undocumented. |
| classname | The name of the class of the object to be created |
| ac | Count of arguments in av |
| av | Array of t_atoms; arguments to the class's instance creation function. |
Broadcast a message (with an optional argument) from a registered object to any attached client objects.
| x | Pointer to the registered object |
| s | The message to send |
| data | An optional argument which will be passed with the message. Sets this argument to NULL if it will be unused. |
notify
, like so: notify
method should be prototyped as: x
is the pointer to the receiving object, s
is the name of the sending (registered) object in its namespace, msg
is the sent message, sender
is the pointer to the sending object, and data
is an optional argument sent with the message. This value corresponds to the data argument in the object_notify() method. Referenced by jit_object_notify(), max_jit_attr_set(), and max_jit_obex_attr_set().
Sends data from the object's dumpout outlet.
The dumpout outlet is stored in the obex using the object_obex_store() function (see above). It is used approximately like outlet_anything().
| x | The object pointer. This function should only be called on instantiated objects (i.e. in the new method or later), not directly on classes (i.e. in main() ). |
| s | The message selector t_symbol * |
| argc | Number of elements in the argument list in argv |
| argv | t_atoms constituting the message arguments |
Referenced by ext_main().
Retrieves the value of a data stored in the obex.
| x | The object pointer. This function should only be called on instantiated objects (i.e. in the new method or later), not directly on classes (i.e. in main() ). |
| key | The symbolic name for the data to be retrieved |
| val | A pointer to a t_object *, to be filled with the data retrieved from the obex. |
Stores data in the object's obex.
| x | The object pointer. This function should only be called on instantiated objects (i.e. in the new method or later), not directly on classes (i.e. in main() ). |
| key | A symbolic name for the data to be stored |
| val | A t_object *, to be stored in the obex, referenced under the key . |
new
method: | void object_openhelp | ( | t_object * | x | ) |
Open the help patcher for a given instance of an object.
| x | The object instance for which to open the help patcher. |
| void object_openquery | ( | t_object * | x | ) |
Open a search in the file browser for files with the name of the given object.
| x | The object instance for which to query. |
| void object_openrefpage | ( | t_object * | x | ) |
Open the reference page for a given instance of an object.
| x | The object instance for which to open the reference page. |
Registers an object in a namespace.
| name_space | The namespace in which to register the object. The namespace can be any symbol. If the namespace does not already exist, it is created automatically. |
| s | The name of the object in the namespace. This name will be used by other objects to attach and detach from the registered object. |
| x | The object to register |
Referenced by jit_object_register().
Returns all registered names in a namespace.
| name_space | Pointer to a t_symbol, the namespace to lookup names in |
| namecount | Pointer to a long, to receive the count of the registered names within the namespace |
| names | Pointer to a t_symbol **, to receive the allocated names. This pointer should be freed after use |
MAX_ERR_NONE
if successful, or one of the other error codes defined in "ext_obex.h" if unsuccessful. Sets the value of an object which supports the getvalueof/setvalueof
interface.
| x | The object whose value is of interest |
| ac | The count of arguments in av |
| av | Array of t_atoms; the new desired data for the object |
setvalueof
, like so: setvalueof
method should be prototyped as: Subscribes a client to wait for an object to register.
Upon registration, the object will attach. Once attached, the object will receive notifications sent from the registered object (via the object_notify
function), if it has a notify
method defined and implemented. See below for more information, in the reference for object_notify
.
| name_space | The namespace of the registered object. This should be the same value used in object_register to register the object. If you don't know the registered object's namespace, the object_findregisteredbyptr function can be used to determine it. |
| s | The name of the registered object in the namespace. If you don't know the name of the registered object, the object_findregisteredbyptr function can be used to determine it. |
| classname | The classname of the registered object in the namespace to use as a filter. If NULL, then it will attach to any class of object. |
| x | The client object to attach. Generally, this is the pointer to your Max object. |
name_space
and s
arguments) if successful, or NULL if the object is not yet registered. Sends an untyped message to an object using superclass methods.
Uses a thread specific stack to ensure traversal up the class hierarchy.
| x | The object that will receive the message |
| s | The message selector |
| ... | Any arguments to the message |
Sends an untyped message to an object, respects a thread specific class stack from object_super_method() calls.
| x | The object that will receive the message |
| s | The message selector |
| ... | Any arguments to the message |
| t_max_err object_unregister | ( | void * | x | ) |
Removes a registered object from a namespace.
| x | The object to unregister. This should be the pointer returned from the object_register() function. |
Referenced by jit_object_unregister().
| t_max_err object_unsubscribe | ( | t_symbol * | name_space, |
| t_symbol * | s, | ||
| t_symbol * | classname, | ||
| void * | x | ||
| ) |
Unsubscribe a client from a registered object, detaching if the object is registered.
| name_space | The namespace of the registered object. This should be the same value used in object_register to register the object. If you don't know the registered object's namespace, the object_findregisteredbyptr function can be used to determine it. |
| s | The name of the registered object in the namespace. If you don't know the name of the registered object, the object_findregisteredbyptr function can be used to determine it. |
| classname | The classname of the registered object in the namespace to use as a filter. Currently unused for unsubscribe. |
| x | The client object to detach. Generally, this is the pointer to your Max object. |
MAX_ERR_NONE
if successful, or one of the other error codes defined in "ext_obex.h" if unsuccessful.


All form components have an invalid state style to display the validation errors when ng-invalid ng-dirty combination is applied by Angular.


new Group(options)
The SPE.Group class. Creates a new group, containing a material, geometry, and mesh.
Parameters:
| Name | Type | Description |
|---|---|---|
options |
GroupOptions | A map of options to configure the group instance. |
- Source:
Methods
addEmitter(emitter)
Adds an SPE.Emitter instance to this group, creating particle values and
assigning them to this group's shader attributes.
Parameters:
| Name | Type | Description |
|---|---|---|
emitter |
Emitter | The emitter to add to this group. |
- Source:
addPool(numEmitters, emitterOptions, createNew) → {Group}
Add a pool of emitters to this particle group
Parameters:
| Name | Type | Description |
|---|---|---|
numEmitters |
Number | The number of emitters to add to the pool. |
emitterOptions |
EmitterOptions | Array | An object, or array of objects, describing the options to pass to each emitter. |
createNew |
Boolean | Should a new emitter be created if the pool runs out? |
- Source:
Returns:
This group instance.
- Type
- Group
dispose() → {Group}
Dipose the geometry and material for the group.
- Source:
Returns:
Group instance.
- Type
- Group
getFromPool() → {Emitter|null}
Fetch a single emitter instance from the pool.
If there are no objects in the pool, a new emitter will be
created if specified.
- Source:
Returns:
- Type
- Emitter | null
getPool() → {Array}
Get the pool array
- Source:
Returns:
- Type
- Array
releaseIntoPool(emitter) → {Group}
Release an emitter into the pool.
Parameters:
| Name | Type | Description |
|---|---|---|
emitter |
ShaderParticleEmitter |
- Source:
Returns:
This group instance.
- Type
- Group
removeEmitter(emitter)
Removes an SPE.Emitter instance from this group. When called,
all particle's belonging to the given emitter will be instantly
removed from the scene.
Parameters:
| Name | Type | Description |
|---|---|---|
emitter |
Emitter | The emitter to add to this group. |
- Source:
tick(dtopt)
Simulate all the emitter's belonging to this group, updating
attribute values along the way.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
dt |
Number |
<optional> |
Group's `fixedTimeStep` value | The number of seconds to simulate the group's emitters for (deltaTime) |
- Source:
triggerPoolEmitter(numEmitters, positionopt) → {Group}
Set a given number of emitters as alive, with an optional position
vector3 to move them to.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
numEmitters |
Number | The number of emitters to activate | |
position |
Object |
<optional> |
A THREE.Vector3 instance describing the position to activate the emitter(s) at. |
- Source:
Returns:
This group instance.
- Type
- Group


Reģistrē savu biznesu pie mums. but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.


Router
This class organizes Slim application route objects. It is responsible
for registering route objects, assigning names to route objects,
finding routes that match the current HTTP request, and creating
URLs for a named route.
Methods summary
public
|
#
__construct( FastRoute\RouteParser $parser = null )
Create new router
Parameters
|
public
Slim\Router
|
#
setBasePath( string $basePath )
Set the base path used in pathFor()
Set the base path used in pathFor()
Parameters
Returns
|
public
Slim\Router
|
#
setCacheFile( string|false $cacheFile )
Set path to fast route cache file. If this is false then route caching is disabled.
Set path to fast route cache file. If this is false then route caching is disabled.
Parameters
Returns
|
public
|
#
setContainer( Interop\Container\ContainerInterface $container )
|
public
Slim\Interfaces\RouteInterface
|
#
map( string[] $methods, string $pattern, callable $handler )
Add route
Parameters
- $methods
- Array of HTTP methods
- $pattern
- The route pattern
- $handler
- The route callable
Returns
Throws
InvalidArgumentException if the route pattern isn't a string
Implementation of
|
public
array
|
#
dispatch( Psr\Http\Message\ServerRequestInterface $request )
Dispatch router for HTTP request
Dispatch router for HTTP request
Parameters
- $request
- The current HTTP request object
Returns
array
Link
Implementation of
|
protected
Slim\Interfaces\RouteInterface
|
#
createRoute( string[] $methods, string $pattern, callable $callable )
Create a new Route object
Create a new Route object
Parameters
- $methods
- Array of HTTP methods
- $pattern
- The route pattern
- $callable
- $handler The route callable
Returns
|
protected
FastRoute\Dispatcher
|
|
public
|
|
public
Slim\Route[]
|
|
public
Slim\Route
|
#
getNamedRoute( string $name )
Get named route object
Parameters
Returns
Throws
RuntimeException If named route does not exist
Implementation of
|
public
|
#
removeNamedRoute( string $name )
Remove named route
Parameters
Throws
RuntimeException If named route does not exist
|
protected
string
|
#
processGroups( )
Process route groups
Returns
string A group pattern to prefix routes with
|
public
Slim\Interfaces\RouteGroupInterface
|
#
pushGroup( string $pattern, callable $callable )
Add a route group to the array
Add a route group to the array
Parameters
Returns
Implementation of
|
public
Slim\RouteGroup |boolean
|
#
popGroup( )
Removes the last route group from the array
Removes the last route group from the array
Returns
Implementation of
|
public
Slim\Interfaces\RouteInterface
|
#
lookupRoute( $identifier )
Parameters
Returns
Implementation of
|
public
string
|
#
relativePathFor( string $name, array $data = [], array $queryParams = [] )
Build the path for a named route excluding the base path
Build the path for a named route excluding the base path
Parameters
- $name
- Route name
- $data
- Named argument replacement data
- $queryParams
- Optional query string parameters
Returns
string
Throws
RuntimeException If named route does not exist
InvalidArgumentException If required data not provided
Implementation of
|
public
string
|
#
pathFor( string $name, array $data = [], array $queryParams = [] )
Build the path for a named route including the base path
Build the path for a named route including the base path
Parameters
- $name
- Route name
- $data
- Named argument replacement data
- $queryParams
- Optional query string parameters
Returns
string
Throws
RuntimeException If named route does not exist
InvalidArgumentException If required data not provided
Implementation of
|
public
string
|
#
urlFor( string $name, array $data = [], array $queryParams = [] )
Build the path for a named route.
Build the path for a named route.
This method is deprecated. Use pathFor() from now on.
Parameters
- $name
- Route name
- $data
- Named argument replacement data
- $queryParams
- Optional query string parameters
Returns
string
Throws
RuntimeException If named route does not exist
InvalidArgumentException If required data not provided
|
Properties summary
protected
Interop\Container\ContainerInterface
|
$container
|
|
protected
FastRoute\RouteParser
|
$routeParser
|
|
protected
string
|
$basePath
Base path used in pathFor()
Base path used in pathFor()
|
|
protected
string|False
|
$cacheFile
Path to fast route cache file. Set to false to disable route caching
Path to fast route cache file. Set to false to disable route caching
|
|
protected
Slim\Route[]
|
$routes
|
|
protected
integer
|
$routeCounter
Route counter incrementer
Route counter incrementer
|
|
protected
Slim\RouteGroup[]
|
$routeGroups
|
|
protected
FastRoute\Dispatcher
|
$dispatcher
|
|


abstract class Subnet::Prefix
- Subnet::Prefix
- Reference
- Object
Overview
The base class for Prefix32
and Prefix128
defining some
common methods that exist in both.
Included Modules
- Comparable(Int32 | Int64 | Subnet::Prefix | UInt32 | UInt64 | UInt8)
Direct Known Subclasses
Defined in:
subnet/prefix.crConstructors
Instance Method Summary
-
#+(other)
Add this Prefix to another.
-
#-(other)
Subtract another Prefix from this one.
-
#<=>(other)
Compare this Prefix to another.
- #prefix : Int32
- #prefix=(prefix : Int32)
-
#to_i : Int32
Return this Prefix as an integer.
-
#to_s(io)
Convert the Prefix to a string.


Created by Francois Laberge / @francoislaberge
Frames Per Second (Not First Person Shooters, but yes that too)
Pixel Persistence
Virtual Reality. The most prominent examples being Video-Games/Simulations. The term VR connotates more to mean experiences using a VR headset, versus games and gaming.

Generally AR experiences are accomplished via special glasses or pass through video.
Back to that.
At PAX Prime 2012 an early prototype was shown and it already started to draw attention. (Sample news coverage)
In 2012, Oculus started a kickstarter to raise $250K to build DIY starter kits for other VR enthusiasts. They ended up with $2.4M at close.
First demoed at CES 2014, Oculus introduced a new much improved version of the Oculus Rift.
With a newly added external camera the ability to track accurate head translation as well as orientation was enabled.
The crystal cove prototype became the basis for the second publicly sold version of the product. It is still marketed to developers to build games ahead of the future release of a consumer version.
Announced/demoed at GDC 2014.
At Steam Dev Days 2014 in January Valve showed off a VR prototype that tracked your body's physical movement using. Many a marker, with very good specs.
Google cardboard is a DIY phone holder you can make from cardboard.
A cheap solution for a prototyping VR enthusiast. It's about $20 for the parts.
Pause for a quick demo. Website
Hardware that uses line of site will always suffer from occlusion. Try turning your hands so that your hand blocks the device from seeing most of your fingers.
TODO: Add more details on time coherent solutions and such.
With your eyes covered standard controllers become much harder to use for non hardcore games as they can't peak at button labels
To be covered.
Advanced game audio engines already model your head to emulates sound wave propagation. This includes head oclusion, ear direction, echo, doppler effect, the geometry of the environment, and more.
 Hear better by leaning out of a door to checkout a commotion in a hallway.
Imagine leaning in to better hear a buzzing bee on a flower. Flies will now be just as annoying as in real life as they fly into your ear.
github.com/francoislaberge/the-state-of-vr (0.0.1)
DK2 arrives July, 2014 (Order here, $50 now, $300 later )


Welcome to CryptoPay’s documentation!¶
CryptoPay is a pretty simple library for donations and payments written in Python 3.7. It helps you to receive donations and payments the fastest way.
Installing¶
pip install cryptopay
Quickstart¶
from cryptopay import Application
def on_success_payment(user_id, item_id):
add_item_to_user(user_id, item_id)
app = Application('APP_TOKEN', callback=on_success_payment)
app.create_payment(symbol='eth test', data={'user_id': 42, 'target_amount': 0.12, 'item_id': 123})
Payment types¶
There are system variables: donated
, fixed_amount
. Please do not pass them to your data, all these variables will be reassigned.
Use following data keywords:
target_amount
if you want to bill user with fixed amount. Callback will be called after the user has paid the full amount.
def some_good_payment(good_id, user_id):
pass
app.create_payment(symbol='eth test', data={'good_id': 1, 'user_id': 2, 'target_amount': 0.1})
Any other data you want. Just pass it to callback. For example:
def callback(arg1, arg2, something_else):
pass
data = {'arg1': 'some', 'arg2': 'think', 'something_else': 'you want'}
app.create_payment(symbol='eth test', data=data)
Low level¶
get_currencies()
get_payment()
get_all_payments()
create_payment()
update_payment_data()
-
class
cryptopay.cryptopay.
Application
(token, callback=None, loop=None)[source]¶ Bases:
object
-
create_payment
(symbol, data=None)[source]¶ Creating new payment async :param symbol: one of supported symbols :param data: data to be stored with payment object, dict or None :return:
-
async
create_payment_async
(symbol, data=None)[source]¶ Creating new payment async :param symbol: one of supported symbols :param data: data to be stored with payment object, dict or None :return:
-
async
get_currencies_async
()[source]¶ Returns list of currencies available for your application type in async mode
-
async
get_payment_async
(payment_id: str)[source]¶ - Parameters
payment_id – payment identifier
- Returns
Payment
-


Welcome to the API Elements extension for Visual Studio Code! This is a totally untested extension which will improve your experience working with API description formats like API Blueprint and Swagger. It provides some great features, such as:
API Elements is the structure for parse results of both API Blueprint and Swagger, and it is built on the Refract format. It provides a single format for interacting with parse results from various API description formats. So far, only API Blueprint and Swagger are supported.
Warning: This package is alpha and probably might be buggy, but I decided to share the progress for those who are interested. Proceed at your own risk!
aglio
(this requires investigation as itâ€™s able to work just with API Blueprint)+ Request [
I want to see Http verbs, or in payloads I want to recall MSON structures)Please file an issue at https://github.com/XVincentX/vscode-apielements.
First install:
* Node.js (newer than 4.3.1)
* Npm (newer 2.14.12) - probably 3.x would be even better
This extension is built on top of Visual Studio template; so:
To run and develop do the following:
For both server
and client
directory (in the exact order):
Run npm i
code .
) and run the build
taskcode .
) and run the launch
taskNote: If youâ€™re on a Unix envirnonment, you might want to use open.sh
file which
will open both client and server instances at the same time.
Symbol navigation is strongly dependant on sourcemaps quality provided by the parser.
Currently, the following resources are indexed:
The idea would be, of course, to improve symbol navigation as much as possible and exploit
sourcemaps in all their power. This, however, might take time. If you feel there are some
important symbols Iâ€™m missing, please file an issue, Iâ€™ll be happy to evaluate it.
This extension is able to provide basic Apiary integration. Fundamentally, the entire
Apiary client has been reimplemented
following the Apiary API documentation. It means that
you can perform the following actions:
without having to leave the editor at all.
Most of the process is actually automated. Thous, it will ask you to provide a
token and redirect you to the right page if itâ€™s not avaliable on your computer.
All those commands are listed with an Apiary
prefix. Therefore, to see what you
can do, simply type Apiary
in the command box to see whatâ€™s going on.
Even if I currently work for Apiary, this extension is my personal work and itâ€™s not backed by Apiary.


This function takes in a dataframe object and one categorical feature, to produce a histogram plot that visualizes the distribution of the feature. User can also choose to plot density graph of the feature by specifying in plot_type. The function also offers customization on color, plot title, font size, color-scheme, plot size and other common configurations.
categorical_eda( data, xval, plot_type = "histogram", color = NULL, title = NULL, font_size = 10, color_scheme = "Tableau 20", opacity = 0.6, facet_factor = NULL, facet_col = NULL )
| data | A tibble or a dataframe |
|---|---|
| xval | A variable used to represent the x-axis. |
| plot_type | An optional character variable used to specify plot type. Options include "histogram" and "density". |
| color | A character variable used to set the color variable of the plot |
| title | An optional character variable used to set the title of the plot |
| font_size | An optional integer variable used to set the font size |
| color_scheme | An optional character variable used to set the color shceme |
| opacity | An optional integer variable used to specify density fill opacity for the density plot |
| facet_factor | An optional character variable used to specify facet factor |
| facet_col | An optional numeric variable used to specify number of facet columns |
A ggplot2 object, either a histogram or a density plot
library(palmerpenguins) categorical_plot <- categorical_eda( data = penguins, xval = body_mass_g, color = island, title = "Histogram of Body Mass in Different Sex", facet_factor = "island", facet_col = 1 )#> Warning: Ignoring unknown parameters: binwidth, bins, pad


Corruption Accused ANC MP Bongani Bongo To Appear Before Parliament’s Ethics Committee
by NT EditorAfrican National Congress (ANC) MP Bongani Bongo, who was arrested on corruption charges on Thursday, is set to face Parliament’s ethics committee.
The former state security minister was arrested by the Hawks before he appeared in the Cape Town Magistrates Court. He was released on R5,000 bail.
ANC chief whip Pemmy Majodina said Parliament’s ethics committee was only inducted two weeks ago but would be seized with the Bongo matter at the soonest possible time.
Bongo currently served as the chairperson of the National Assembly’s home affairs portfolio committee.
“There is a case that Mr Bongo is facing with the ethics committee. Mr Bongo was phoned by the committee to come and appear before it,” Majodina said.
Majodina said the ANC’s Luthuli House would also have to reconsider Bongo’s deployment.
“The ANC makes deployments on their members, but now that we have such a case. Maybe the ANC needs to reconsider the deployment,” she said.


LIBVIRTMIB_SUBAGENT
Section: Virtualization Support (1)Updated: 2011-03-09
Index Return to Main Contents
NAME
libvirtMib_subagent - SNMP subagent for libvirtSYNOPSIS
libvirtMib_subagent [OPTIONS] [LISTENING ADDRESSES]DESCRIPTION
The libvirtMib_subagent provides SNMP functionality for libvirt. Therefore it is now possible to gather and set domain status over SNMP from one place. This allows to create views of entire platforms end to end.It communicates with SNMP agent over AgentX protocol (RFC 2741) and extends agent's set of infomation provided. Therefore, we need a running SNMP agent. This behaviour can be avoided using -M option.
The libvirtMib_subagent understands these OPTIONS:
- -f
- Don't fork. Run in foreground.
- -D[token[,...]]
- Turn on debugging output for the given TOKEN(s). Without any tokens specified, it defaults to printing all the tokens (which is equivalent to the keyword '"ALL"'). You might want to try ALL for extremely verbose output. Note: You can't put a space between the -D and the tokens.
- -H
- Display a list of configuration file directives understood by the agent and then exit.
- -M
- Run as a normal SNMP Agent instead of an AgentX sub-agent.
- -xADDRESS
- Connect to master agent at ADDRESS (default "/var/agentx/master"). The address can either be a Unix domain socket path, or the address of a network interface. The format is the same as the format of listening addresses described below.
- -L
- Do not open a log file; print all messages to stderr.
The last optional LISTENING ADDRESSES specify on which addresses should subagent running in normal SNMP Agent mode listen for incoming requests. See snmpd for further information.
BUGS
Report any bugs discovered to the libvirt community via the mailing list ``http://libvirt.org/contact.html'' or bug tracker ``http://libvirt.org/bugs.html''. Alternatively report bugs to your software distributor / vendor.AUTHORS
Please refer to the AUTHORS file distributed with libvirt.COPYRIGHT
Copyright (C) 2011 Red Hat, Inc., and the authors listed in the libvirt-snmp AUTHORS file.LICENSE
libvirt-snmp is distributed under the terms of the GNU GPL v3. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSESEE ALSO snmpd, <http://www.libvirt.org>
Index
This document was created by man2html, using the manual pages.
Time: 05:29:05 GMT, December 24, 2015


@remarks
The Style parameter defines the style elements (such as white space or the positive sign) that are allowed in the s parameter for the parse operation to succeed. It must be a combination of bit flags from the NumberStyles enumeration. Depending on the value of Style, the s parameter may include the following elements:
[ws][$][sign][digits,]digits[.fractional_digits][e[sign]exponential_digits][ws]
Or, if style includes AllowHexSpecifier:
[ws]hexdigits[ws]
Elements in square brackets ([ and ]) are optional. The following table describes each element.
| Element | Description |
|---|---|
| ws | Optional white space. White space can appear at the beginning of s if Style includes the NumberStyles.AllowLeadingWhite flag, and it can appear at the end of s if Style includes the NumberStyles.AllowTrailingWhite flag. |
| $ | A culture-specific currency symbol. Its position in the string is defined by the NumberFormatInfo.CurrencyPositivePattern property of the NumberFormatInfo object returned by the GetFormat method of the Provider parameter. The currency symbol can appear in s if style includes the NumberStyles.AllowCurrencySymbol flag. |
|
digits fractional_digits expontial_digits |
A sequence of digits from 0 through 9. |
| , | A culture-specific thousands separator symbol. The thousands separator of the culture specified by Provider can appear in s if Style includes the NumberStyles.AllowThousands flag. |
| . |
A culture-specific decimal point symbol. The decimal point symbol of the culture specified by Provider can appear in s if style includes the NumberStyles.AllowDecimalPoint flag. Only the digit 0 can appear as a fractional digit for the parse operation to succeed; if fractional_digits includes any other digit, an OverflowException is thrown. |
| e | The 'e' or 'E' character, which indicates that the value is represented in exponential notation. The s parameter can represent a number in exponential notation if Style includes the NumberStyles.AllowExponent flag. |
| hexdigits | A sequence of hexadecimal digits from 0 through f, or 0 through F. |
A string expression beginning with "0x" or "&h" will be parsed as a hex value.


---
---
Make a short list of things that annoy you
My List:
- Shell: git tab completion doesn't work for all subcommands
- Shell: codecept isn't tab-completing
- Vim: I want Javascript files to open unfolded
- Vim: Enable PHP Syntax checking [PSR-2]
- Vim: Copy-Yank-Put with clipboard=unnamed
- etc....
Making a List
- When you encounter something that annoys you, write it on your list
- Whenever you say, there must be a better way to do this, add it to your list
- When you need something, but don't have time to research right now...
- When you find yourself making the same typo over and over...
Spend 10-15 minutes every day on your list
- Prioritize your list by agony
- Try to complete at least one item from your list


Avoid entering port for clearance on weekends as the overtime charges are fairly hefty. The approaches to the harbour are well marked.
Customs, Immigration and Quarantine can be done at the marina. The main wharf (Charlie dock) attracts a US$30 fee, although Clearance is possible here. Contact the Port Captain on VHF Ch. 16 for directions on where to moor.
Last updated 2008.
Smiling Cove Marina, located north of the American Memorial Park in Garapan, is reasonably well protected, but is not safe in a typhoon. Services for transient yachts have ceased and cruisers report that the situation does not like it will improve.
Outer Cove Marina, located on the east of the island in Tanapag harbour, almost due west of Monagaha Island, was built in 2008 and has fixed concrete docks. Fuel, ice and supplies from a mobile store are available.
The inner harbour does provide good shelter, but it is on a first come, first served basis and gets very crowded.
Last updated May 2013.


BABY RECORD
BABY'S PROFILE
BABY'S GROWTH
IMMUNIZATION
DOCTOR'S ADVICE
EDIT INFO
EDIT INFO
BABY'S NAME
Customer Name"; // list box select command foreach ($dbo->query($sql) as $row){//Array or records stored in $row echo "
$row[username]
"; /* Option values are added by looping through the array */ } echo "";// Closing of list box ?>
BIRTHDAY
ADDRESS
MOTHER'S NAME
FATHER'S NAME
Submit
Should be Empty:


Court rejects Trump’s appeal in fight over financial records
by KNOEWASHINGTON (AP) — A federal appeals court will not take up President Donald Trump’s appeal of a ruling that his accounting firm must turn over financial records to Congress.
The order was handed down Wednesday by the U.S. Court of Appeals for the District of Columbia Circuit.
It is almost certain that Trump will appeal to the Supreme Court.
A three-judge appellate panel rejected Trump’s arguments last month after the president’s lawyers went to court to prevent Mazars USA from turning over the records. But Trump petitioned for the full court to reconsider the case.
The House Committee on Oversight and Reform subpoenaed records from Mazars in April.
They include documents from 2011 to 2018 that the House wants for investigation into the president’s reporting of his finances and potential conflicts of interest.
Copyright 2019 Associated Press. All rights reserved.


In order to ensure proper operation of OSP, please provide the following information:
** Restoring a backup will wipe all existing data! **


Paste this in to teleport to exact place/angle.
setpos 2498.968750 -993.968750 1677.927490;setang -29.268682 154.468796 0.000000
Take one step forward then immediately jump throw. If you have made a step noise, you have stepped too far forward. A jump throw bind is recommended to ensure consistency.


1) Exit the church parking lot and turn right tn
LakeShore Blvd.
2) Make an almost immediate Left on to East 200 St.
3) Travel about 1 mile untill you encounter I-90.
4) Go under the bridge and turn left onto the marginal road.
5) Take the marginal road onto I-90 East.
6) Take State Route 2 East at the I-90 split in Euclid. You will
just go strait as I-90 viers to the right.
7) Exit at Route 91, SOM Center Road, Willoughby / Eastlake.
8) Turn Right at the light. Go about .5 mile to Euclid Ave. There
will be a Denny's and a BP at the corner.
9) At the stop light, turn left on to Euclid Ave, Route 20.
10) Take Euclid Ave about 2 miles into downtown Willoughby. You
will Pass a Lowe's on the right, and a big plaza on the left. Once
you see a little park on the right, and white tree lights along
the road, you are in downtown.
11) Turn right on to Glenn Ave / 2nd St. It will be the second
light in the downtown area.
12) After the storefront on the left ends, you will see the Willoughby
Brewing Company back to the left. You can park in the lot in front
of the Brewing company. There is an overflow lot across Glenn Street.
|


Press Play New first.
This web application is for a free practice of four Chinese tones recognition.
It uses high quality audio from Tone Perfect Database.
Martin Hassman, programming.
Catherine Ryu, Mandarin Tone Perception & Production Team, and Michigan State University Libraries. Tone Perfect: Multimodal Database for Mandarin Chinese.
My name is Martin Hassman, I'm an IT professional from the Czech Republic. I love learning laguanges and developing applications that help with learning (eg. Subfilter for Netflix). I am volunteer at Cesko.Digital.


CVE-2021-21341: XStream can cause a Denial of Service.
All versions until and including version 1.4.15 are affected, if using the version out of the box. No user is affected, who followed the recommendation to setup XStream's security framework with a whitelist limited to the minimal required types.
The processed stream at unmarshalling time contains type information to recreate the formerly written objects. XStream creates therefore new instances based on these type information. An attacker can manipulate the processed input stream and replace or inject a manipulated ByteArrayInputStream (or derived class), that can cause an endless loop resulting in a denial of service.
Create a simple PriorityQueue and use XStream to marshal it to XML. Replace the XML with following snippet and unmarshal it again with XStream:
<java.util.PriorityQueue serialization='custom'> <unserializable-parents/> <java.util.PriorityQueue> <default> <size>2</size> <comparator class='javafx.collections.ObservableList$1'/> </default> <int>3</int> <com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data> <dataHandler> <dataSource class='com.sun.xml.internal.ws.encoding.xml.XMLMessage$XmlDataSource'> <is class='java.io.ByteArrayInputStream'> <buf></buf> <pos>-2147483648</pos> <mark>0</mark> <count>0</count> </is> <consumed>false</consumed> </dataSource> <transferFlavors/> </dataHandler> <dataLen>0</dataLen> </com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data> <com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data reference='../com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data'/> </java.util.PriorityQueue> </java.util.PriorityQueue>
XStream xstream = new XStream(); xstream.fromXML(xml);
As soon as the XML gets unmarshalled, the an endless loop is entered and the executing thread consumes maximum CPU time and will never return.
Note, this example uses XML, but the attack can be performed for any supported format. e.g. JSON.
The vulnerability may allow a remote attacker to allocate 100% CPU time on the target system depending on CPU type or parallel execution of such a payload resulting in a denial of service only by manipulating the processed input stream.
See workarounds for the different versions covering all CVEs.
The vulnerability was discovered and reported by threedr3am.


Examples
Remember:
- CSS in the html head
- HTML at the bottom of your the document
- JS just before
</body>
- Make sure there aren't any javascript errors in your code, before calling outdatedbrowser plugin,
specially in older browsers. Try this: call outdatedBrowser.min.js and the
function outdatedBrowser({.....}), before any other scripts you have!
by Bürocratik


K-Means++ code from scratch [Julia] - 2/3
This post continuous the previous post about ClusterAnalysis.jl package by detailing all code created for the K-Means++ implementation. It will dive into the pseudocode presented in ‘Algorithms Section’ in the documentation and will presenting how each step was implemented in the source code.
Representation of the K-Means algorithm by livebook MLWR
My goal is that at the end of this post, you will be in touch with with some good practices in package development Julia.
I want to go beyond creating a tutorial that only teaches how to create packages/code, as there are already several posts of these, by going further and demonstrate a bit of a Julia package developer’s line of thinking when creating an algorithm from scratch for a package.
Notes: Since this post explain good practices in package development, I will assume that the reader has a good understanding of some Julia concepts such like
types
,multiple dispatch
,broadcast operator
,immutable/mutable structs
andpositional/keywords arguments
.I recommend that you read the Algorithms Section of the K-Means, that explains the algorithm through various gifs and graphics, before diving into the details of the source code in this post.
1 - The K-Means Struct
The goal is to create a kmeans()
function that receive, at minimum, these 2 arguments:
- A tabular data (row
n
x columnm
), wherem > 1
- The desired number of clusters
K
Which results in the following output:
- The number of clusters
K
- All centroids values inside a Vector, resulting in a Vector of Vector (named
centroids
) - The label for each observation, resulting in a a Vector of size
n
(namedcluster
)
- The quality measure of the model, that mensure the Total Variance Within Cluster (named
withinss
)
- The Number of iterations until algorithm converge (named
iter
)
So I will start talking about the output first. Initially, we create a Mutable Struct
with the clusters prediction that would be updated at each iteration of the algorithm, but soon we realized that this was inefficient. Then after a few refactorings, Elias and I concluded that the best structure would be to have a immutable struct
that would receive only the optimal values after finish all iterations.
In this initial version, we add the algorithm initialization inside the struct
initialization. This make the process more complex because in the next iterations we need to update this values that were initialized and also we lost performance by utilizing a mutable struct
instead of an imutable struct
, as Performance Tips section in Julia Documentation suggests.
I suggest you read the Performance Tips Section of Julia documentation. It contains a lot practices that was implemented in this package.
See how it was:
# Now I see how terrible it was haha
mutable struct Kmeans{T<:AbstractFloat}
df::Matrix{T}
K::Int
centroids::Vector{Vector{T}}
cluster::Vector{T}
variance::T
# initialization function
function Kmeans(df::Matrix{T}, K::Int) where {T<:AbstractFloat}
# generate random centroids
# ...
# estimate clusters
# ...
# evaluate total variance
# ...
return new{T}(df, K, centroids, cluster, variance)
end
end
And see how it becomes:
struct KmeansResult{T<:AbstractFloat}
K::Int
centroids::Vector{Vector{T}}
cluster::Vector{Int}
withinss::T
iter::Int
end
Now It’s much more simple to anyone understand and also more performatic.
It’s like they say: “Less is more”. 😆
Quick tip: The use of an AbstractType in the Struct, like the
T<:AbstractFloat
, it’s recommended for a package because allow the Julia Compiler adapt the code to different versions of Floats that computers could have (Float32, Float64, etc).So, you will see for all functions in the package, that we use
AbstractMatrix
for Matrix,AbstractVector
for Vectors and so on….
2 - The nstart
argument
Our K-Means implementation repeats the algorithms nstart
times and selects the best result from them.
The idea is that as the initialization of the algorithm is completely random, when we run it several times, we try to avoid local minimums, thus getting a little closer to the global minimum.
So we encapsulate the algorithm inside the _kmeans()
function and run the following for-loop in to the kmeans()
function:
function kmeans(data::AbstractMatrix{T}, K::Int;
nstart::Int = 1,
maxiter::Int = 10,
init::Symbol = :kmpp) where {T<:AbstractFloat}
# number of lines in the dataset
nl = size(data, 1)
# create the variables outside for-loop to be updated
centroids = Vector{Vector{T}}(undef, K)
cluster = Vector{Int}(undef, nl)
withinss = Inf
iter = 0
# run multiple kmeans to get the best result
for _ in 1:nstart
# execute the algorithm searching for a global minimum
new_centroids, new_cluster, new_withinss, new_iter = _kmeans(data, K, maxiter, init)
if new_error < withinss
# update the final values and error
centroids .= new_centroids
cluster .= new_cluster
withinss = new_withinss
iter = new_iter
end
end
return KmeansResult(K, centroids, cluster, withinss, iter)
end
Note: Take a look at the broadcast operator (
.
) used to update model variables. When update a vector the broadcast it’s used.=
, but when we updated a single value, it’s used=
.
In the end, we pass all the parameters of the optimal result inside the struct KmeansResult
constructed before.
Now, lets go dive into the algorithm, where all the magic happens, by constructing the function _kmeans()
.
3 - The K-Means pseudocode
Moving on in the algorithm, I rescued the pseudocode steps presented in the package documentation:
- Initialize k centroids by K-Means++ algorithm or by random initialization.
- Calculate the distance of every point to every centroid.
- Assign every point to a cluster, by choosing the centroid with the minimum distance to the point.
- Calculate the Total Variance Within Cluster by the Sum of Squared Error (SSE) of this iteration.
- Recalculate the centroids using the mean of the assigned points.
- Repeat the steps 3 to 5,
maxiter
times or until reaching convergence with minimum total variance at step 4.
Here it’s a gif that represent these iterations of the algorithm, available at the K-Means wikipedia page.
4 - Distance function
As you realized seeing the pseudocode, the K-Means calculate distances every time. And I think that it’s the main point of the performance in the code. Because of that concern, we construct our distance function implementing all the good practices we learned, like parallelization with macros @simd
, indexations instructions with macro @inbounds
and some heeds about reducing allocations.
All those points deserve another post just for them and I will let to Elias create that post because he made most of the research and prototype that function. Thus, when he finished that, I will update that paragraph with the link to his post.
For now, we have this beautiful and performatic implementation of the euclidian distance:
function euclidean(a::AbstractVector{T},
b::AbstractVector{T}) where {T<:AbstractFloat}
@assert length(a) == length(b)
# euclidean(a, b) = √∑(aᵢ- bᵢ)²
s = zero(T)
@simd for i in eachindex(a)
@inbounds s += (a[i] - b[i])^2
end
return √s
end
QuickTip: Use
eachindex(x)
instead of1:length(x)
in for-loops. It’s more performatic. I encourage you to check using the macros of theBenchmarkTools
package. ☺
5 - Initialization (Random and K-Means++)
The first step is the initialization and we got two implementations. The easiest method is :random
and the hardest is :kmpp
.
5.1 - Random Initialization
The :random
initialization is very simple, it was proposed by Andrew NG in his Machine Learning Course, and basically select randomly K points of the dataset as the initial centroids. Thus, we code this way:
# variable `data` received from function `_kmeans(...)`
nl = size(data, 1)
# random select the idx of K centroids
indexes = rand(1:nl, K)
# select the values of those idx as centroids
centroids = Vector{T}[data[i, :] for i in indexes]
5.2 - K-Means++ Initialization
The :kmpp
algorithm is a smart centroid initialization method that works with those steps:
1. Select randomly one point in the dataset as the first centroid.
2. Compute the distance (euclidian or other) of all point of that dataset from the selected point.
3. Select as the new centroid the point with the maximum distance of the first centroid.
4. Repeat the steps until find all the K
centroids required.
If you want to delve into the math that underlies
:kmpp
, I suggest you to read the first paper of the method, here. 🤓
At first view, looks simple, a for loop for each observation to every centroid (resulting in two for-loops) is enough, but it also has one important detail that very few tutorials present.
When calculating the distances of all points after the second centroid, it’s necessary, for each point, assign the nearest centroid for calculating the distances for the next centroid. This ensures that we are getting the correct maximum distance when considering all centroids already labeled.
Image to represent that important detail of the method.
Because of that, we need to use another for-loop, that we encapsulated using an array comprehension, which results in that final code of :kmpp
:
# K: Number of clusters desired
# data: Dataset inputed in function
# nl: Number of lines in `data`
...
centroids = Vector{Vector{T}}(undef, K) # create the vector of vector with size `K`
centroids[1] = data[rand(1:nl), :] # select randomly the first centroid
# distance vector for each observation
dists = Vector{T}(undef, nl)
# get each new centroid by the furthest observation (maximum distance)
for k in 2:K
# for each observation get the nearest centroid by the minimum distance
for (i, row) in enumerate(eachrow(data))
dist_c = [euclidean(row, c) for c in @view centroids[1:(k-1)]]
@inbounds dists[i] = minimum(dist_c)
end
# new centroid by the furthest observation
@inbounds centroids[k] = data[argmax(dists), :]
end
return centroids
This implementation use the macro @inbounds
to discard the check inbounds in arrays that Julia does automatically. This optimize the code but is risky and should only be used when you are pretty sure that it’ll work correctly. I really suggest you read this section of the docs for more details about it.
QuickTip: Since when we slice arrays (
A[1:10]
), we create a copy of the array, performing new allocations, we use the@view
macro to reduce the number of allocations of our algorithm.Also
@view
it’s not recommended for small arrays, but it’s for big arrays. Thus, I suggest you to make some tests whenever your could using theBenchmarkTools
package.A reading suggestion about the use of view
5.3 - Function _initialize_centroids()
To keep things organized, we have the argument init
, which receives a Symbol
type, that accept :random
or :kmpp
. Then, we finalize that initialization section with the following final function:
function _initialize_centroids(data::AbstractMatrix{T},
K::Int,
init::Symbol) where {T<:AbstractFloat}
nl = size(data, 1)
if init == :random
indexes = rand(1:nl, K)
centroids = Vector{T}[data[i, :] for i in indexes]
elseif init == :kmpp
centroids = Vector{Vector{T}}(undef, K)
centroids[1] = data[rand(1:nl), :]
# distance vector for each observation
dists = Vector{T}(undef, nl)
# get each new centroid by the furthest observation (maximum distance)
for k in 2:K
# for each observation get the nearest centroid by the minimum distance
for (i, row) in enumerate(eachrow(data))
dist_c = [euclidean(row, c) for c in @view centroids[1:(k-1)]]
@inbounds dists[i] = minimum(dist_c)
end
# new centroid by the furthest observation
@inbounds centroids[k] = data[argmax(dists), :]
end
else
throw(ArgumentError("The symbol :$init is not a valid argument. Use :random or :kmpp."))
end
return centroids
end
6 - The _kmeans()
function
Continuing the steps of the pseudocode, I’m think that a good generalization of those is that we iterate through 2 macro steps: (i) assign points to a cluster and (ii) recalculate centroids using mean()
.
Also, during every iteration we calculate the Total Variance as a measure of model quality and also check the Stop Rule by comparing the difference in recalculated centroids.
In general, we should have those steps in the _kmeans()
function:
function _kmeans(data, K, maxiter, init)
# number of observations/lines of the dataset
nl = size(data, 1)
# initialize centroids (that it's already constructed)
centroids = _initialize_centroids(data, K, init)
# estimate first clusters with centroids
#...
# evaluate total variance
#...
# start iterations (for-loop)
# update centroids using mean()
# ...
# reestimate clusters...
# ...
# check stop rule
# ...
return centroids, cluster, withinss, iter
end
Note that it is necessary to do a first estimation before going to update the centroids in the for-loop iterations. Because of this, our first struct
was that terrible idea using mutable struct
. 😆
6.1 - Estimate clusters
To make the estimation of the clusters with the centroids initialized, we use a vector with size n
, calculate for every point the distance to all centroids and select the centroid with minimum distance. Therefore, we need to initialize a vector and create a double for loop, that first pass through all observations n
and then calculate the distances to all centroids.
# first clusters estimate
cluster = Vector{Int}(undef, nl)
for (i, obs) in enumerate(eachrow(data))
dist = [euclidean(obs, c) for c in centroids]
@inbounds cluster[i] = argmin(dist)
end
We choose use an Array Comprehension as the second for-loop and also use enumerate()
to assign the label to the cluster
array using the index i
.
QuickTip: If you know the size and the type of the vector, pre-allocate the vector before using it, like the cluster vector
cluster = Vector{Int}(undef, nl)
. It’s a very excelent practice.Also, It’s faster pre-allocate a vector and update each of their values using
vector[i] = ...
, instead of create an empty vector and push values inside it, likea = Int[]; push!(a, ...)
.
6.2 - Total Variance Within Cluster (withinss
)
Since we got an equivalence in the withinss
with the Sum of Squared Error (SSE) measurement, the model evaluation function calculate the Sum of Squared Error (SSE) for each cluster. That “for each” in the sentence it’s a filter that we need to do before make the calculus, using data[cluster .== k, :]
.
So, we created a function called totalwithinss()
that evaluate for each cluster the SSE, using a for-loop, and sum them all. Resulting in our Total Variance Within Cluster desired.
function totalwithinss(data::AbstractMatrix{T}, K::Int, cluster::AbstractVector{Int}) where {T<:AbstractFloat}
# evaluate total-variance-within-clusters
error = zero(T)
@simd for k in 1:K
error += squared_error(data[cluster .== k, :])
end
return error
end
Now, in the squared_error()
function, we use the multiple dispatch paradigm of the language to being able to properly calculate the Total Variance, considering two distinct cases:
* Have multiple points assigned to the cluster, resulting in a Matrix.
* Have only one point assigned to the cluster, resulting in a Vector.
Thus, instead make a if-else inside the function, we create two functions to cover both cases. One which receive an AbstractMatrix
and other which receive an AbstractVector
.
function squared_error(col::AbstractVector{T}) where {T<:AbstractFloat}
m = mean(col)
error = zero(T)
@simd for i in eachindex(col)
@inbounds error += (col[i] - m)^2
end
return error
end
function squared_error(data::AbstractMatrix{T}) where {T<:AbstractFloat}
ncol = size(data, 2)
error = zero(T)
@simd for i in 1:ncol
error += squared_error(view(data, :, i))
end
return error
end
Another detail of this function architecture, is that when we input a matrix, the function always ended-up going to the Vector version. This ensures that we capture all the possibilities and make it easier for the compiler find the best optimized version of the function during compilation.
Note: Since the centroids are the mean of the assigned observations, we could use the operation
mean()
in the function without worries.QuickNote: As you realized, we are using again optimization macros in the functions, like
@simd
and@inbounds
, to obtain the best of the performance in Julia.
6.3 - Running iterations (Inside for-loop)
During the iterations, it will be necessary to compare the new results of the centroids
, cluster
, norms
and withinss
variables with the previous values. Therefore, it is necessary create a copy of these measures outside the for-loop so that their values are updated and compared.
So filling the _kmeans()
function with what has already been explained, we have the following function:
function _kmeans(data::AbstractMatrix{T}, K::Int, maxiter::Int, init::Symbol) where {T<:AbstractFloat}
nl = size(data, 1)
# generate random centroids
centroids = _initialize_centroids(data, K, init)
# first clusters estimate
cluster = Vector{Int}(undef, nl)
for (i, obs) in enumerate(eachrow(data))
dist = [euclidean(obs, c) for c in centroids]
@inbounds cluster[i] = argmin(dist)
end
# first evaluation of total-variance-within-cluster
withinss = totalwithinss(data, K, cluster)
# variables to update during the iterations
new_centroids = copy(centroids)
new_cluster = copy(cluster)
iter = 1
norms = norm.(centroids)
# start kmeans iterations until maxiter or convergence
for _ in 2:maxiter
# update centroids using mean()
# ...
# reestimate clusters...
# ...
# check stop rule
# ...
end
return centroids, cluster, withinss, iter
end
To make the update of the new centroids using the mean, we use a for-loop through all K centroids, which calculate the mean for every columns/variable of the observations in each cluster. Thus, we filter the data using data[new_cluster .= k,:]
, but we incorporate the view()
function to avoid unnecessary allocations, resulting in view(data, new_cluster .== k, :)
. Then we use the argument dims=1
to calculate the mean of each column and encapsulate all inside vec()
to standardize the output.
# update new_centroids using the mean
@simd for k in 1:K # mean.(eachcol(data[new_cluster .== k, :]))
@inbounds new_centroids[k] = vec(mean(view(data, new_cluster .== k, :), dims = 1))
end
This for-loop is a good example of using the explained tips. Have the optimizations macros @simd
and @inbounds
, use of view()
and update the pre-allocated vector.
To reestimate clusters using the new centroids, we use the same code showed before, outside the for-loop.
# estimate cluster to all observations
for (i, obs) in enumerate(eachrow(data))
dist = [euclidean(obs, c) for c in new_centroids]
@inbounds new_cluster[i] = argmin(dist)
end
Then, we update the new withniss
, the number of iterations iter
by running iter += 1
, and calculate the norm()
of each new centroid to inspect if the iteration made some significant change in the centroid (that is our Stop Rule).
# update iter, withinss-variance and calculate centroid norms
new_withinss = totalwithinss(data, K, new_cluster)
new_norms = norm.(new_centroids)
iter += 1
# convergence rule
norm(norms - new_norms) ≈ 0 && break
See the convergence rule, there we calculate the norm()
of the difference between the earlier and newer norms
of the centroids. This way, it’s possible to check if the centroids got a significant change after the iteration. Also, the tolerance utilized for the check is 1e-8
, which is the default of the aproximation operator ≈
.
If the convergence rule is true, the for-loop stops in the break
statement, and the final results it’s the values of the earlier iteration, because the last iteration didn’t have a significant change. If the convergence rule is false, then we update the norm
to compare in the next iteration and make the check to update the values of the model, inside the if-else statement below.
# update centroid norms
norms .= new_norms
# update centroids, cluster and whithinss
if new_withinss < withinss
centroids .= new_centroids
cluster .= new_cluster
withinss = new_withinss
end
Thus, bringing together all the points raised, we have the following final function of _kmeans()
:
function _kmeans(data::AbstractMatrix{T}, K::Int, maxiter::Int, init::Symbol) where {T<:AbstractFloat}
nl = size(data, 1)
# generate random centroids
centroids = _initialize_centroids(data, K, init)
# first clusters estimate
cluster = Vector{Int}(undef, nl)
for (i, obs) in enumerate(eachrow(data))
dist = [euclidean(obs, c) for c in centroids]
@inbounds cluster[i] = argmin(dist)
end
# first evaluation of total-variance-within-cluster
withinss = totalwithinss(data, K, cluster)
# variables to update during the iterations
new_centroids = copy(centroids)
new_cluster = copy(cluster)
iter = 1
norms = norm.(centroids)
# start kmeans iterations until maxiter or convergence
for _ in 2:maxiter
# update new_centroids using the mean
@simd for k in 1:K # mean.(eachcol(data[new_cluster .== k, :]))
@inbounds new_centroids[k] = vec(mean(view(data, new_cluster .== k, :), dims = 1))
end
# estimate cluster to all observations
for (i, obs) in enumerate(eachrow(data))
dist = [euclidean(obs, c) for c in new_centroids]
@inbounds new_cluster[i] = argmin(dist)
end
# update iter, withinss-variance and calculate centroid norms
new_withinss = totalwithinss(data, K, new_cluster)
new_norms = norm.(new_centroids)
iter += 1
# convergence rule
norm(norms - new_norms) ≈ 0 && break
# update centroid norms
norms .= new_norms
# update centroids, cluster and whithinss
if new_withinss < withinss
centroids .= new_centroids
cluster .= new_cluster
withinss = new_withinss
end
end
return centroids, cluster, withinss, iter
end
7 - Tables.jl integration
Until now, the ClusterAnalysis.jl
implementation it’s based on the 3 main big functions that we constructed together here:
kmeans()
_kmeans()
_initialize_centroids()
and the distance and variance functions:
euclidian()
totalwithniss()
squared_error()
Before finishing this post, I want to quickly explain an integration we made of the package to the Tables.jl
interface, which allows the package to receive all the inputs contained in that interface.
Here is the list of all inputs that Tables.jl
interface allow.
To make this integration we use again the multiple dispatch by creating new kmeans functions above:
- First: Make a
if-else
to check if the input is allowed inTables.jl
interface. If true, select the data in the input as a matrix and pass to the second or the third function. - Second: Receive any type of input coming from the first function and, if its not a subtype of an
AbstractFloat
, convert to a matrix ofFloat64
, passing to the third function. - Third: Receive an input, which is a subtype of
AbstractFloat
, and run the algorithm constructed.
# first function
function kmeans(table, K::Int; kwargs...)
Tables.istable(table) ? (data = Tables.matrix(table)) : throw(ArgumentError("The table argument passed does not implement the Tables.jl interface."))
return kmeans(data, K; kwargs...)
end
# second function
kmeans(data::AbstractMatrix{T}, K::Int; kwargs...) where {T} = kmeans(convert(Matrix{Float64}, data), K; kwargs...)
# third function
function kmeans(data::AbstractMatrix{T}, K::Int;
nstart::Int = 1,
maxiter::Int = 10,
init::Symbol = :kmpp) where {T<:AbstractFloat}
# generate variables to update with the best result
nl = size(data, 1)
# ...
# ...
# ...
end
We also make use of the kwargs...
in the argument function to make the code more concise and less repetitive.
Well, now I think you are able to navigate through the source-code of K-Means and understand how every line of the code interact with each other. Going veeery beyond a simple model.fit()
😆
I hope you enjoy this journey and if you have any suggestion, question or even catch some mistake, typo and etc, feel free to contact me in whatever media you want. Here is my contact page.
That’s all folks. 😄


class OrderFeatureQuery extends OrderFeatureQuery
Skeleton subclass for performing query and update operations on the 'order_feature' table.
You should add additional methods to this class to meet the application requirements. This class will only be generated as long as it does not already exist in the output directory.


Tasked with creating an internal dashboard we decided to go with Shopify’s
Dashing framework. However, I ran into a problem when using the data-foreach
binding to iterate over a hash where I needed to access both the key
and the
value
. Unable to find the solution in the documentation or online I turned
to the batmanjs freenode irc channel.As it turns out the solution is very
simple.
The data-foreach
binding iterates over the keys. Use the key to
lookup the value and boom goes the dynamite.
Hash:
Products = { product1: '$1', product2: '$2' }
View:

Output:

product1
$1

product2
$2


[gecode-users] Backjumping (aka Intelligent Backtracking)
Luca Di Gaspero
l.digaspero at uniud.it
Wed Mar 5 17:47:05 CET 2014
Hi Christian,
> No, really anything useful to say here. It should be possible and due to the
> documentation it should be easier to do than before but it would mean that
> you really program your own search engine.
Given the elegant design of Search Engines is not a problem ;-)
> What might help you, though, is the support we added in 4.2.1 for nogood
> literals.
Right, maybe I can take inspiration from the RBS. By the way, what’s the current situation with *direct* option passing to search engines? (do you remember the talks you had with Tommaso Urli at CP?)
Thanks and all the best,
Luca
More information about the users
mailing list


BestHint
.
Home
(current)
About Us
Contact Us
All Posts
Gaming | Trending
Battle Grounds Mobile India - FUll Review
Gaming | Trending
Battlegrounds Mobile India Permanent BAN Notice
Smartphone | Tech
Top 5 Best Mobile Phone Under 10k
Smartphone | Tech
Mi 11 Ultra Vs Samsung S21 Ultra [ Legends of Android Mobile Community ]
Lifestyle
Best Mid-Range Mobile Companies in the market.
Smartphone | Tech
Samsung Exynos 2100 Edition vs Qualcomm 888 Edition - Just for Samsung S21 Ultra
Recent Posts
Battle Grounds Mobile India - FUll Review
June 22, 2021
Battlegrounds Mobile India Permanent BAN Notice
June 22, 2021
Top 5 Best Mobile Phone Under 10k
June 21, 2021
Explore
- Trending
- Gaming
- Tech
- Lifestyle


R/SEIR_outbreak_model_fitting.R
seir_model_fit.Rd
Create an instance of the hierarchical SEIR Stan model incorporating various data elements and sample model.
seir_model_fit( stan_model = NULL, tmax, n_outbreaks, outbreak_cases, outbreak_sizes, intervention_switch = TRUE, multilevel_intervention = FALSE, priors = prior_list, chains = 4, iter = 600, seed = 42, fit_type = "NUTS", data_model = "poisson" )
| stan_model | [rstan] model object |
|---|---|
| tmax | Total number of time-points in observation |
| n_outbreaks | Total number of outbreaks |
| outbreak_cases | Number of daily reported cases by outbreak |
| outbreak_sizes | The total size of each facility (initial number of susceptible and exposed) |
| intervention_switch | Describes whether interventions occur in data (default TRUE) |
| multilevel_intervention | Describes whether intervention occurs |
| chains | Number of chains to sample |
| iter | number of iterations of MCMC |
| seed | The seed for random number generation. Set to replicate results. |
| fit_type | string "NUTS" or "VB" (VB quicker but less accurate). |
| data_model | string "poisson" or "negative_binomial". If negative_binomial selected then uses phi prior to control for overdispersion |
| prior_list | List of priors. See [prior_list] |
An object of class `stanfit` returned by sampling
Mike Irvine
stan_mod <- rstan::stan_model(system.file("stan", "hierarchical_SEIR_incidence_model.stan", package = "cr0eso")) tmax <- 5 pop_size <- 100 dim(pop_size) <- c(1) example_incidence <- matrix(c(1,1,2,3,2),ncol=1) fit <- seir_model_fit(stan_model = stan_mod, tmax,1,example_incidence,pop_size)#> #> SAMPLING FOR MODEL 'hierarchical_SEIR_incidence_model' NOW (CHAIN 1). #> Chain 1: #> Chain 1: Gradient evaluation took 0 seconds #> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: #> Chain 1: Iteration: 1 / 600 [ 0%] (Warmup) #> Chain 1: Iteration: 60 / 600 [ 10%] (Warmup) #> Chain 1: Iteration: 120 / 600 [ 20%] (Warmup) #> Chain 1: Iteration: 180 / 600 [ 30%] (Warmup) #> Chain 1: Iteration: 240 / 600 [ 40%] (Warmup) #> Chain 1: Iteration: 300 / 600 [ 50%] (Warmup) #> Chain 1: Iteration: 301 / 600 [ 50%] (Sampling) #> Chain 1: Iteration: 360 / 600 [ 60%] (Sampling) #> Chain 1: Iteration: 420 / 600 [ 70%] (Sampling) #> Chain 1: Iteration: 480 / 600 [ 80%] (Sampling) #> Chain 1: Iteration: 540 / 600 [ 90%] (Sampling) #> Chain 1: Iteration: 600 / 600 [100%] (Sampling) #> Chain 1: #> Chain 1: Elapsed Time: 1.674 seconds (Warm-up) #> Chain 1: 1.025 seconds (Sampling) #> Chain 1: 2.699 seconds (Total) #> Chain 1: #> #> SAMPLING FOR MODEL 'hierarchical_SEIR_incidence_model' NOW (CHAIN 2). #> Chain 2: #> Chain 2: Gradient evaluation took 0 seconds #> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0 seconds. #> Chain 2: Adjust your expectations accordingly! #> Chain 2: #> Chain 2: #> Chain 2: Iteration: 1 / 600 [ 0%] (Warmup) #> Chain 2: Iteration: 60 / 600 [ 10%] (Warmup) #> Chain 2: Iteration: 120 / 600 [ 20%] (Warmup) #> Chain 2: Iteration: 180 / 600 [ 30%] (Warmup) #> Chain 2: Iteration: 240 / 600 [ 40%] (Warmup) #> Chain 2: Iteration: 300 / 600 [ 50%] (Warmup) #> Chain 2: Iteration: 301 / 600 [ 50%] (Sampling) #> Chain 2: Iteration: 360 / 600 [ 60%] (Sampling) #> Chain 2: Iteration: 420 / 600 [ 70%] (Sampling) #> Chain 2: Iteration: 480 / 600 [ 80%] (Sampling) #> Chain 2: Iteration: 540 / 600 [ 90%] (Sampling) #> Chain 2: Iteration: 600 / 600 [100%] (Sampling) #> Chain 2: #> Chain 2: Elapsed Time: 1.567 seconds (Warm-up) #> Chain 2: 1.09 seconds (Sampling) #> Chain 2: 2.657 seconds (Total) #> Chain 2: #> #> SAMPLING FOR MODEL 'hierarchical_SEIR_incidence_model' NOW (CHAIN 3). #> Chain 3: #> Chain 3: Gradient evaluation took 0 seconds #> Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0 seconds. #> Chain 3: Adjust your expectations accordingly! #> Chain 3: #> Chain 3: #> Chain 3: Iteration: 1 / 600 [ 0%] (Warmup) #> Chain 3: Iteration: 60 / 600 [ 10%] (Warmup) #> Chain 3: Iteration: 120 / 600 [ 20%] (Warmup) #> Chain 3: Iteration: 180 / 600 [ 30%] (Warmup) #> Chain 3: Iteration: 240 / 600 [ 40%] (Warmup) #> Chain 3: Iteration: 300 / 600 [ 50%] (Warmup) #> Chain 3: Iteration: 301 / 600 [ 50%] (Sampling) #> Chain 3: Iteration: 360 / 600 [ 60%] (Sampling) #> Chain 3: Iteration: 420 / 600 [ 70%] (Sampling) #> Chain 3: Iteration: 480 / 600 [ 80%] (Sampling) #> Chain 3: Iteration: 540 / 600 [ 90%] (Sampling) #> Chain 3: Iteration: 600 / 600 [100%] (Sampling) #> Chain 3: #> Chain 3: Elapsed Time: 11.104 seconds (Warm-up) #> Chain 3: 0.705 seconds (Sampling) #> Chain 3: 11.809 seconds (Total) #> Chain 3: #> #> SAMPLING FOR MODEL 'hierarchical_SEIR_incidence_model' NOW (CHAIN 4). #> Chain 4: #> Chain 4: Gradient evaluation took 0 seconds #> Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 0 seconds. #> Chain 4: Adjust your expectations accordingly! #> Chain 4: #> Chain 4: #> Chain 4: Iteration: 1 / 600 [ 0%] (Warmup) #> Chain 4: Iteration: 60 / 600 [ 10%] (Warmup) #> Chain 4: Iteration: 120 / 600 [ 20%] (Warmup) #> Chain 4: Iteration: 180 / 600 [ 30%] (Warmup) #> Chain 4: Iteration: 240 / 600 [ 40%] (Warmup) #> Chain 4: Iteration: 300 / 600 [ 50%] (Warmup) #> Chain 4: Iteration: 301 / 600 [ 50%] (Sampling) #> Chain 4: Iteration: 360 / 600 [ 60%] (Sampling) #> Chain 4: Iteration: 420 / 600 [ 70%] (Sampling) #> Chain 4: Iteration: 480 / 600 [ 80%] (Sampling) #> Chain 4: Iteration: 540 / 600 [ 90%] (Sampling) #> Chain 4: Iteration: 600 / 600 [100%] (Sampling) #> Chain 4: #> Chain 4: Elapsed Time: 12.309 seconds (Warm-up) #> Chain 4: 0.706 seconds (Sampling) #> Chain 4: 13.015 seconds (Total) #> Chain 4:#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable. #> Running the chains for more iterations may help. See #> http://mc-stan.org/misc/warnings.html#tail-ess