| | | Compiling...
Signature.cpp
\ActiveX\XMLSign\Signature.cpp(256) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(412) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(434) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(435) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(437) : warning C4995: 'strcat': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(448) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(456) : warning C4995: 'lstrcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(456) : warning C4995: 'lstrcpyA': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(340) : warning C4101: 'lret' : unreferenced local variable
\ActiveX\XMLSign\Signature.cpp(339) : warning C4101: 'hkey' : unreferenced local variable
\ActiveX\XMLSign\Signature.cpp(628) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(1615) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(1823) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(1824) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(1886) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(2022) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(2412) : warning C4800: 'unsigned char *' : forcing value to bool 'true' or 'false' (performance warning)
\ActiveX\XMLSign\Signature.cpp(2535) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(2537) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(2539) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(2560) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(2563) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(2564) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(2601) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(2629) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(2665) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(2668) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(2669) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(2707) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(2735) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(3075) : warning C4101: 'guidStr' : unreferenced local variable
\ActiveX\XMLSign\Signature.cpp(3071) : warning C4101: 'sigGuid' : unreferenced local variable
\ActiveX\XMLSign\Signature.cpp(3598) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(4845) : warning C4995: 'wcscat': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(4846) : warning C4995: 'wcscat': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(4849) : warning C4995: 'wcscat': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(4896) : warning C4995: 'wcscpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(6208) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(6505) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(6508) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(6511) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(6517) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(6541) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(6543) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(6545) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(6553) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(6633) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(6641) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(6664) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(6665) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(7170) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(7171) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(7197) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(7203) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(7595) : warning C4995: 'strcat': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(7598) : warning C4995: 'strcat': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(8026) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(8083) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(8084) : warning C4995: 'strcat': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(8086) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(8087) : warning C4995: 'strcat': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(8124) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(8232) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(8395) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(8439) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(8469) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(8470) : warning C4995: 'strcat': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(8471) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(8472) : warning C4995: 'strcat': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(9255) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(9684) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(9779) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(11279) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(11285) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(11348) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(11403) : warning C4018: '<' : signed/unsigned mismatch
\ActiveX\XMLSign\Signature.cpp(11405) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(12245) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(12669) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(13000) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(13219) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(13225) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(13313) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(13314) : warning C4995: 'strcat': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(13315) : warning C4995: 'strcat': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(13731) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(13767) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(13774) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(14377) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(15705) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(15908) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(16035) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(16943) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(17025) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(17155) : warning C4800: 'unsigned char *' : forcing value to bool 'true' or 'false' (performance warning)
\ActiveX\XMLSign\Signature.cpp(17314) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(17319) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(18474) : warning C4995: 'wcscpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(18709) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(18751) : warning C4995: 'strcpy': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(18969) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(19079) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(19117) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(19122) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(19127) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(19132) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(19137) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(19142) : warning C4995: 'sprintf': name was marked as #pragma deprecated
\ActiveX\XMLSign\Signature.cpp(19147) : warning C4995: 'sprintf': name was marked as #pragma deprecated
ShowSelectCert.cpp
License.cpp
infomosaic_securexml_SignatureImpl.cpp
CRLCache.cpp
\ActiveX\XMLSign\CRLCache.cpp(67) : warning C4244: 'return' : conversion from 'LONGLONG' to 'long', possible loss of data
config.cpp
CharConversion.cpp
CertVerify.cpp
CAMClient.cpp
Generating Code...
Linking...
LINK : fatal error LNK1181: cannot open input file 'xmlsig_nss.lib'
|


As you enter the room, you see a statue of a hero. The statue is posing heroically, a sign next to the statue reads 'The great hero Karl Sturnguard whom has slain the last of the demons.'
You spot a small sword lying next to the statue.
{{ message }}


GNSDK C Quick Start Tutorial
Introduction
This tutorial shows you how to build a simple GNSDK C application from scratch. The application does a track title text search to identify an album in the Gracenote database. The Gracenote SDK provides several methods to access Gracenote metadata from a C application, most of which are demonstrated in the C sample apps that come with GNSDK.
NOTE: This tutorial application creates a very basic GNSDK application only, and is not meant to be used in a production environment. It does not include many other features and best practices found within the GNSDK and other sample applications. These include:
- GNSDK logging
- Loading a locale - Locales are a convenient way to group locale-dependent metadata. The quick start application does not access any locale-dependent metadata here.
- Code for accessing an embedded database
- Code for the SQLite module - Used for caching
- Decision code - Sometimes more than one match is returned or Gracenote is not entirely confident about the one match. This requires the user to pick one match or confirm the match. This application simply uses the first match.
- Partial or full metadata code - A match can contain full or partial metadata. If partial, an additional call is needed to get full metadata. In this case, the album title is part of partial metadata, so there is no need for an additional check.
- SDK user object - Normally, this object should be saved and retrieved from disk after initial creation. Here, the application just creates a new one.
Refer to the sample applications for examples of using these features in your application.
Setting Up Your Development Environment
The GNSDK is supports several different systems, including different flavors of Android, iOS, Linux, Macintosh, and Windows. Included with the SDK are the support files necessary to create a local build environment of your choosing.
Include Files
Include files for GNSDK applications are located in /include
under your installation directory. There are approximately 30 platform independent include files, and one platform dependent file, gnsdk_platform.h
. The different versions of the platform dependent file are stored under the /include
directory in subdirectories named for specific supported platforms, for example, linux_arm-32
. For proper compilation, ensure that the correct include files are made available to your build system. Although we mention these files for clarity, you should not need to include anything other than gnsdk.h
in your application for GNSDK. It will include the files necessary for compilation, based on the options you have defined.
Library Files
The library files necessary for linking are placed into two directories. The directory /lib
is for dynamically linked libraries, and /lib-static
is for statically linked libraries. There are approximately 15 (Windows has double, including DLLs) library files containing the binaries for GNSDK. For your application's link step to locate and include the GNSDK functionality, you must make these libraries available to your link process.
Source Files
The SDK comes with several C samples. They are located in the /samples
directory, with each sample having its own subdirectory. Most of these subdirectories consist of a main.c
file and a GNU makefile. You can use a sample makefile as a guide to creating a makefile for this tutorial. You can either add GNU software to your build system, such as with Cygwin on Windows, or you can build applications through native tools, such as Visual Studio.
Executing The Application
All the sample make files create a sample.exe
executable. For the quick start tutorial application, once you build successfully, you should be able to run the executable with the following command at a command prompt:
> sample <clientID> <clientIDtag> licfile.txt
In this example, the license file text is in its own file as a single line of text. You get Client ID and license information from Gracenote.
Coding the App
Once your development environment is setup, you can begin coding the application. As in the other sample applications, the code is going to be in one main.c
file which you
can create in any text editor or IDE. The application performs the following steps:
- Perform GNSDK initializations
- Look up an album in Gracenote's database from a single track
- Display the album title of the first match
- Shut down the GNSDK and exit the program
Code the Includes, Defines and Local Function Declarations
First, code all your pre-main()
function
includes, defines and local function declarations:
#define GNSDK_MUSICID 1 #include "gnsdk.h" // Includes all GN SDK headers /* Standard C headers - used by the sample app, but not required for GNSDK */ #include <stdio.h> #include <string.h> #include <stdlib.h> /* Local function declarations */ static int _init_gnsdk(const char* client_id, const char* client_id_tag, const char* client_app_version, const char* license_path, gnsdk_user_handle_t* p_user_handle); static void _display_error(int line_num, const char* info, gnsdk_error_t error_code); static void _shutdown_gnsdk(gnsdk_user_handle_t user_handle); static void _query_album_lookup(gnsdk_user_handle_t user_handle); static void _display_album_gdo(gnsdk_gdo_handle_t album_gdo);
A define is required for each module (MusicID, MusicID-File, DSP, and so on.) that the program uses. This application only uses MusicID. Including "gnsdk.h" will automatically include all the GNSDK headers. We are also including forward declarations for all our local functions except main()
.
Code the main() Function
The main()
function validates the command-line parameters and calls three other functions to perform initialization, lookup and display, and shutdown:
int main(int argc, char* argv[]) { gnsdk_user_handle_t user_handle = GNSDK_NULL; const char* client_id = NULL; const char* client_id_tag = NULL; const char* client_app_version = "1"; // Version of your application const char* license_path = NULL; if (argc != 4) { printf("\nUsage:\n%s clientid clientidtag license\n", argv[0]); return -1; } client_id = argv[1]; client_id_tag = argv[2]; license_path = argv[3]; /* GNSDK initialization */ if ((_init_gnsdk(client_id, client_id_tag,client_app_version,license_path,&user_handle)) == 0) { _query_album_lookup(user_handle); /* Perform a sample album text search query - calls display function */ _shutdown_gnsdk(user_handle); /* Clean up and shutdown */ } return 0; }
Code GNSDK Initializations
The _init_gnsdk()
function performs all necessary GNSDK initializations which include the following:
- Initialize the GNSDK manager with your license text
- Initialize the MusicID library
- Initialize the SDK User object - Normally, you would save this to a file after creating it and save it again at program exit if it had changed. This tutorial, skips storage and just creates a new user object and releases it on exit without saving it. User ID's are consumable. Best practice is to create and save it, rather than discarding it.
All the GNSDK functions
return "GNSDK_SUCCESS" if completed successfully. The error handling function - _display_error()
grabs system error information and displays it to the console when an error occurs.
static void _display_error(int line_num, const char* info, gnsdk_error_t error_code) { const gnsdk_error_info_t* error_info = gnsdk_manager_error_info(); printf("\nerror 0x%08x - %s\n\tline %d, info %s\n", error_code, error_info->error_description, line_num, info); } static int _init_gnsdk(const char* client_id, const char* client_id_tag, const char* client_app_version, const char* license_path, gnsdk_user_handle_t* p_user_handle) { gnsdk_manager_handle_t sdkmgr_handle = GNSDK_NULL; gnsdk_error_t error = GNSDK_SUCCESS; gnsdk_user_handle_t user_handle = GNSDK_NULL; gnsdk_str_t serialized_user = GNSDK_NULL; /* Initialize the GNSDK Manager */ if ((error = gnsdk_manager_initialize(&sdkmgr_handle, license_path, GNSDK_MANAGER_LICENSEDATA_FILENAME)) != GNSDK_SUCCESS) { _display_error(__LINE__, "gnsdk_manager_initialize()", error); } /* Initialize the MusicID Library */ else if ((error = gnsdk_musicid_initialize(sdkmgr_handle)) != GNSDK_SUCCESS) { _display_error(__LINE__, "gnsdk_musicid_initialize()", error); } else if (( error = gnsdk_manager_user_register(GNSDK_USER_REGISTER_MODE_ONLINE, client_id, client_id_tag, client_app_version, &serialized_user)) != GNSDK_SUCCESS) { _display_error(__LINE__, "gnsdk_manager_user_register()", error); } else if (( error = gnsdk_manager_user_create(serialized_user, client_id, &user_handle)) != GNSDK_SUCCESS) { _display_error(__LINE__, "gnsdk_manager_user_create()", error); } if (error != GNSDK_SUCCESS) _shutdown_gnsdk(user_handle); else *p_user_handle = user_handle; return error; }
Code the Lookup Function
The _query_album_lookup
function looks up an album using a track title ("I Wonder"), which returns "Graduation" by Kanye West. This function uses what are called "GDOs" (Gracenote Data Objects) that receive both metadata and queries. GDOs are an important part of the GNSDK. To find out more about them, see About Gracenote Data Objects (GDOs).
static void _query_album_lookup( gnsdk_user_handle_t user_handle) { gnsdk_error_t error = GNSDK_SUCCESS; gnsdk_musicid_query_handle_t query_handle = GNSDK_NULL; gnsdk_gdo_handle_t response_gdo = GNSDK_NULL; gnsdk_gdo_handle_t album_gdo = GNSDK_NULL; gnsdk_uint32_t count = 0; printf("\nMusicID Text Search Query\n"); /* Create the query handle */ if ((error = gnsdk_musicid_query_create(user_handle, GNSDK_NULL, GNSDK_NULL, &query_handle)) == GNSDK_SUCCESS) { if ((error = gnsdk_musicid_query_set_text( query_handle, GNSDK_MUSICID_FIELD_TITLE, "I Wonder")) != GNSDK_SUCCESS) { _display_error(__LINE__, "gnsdk_musicid_query_set_text()", error); } else if ((error = gnsdk_musicid_query_find_albums(query_handle, &response_gdo)) != GNSDK_SUCCESS) { _display_error(__LINE__, "gnsdk_musicid_query_find_albums()", error); } /* Find number of matches */ else if ((error = gnsdk_manager_gdo_child_count(response_gdo, GNSDK_GDO_CHILD_ALBUM, &count)) != GNSDK_SUCCESS) { _display_error(__LINE__, "gnsdk_manager_gdo_child_count(GNSDK_GDO_CHILD_ALBUM)", error); } else if (count == 0) { printf("\nNo albums found for the input.\n"); } /* Get first child Album GDO */ else if ((error = gnsdk_manager_gdo_child_get(response_gdo, GNSDK_GDO_CHILD_ALBUM, 1, &album_gdo)) != GNSDK_SUCCESS) { _display_error(__LINE__, "gnsdk_manager_gdo_child_get(GNSDK_GDO_CHILD_ALBUM)", error); } else { _display_album_gdo(album_gdo); gnsdk_manager_gdo_release(album_gdo); album_gdo = GNSDK_NULL; } } /* Clean up - release the query handle and results */ if (GNSDK_NULL != query_handle) gnsdk_musicid_query_release(query_handle); if (GNSDK_NULL != response_gdo) gnsdk_manager_gdo_release(response_gdo); }
Code the Display Function
This function parses the album title from our returned GDO structure and displays it to the console.
static void _display_album_gdo(gnsdk_gdo_handle_t album_gdo) { gnsdk_error_t error = GNSDK_SUCCESS; gnsdk_gdo_handle_t title_gdo = GNSDK_NULL; gnsdk_cstr_t value = GNSDK_NULL; /* Album Title */ if ((error = gnsdk_manager_gdo_child_get( album_gdo, GNSDK_GDO_CHILD_TITLE_OFFICIAL, 1, &title_gdo )) == GNSDK_SUCCESS) { if ((error = gnsdk_manager_gdo_value_get( title_gdo, GNSDK_GDO_VALUE_DISPLAY, 1, &value )) == GNSDK_SUCCESS) { printf( "%8s %s\n", "Album Title:", value ); } else _display_error(__LINE__, "gnsdk_manager_gdo_value_get()", error); gnsdk_manager_gdo_release(title_gdo); } else _display_error(__LINE__, "gnsdk_manager_gdo_child_get()", error); }
Code the Shutdown Function
This function releases the user object handle and shuts down GNSDK libraries
static void _shutdown_gnsdk(gnsdk_user_handle_t user_handle) { gnsdk_error_t error = GNSDK_SUCCESS; /* Release our user handle */ if ((error = gnsdk_manager_user_release(user_handle)) != GNSDK_SUCCESS) { _display_error(__LINE__, "gnsdk_manager_user_release()", error); } /* Shutdown the libraries * gnsdk_manager_shutdown(); // you only need to call this. It will shut down all open libraries. }
Conclusion
Once you successfully build and run the app, you should see the following output similar to the following:
MusicID Text Search Query Album Title: Graduation
This quick start sample demonstrates only a very small portion of the GNSDK capabilities. Check out the full documentation and the samples included with GNSDK to see how to search for different types of metadata by audio fingerprint, text, or existing file.
Reference
The complete main.c
file should look like this:
#define GNSDK_MUSICID 1 #include "gnsdk.h" // Includes all GN SDK headers /* Standard C headers - used by the sample app, but not required for GNSDK */ #include <stdio.h> #include <string.h> #include <stdlib.h> /* Local function declarations */ static int _init_gnsdk(const char* client_id, const char* client_id_tag, const char* client_app_version, const char* license_path, gnsdk_user_handle_t* p_user_handle); static void _display_error(int line_num, const char* info, gnsdk_error_t error_code); static void _shutdown_gnsdk(gnsdk_user_handle_t user_handle); static void _query_album_lookup(gnsdk_user_handle_t user_handle); static void _display_album_gdo(gnsdk_gdo_handle_t album_gdo); int main(int argc, char* argv[]) { gnsdk_user_handle_t user_handle = GNSDK_NULL; const char* client_id = NULL; const char* client_id_tag = NULL; const char* client_app_version = "1"; const char* license_path = NULL; int rc = 0; if (argc != 4) { printf("\nUsage:\n%s clientid clientidtag license\n", argv[0]); return -1; } client_id = argv[1]; client_id_tag = argv[2]; license_path = argv[3]; /* GNSDK initialization */ if ((rc = _init_gnsdk(client_id, client_id_tag,client_app_version,license_path,&user_handle)) == 0) { _query_album_lookup(user_handle); /* Perform a sample album TOC query */ _shutdown_gnsdk(user_handle); /* Clean up and shutdown */ } return rc; } static void _display_error(int line_num, const char* info, gnsdk_error_t error_code) { const gnsdk_error_info_t* error_info = gnsdk_manager_error_info(); printf("\nerror 0x%08x - %s\n\tline %d, info %s\n", error_code, error_info->error_description, line_num, info); } static int _init_gnsdk(const char* client_id, const char* client_id_tag, const char* client_app_version, const char* license_path, gnsdk_user_handle_t* p_user_handle) { gnsdk_manager_handle_t sdkmgr_handle = GNSDK_NULL; gnsdk_error_t error = GNSDK_SUCCESS; gnsdk_user_handle_t user_handle = GNSDK_NULL; gnsdk_str_t serialized_user = GNSDK_NULL; /* Initialize the GNSDK Manager */ if ((error = gnsdk_manager_initialize(&sdkmgr_handle, license_path, GNSDK_MANAGER_LICENSEDATA_FILENAME)) != GNSDK_SUCCESS) { _display_error(__LINE__, "gnsdk_manager_initialize()", error); } /* Initialize the MusicID Library */ else if ((error = gnsdk_musicid_initialize(sdkmgr_handle)) != GNSDK_SUCCESS) { _display_error(__LINE__, "gnsdk_musicid_initialize()", error); } else if (( error = gnsdk_manager_user_register(GNSDK_USER_REGISTER_MODE_ONLINE, client_id, client_id_tag, client_app_version, &serialized_user)) != GNSDK_SUCCESS) { _display_error(__LINE__, "gnsdk_manager_user_register()", error); } else if (( error = gnsdk_manager_user_create(serialized_user, client_id, &user_handle)) != GNSDK_SUCCESS) { _display_error(__LINE__, "gnsdk_manager_user_create()", error); } if (error != GNSDK_SUCCESS) _shutdown_gnsdk(user_handle); else *p_user_handle = user_handle; return error; } static void _shutdown_gnsdk(gnsdk_user_handle_t user_handle) { gnsdk_error_t error = GNSDK_SUCCESS; /* Release our user handle - note that if updated_serialized_user_string is not null, meaning */ /* the handle had changed during program execution, then you should save it out to disk again */ if ((error = gnsdk_manager_user_release(user_handle)) != GNSDK_SUCCESS) { _display_error(__LINE__, "gnsdk_manager_user_release()", error); } /* Shutdown the libraries */ gnsdk_manager_shutdown(); } static void _query_album_lookup( gnsdk_user_handle_t user_handle) { gnsdk_error_t error = GNSDK_SUCCESS; gnsdk_musicid_query_handle_t query_handle = GNSDK_NULL; gnsdk_gdo_handle_t response_gdo = GNSDK_NULL; gnsdk_gdo_handle_t album_gdo = GNSDK_NULL; gnsdk_uint32_t count = 0; printf("\nMusicID Text Search Query\n"); /* Create the query handle */ if ((error = gnsdk_musicid_query_create(user_handle, GNSDK_NULL, GNSDK_NULL, &query_handle)) == GNSDK_SUCCESS) { if ((error = gnsdk_musicid_query_set_text( query_handle, GNSDK_MUSICID_FIELD_TITLE, "I Wonder")) != GNSDK_SUCCESS) { _display_error(__LINE__, "gnsdk_musicid_query_set_text()", error); } else if ((error = gnsdk_musicid_query_find_albums(query_handle, &response_gdo)) != GNSDK_SUCCESS) { _display_error(__LINE__, "gnsdk_musicid_query_find_albums()", error); } /* Find number of matches */ else if ((error = gnsdk_manager_gdo_child_count(response_gdo, GNSDK_GDO_CHILD_ALBUM, &count)) != GNSDK_SUCCESS) { _display_error(__LINE__, "gnsdk_manager_gdo_child_count(GNSDK_GDO_CHILD_ALBUM)", error); } else if (count == 0) { printf("\nNo albums found for the input.\n"); } /* Get first child Album GDO */ else if ((error = gnsdk_manager_gdo_child_get(response_gdo, GNSDK_GDO_CHILD_ALBUM, 1, &album_gdo)) != GNSDK_SUCCESS) { _display_error(__LINE__, "gnsdk_manager_gdo_child_get(GNSDK_GDO_CHILD_ALBUM)", error); } else { _display_album_gdo(album_gdo); gnsdk_manager_gdo_release(album_gdo); album_gdo = GNSDK_NULL; } } else { _display_error(__LINE__, "gnsdk_musicid_query_create", error); } /* Clean up - release the query handle and results */ if (GNSDK_NULL != query_handle) gnsdk_musicid_query_release(query_handle); if (GNSDK_NULL != response_gdo) gnsdk_manager_gdo_release(response_gdo); } static void _display_album_gdo(gnsdk_gdo_handle_t album_gdo) { gnsdk_error_t error = GNSDK_SUCCESS; gnsdk_gdo_handle_t title_gdo = GNSDK_NULL; gnsdk_cstr_t value = GNSDK_NULL; printf("\nIn display_album_gdo\n"); /* Album Title */ if ((error = gnsdk_manager_gdo_child_get( album_gdo, GNSDK_GDO_CHILD_TITLE_OFFICIAL, 1, &title_gdo )) == GNSDK_SUCCESS) { if ((error = gnsdk_manager_gdo_value_get( title_gdo, GNSDK_GDO_VALUE_DISPLAY, 1, &value )) == GNSDK_SUCCESS) { printf( "%8s %s\n", "Album Title:", value ); } else _display_error(__LINE__, "gnsdk_manager_gdo_value_get()", error); gnsdk_manager_gdo_release(title_gdo); } else _display_error(__LINE__, "gnsdk_manager_gdo_child_get()", error); }


One of the country's best forwards stars at first-ever women's AFL Europe Combine
Donegal star Geraldine McLaughlin caught the eye, as did recently-retired Kerry ace Sarah Houlihan and Dublin’s Lauren Magee.
by Emma DuffyDONEGAL STAR FORWARD Geraldine McLaughlin dominated the first-ever women’s AFL Europe Combine in Dublin this weekend.
McLaughlin — widely regarded as one of the best ladies football forwards in the country — was the fastest of the 13 players on trial, in the both the 20m sprint (3.22 seconds) and agility test (8.56 seconds), as per the AFL’s official website.
Those times would have placed the 26-year-old second in each test at October’s NAB AFLW Draft Combine in Melbourne, and understandably immediately put her on AFLW recruiters’ radars for the 2021 season.
With lists closed and 18 Irishwomen ready to go for the 2020 season, none of the hopefuls were in a position to be signed this weekend.
Though lethal forward McLaughlin — a 2014 All-Ireland club champion with Termon and two-time Team of the League award recipient — has surely raised interest Down Under, with her kicking skills impressing former Carlton star Ciaran Byrne.
The Louth man “now oversees the women’s Australian Football development programme in Ireland,” according to the AFL website.
Another star forward, recently-retired Kerry ace Sarah Houlihan also caught the eye as she registered a Combine-best level 18 in the YoYo Test (that would have comfortably won the Australian Combine).
Dublin All-Star Lauren Magee, Meath ace Vicki Wall — who flew out to the Melbourne trial with Olivia Divilly and Saoirse Noonan — and Roscommon’s Jenny Higgins were among others to impress.
Several ladies football stars have landed deals through talent-spotting agency CrossCoders, with the AFL now hoping to get involved with overseas recruitment directly.


In the modern information age we live in, we have to protect ourselves from unwanted access from the outside world. Our computers and the websites we use are a gateway into our lives, and we need to be the gatekeepers.
 Here are some of the ways that you can prevent access to your precious information from the comfort of your own screen.
The worst enemy of a information thief is to have awareness over them. Most people are blissfully unaware to the constant problem that is black hat hackers, and not knowing the easy ways to stop their cause.
There are many different ways that a hackers and automated programs can access your computer; both remotely and through physical connections. Here are a few ways to detect and determine what types of infections can harm your computer.


Welcome to Hoffman’s Landscaping and Lawn Services! Our company has been providing quality and professional residential and commercial landscaping and lawn services to the greater Dayton area since 2002. Hoffman’s Landscaping and Lawn Services is deeply rooted in providing our customers with a unique and beautiful landscape, treating each project as if it were our own. Please explore our website to review our services and past projects. We look forward to working with you!
Phone:<PHONE_NUMBER>
Email: hoffmanslandscaping@gmail.com


Salary: $70,000/year ($5,833/month)
Education Level: Bachelor's Degree (4 years)
Description:
Choose!
Salary: $70,000/year ($5,833/month)
Education Level: Bachelor's Degree (4 years)
Description:
Choose!
Salary: $70,000/year ($5,833/month)
Education Level: Bachelor's Degree (4 years)
Description:
Choose!
Salary: $70,000/year ($5,833/month)
Education Level: Bachelor's Degree (4 years)
Description:
Choose!
Salary: $70,000/year ($5,833/month)
Education Level: Bachelor's Degree (4 years)
Description:
Choose!
Salary: $70,000/year ($5,833/month)
Education Level: Bachelor's Degree (4 years)
Description:
Choose!
Salary: $70,000/year ($5,833/month)
Education Level: Bachelor's Degree (4 years)
Description:
Choose!
Salary: $70,000/year ($5,833/month)
Education Level: Bachelor's Degree (4 years)
Description:
Choose!
Salary: $70,000/year ($5,833/month)
Education Level: Bachelor's Degree (4 years)
Description:
Choose!


Genesis 42:25
Then Joseph commanded to fill their sacks with corn, and to restore every man's money into his sack, and to give them provision for the way: and thus did he unto them.


--- layout: archive title: Zulip Chat Archive permalink: /stream/144837-PR-reviews/topic/.23734.20free_ring.20and.20free_comm_ring.html ---
Suggestions / Discussions? Do we like polynomials? @Kevin Buzzard
Isn't a free comm ring an integer polynomial?
they're isomorphic
So why define them twice?
This sounds like an implementation issue to me so I don't think I'll be much help
@Chris Hughes because here we don't need \a
discrete for free_comm_ring \a
to be a comm_ring
Does discrete mean decidable equality?
yes
@Kenny Lau when you write a PR like this you should more clearly state your intention. Github PR's provide a comment field for a reason. I guess your idea is to replace the current data.polynomial
with this implementation?
well I think free_ring
is important in and of itself; I see a lot of work that has to be done if one wants to replace data.polynomial
with this implementation
@Johannes Hölzl don't we like free functors?
He's talking about free_comm_ring
I'm guessing.
Yes, the title is free_comm_ring
. If this is added to mathlib I think we should replace polynomial
and mv_polynomial
otherwise we will have a lot of duplicate work
changed thread title
I am talking about both
I'm already confused about free_abelian_group α
. What's the difference between it at the add_comm_group pi_instance on α → ℤ
?
you need decidable equality on \a
for the latter
Free abelian groups need to be finitely supported functions. So α →₀ ℤ
would be isomorphic.
But decidable equality isn't a very good justification to define things twice.
Where is decidable equality needed?
The support of the sum of two finsupps is the union of the supports. You need decidable equality for union of finsets.
I see, thanks
Kenny I think used multisets, and effectively quotiented by extensionality, and ignoring zeros. I'm not a fan of this approach. I don't think computing on types without decidable equality is very often useful, and you are slowing down the computations quite a bit with this approach I guess as well.
For actual computations, neither approach is much good
we would need an explicit computational type that looks more like some GAP data type
so the "computable" marker is not much more than a gimmick in any case
I think maybe we should just remove the decidable_eq
constraint from finsupp
It depends how hard the computations are.
I think it's one of the factors in why typeclass inference on polynomials is so slow
For provable computations we should use ring
or something that manipulates polynomial expressions
and computability doesn't matter for this
There was some talk about removing finsupp, and replacing it with dfinsupp, which is a quotient and doesn't use decidable equality. In any case, I'm not in favour of having two different versions of the same thing, just because of some decidable equality issue.
I agree there
I don't know whether kenny's latest version of free_comm_ring
is better than polynomial
but there should only be one
Also, I sneaked in some monad instance; should I do that?
free_comm_ring is faster than mv_polynomial in my usecase
{% endraw %}Last updated: Apr 24 2020 at 19:02 UTC


Whidbey GC helps manage non-memory resources
Here. Brad Abrams describes how the Whidbey .NET Framework adds support for tracking unmanaged memory and limited resources of a non-memory nature. The former is handled by informing the GC of added "pressure" associated with unmanaged memory and the latter by exposing the private HandleCollector class that .NET 1.x has used for a while now. It's not reference counting, but it'll do for a start... : )


You are about to reset your password. Once you click reset button you will get temp password to your registered mail.


- [Plessis2010]
Plessis S, Carrasco N and Pernot P (2010).
“Knowledge-based probabilistic representations of branching ratios
in chemical networks: the case of dissociative recombinations.”
J. Chem. Phys., 133, pp. 134110.
doi: 10.1063/1.3479907.
- [Thomas2005a]
Thomas R, Hellberg F, Neau A, Rosén S, Larsson M, Vane C, Bannister M, Datz S, Petrignani A and van der
Zande W (2005).
“Three-body fragmentation dynamics of amidogen and methylene radicals
via dissociative recombination.”
Phys. Rev. A, 71, pp. 032711–16.
http://link.aps.org/abstract/PRA/v71/e032711.
- [Vikor1999]
Vikor L, Al-Khalili A, Danared H, Djurić N, Dunn G, Larsson M, Le Padellec A, Rosén S and Af Ugglas M (1999).
“Branching fractions in the dissociative recombination of NH$_4^+$
and NH$_2^+$ molecular ions.”
Astron. Astrophys., 344, pp. 1027-1033.


{% extends "infopages/infopage-content.html" %} {% block header %}{% include "base/header.html" with h1="Code of Conduct" %}{% endblock header %} {% block info-content %}
At the Beacon Food Forest, we strive to actively create an inclusive and compassionate community.
By joining any of our classes, gatherings or events, you agree to help maintain a safe and welcoming space for all, by adhering to the P-Patch Code of Conduct.
Discriminatory or threatening behaviors can be reported to the work party leader or class facilitator, or directly to our board at<EMAIL_ADDRESS>The Beacon Food Forest is committed to fostering equity, understanding and kindness throughout our community and the world. Please see our conflict resolution policy for our approach to conflict.


Board Game Name stats
Back
Lowest Price: $
0
Average Price: $
0
Median Price: $
0
Modal Price: $
0
Number of Entries:
0
Reset Entries


A port of log4js to node.js
The log level filter allows you to restrict the log events that an appender will record based on the level of those events. This is useful when you want most logs to go to a file, but errors to be sent as emails, for example. The filter works by wrapping around another appender and controlling which events get sent to it.
type
- logLevelFilter
appender
- string
- the name of an appender, defined in the same configuration, that you want to filterlevel
- string
- the minimum level of event to allow through the filtermaxLevel
- string
(optional, defaults to FATAL
) - the maximum level of event to allow through the filterIf an event’s level is greater than or equal to level
and less than or equal to maxLevel
then it will be sent to the appender.
log4js.configure({
appenders: {
everything: { type: 'file', filename: 'all-the-logs.log' },
emergencies: { type: 'file', filename: 'panic-now.log' },
just-errors: { type: 'logLevelFilter', appender: 'emergencies', level: 'error' }
},
categories: {
default: { appenders: ['just-errors', 'everything' ], level: 'debug' }
}
});
Log events of debug
, info
, error
, and fatal
will go to all-the-logs.log
. Events of error
and fatal
will also go to panic-now.log
.


The Eventful Notes Client
There have been many attempts to explain what Lotus Notes is. I'd like to add my own - from the perspective of software development:
. Some examples of events are: Database opened, Default value of a field, Saving a document etc. There are MANY events and the knowledge how to use what event and when makes the Notes developer <g>
I assembled a small database with one outline, one page, one frameset, two views, one form, one subform and a few fields. I "mined" almost every event I could find with prompts to determine the sequence of the events firing (I didn't mine Hide-when formulas, the onKey..., onMouse... and onChange events).
After putting all the events into code I performed the following actions, starting with the empty database:
Update: Also checkout Part 2 of the story.
Some interesting factoids:
Lotus Notes is an event engine that provides the developer with the capability to assemble an application from predefined events and react to them.
The languages available to react to events are: @Formula, LotusScript, JavaScript, Java, C/C++. The selection of available languages depends on the event you want to react on.. Some examples of events are: Database opened, Default value of a field, Saving a document etc. There are MANY events and the knowledge how to use what event and when makes the Notes developer <g>
I assembled a small database with one outline, one page, one frameset, two views, one form, one subform and a few fields. I "mined" almost every event I could find with prompts to determine the sequence of the events firing (I didn't mine Hide-when formulas, the onKey..., onMouse... and onChange events).
After putting all the events into code I performed the following actions, starting with the empty database:
- Open the database (into the frameset)
- Switch from the View "$All" to the View "SecondView"
- Create one document "EventSample"
- Fill all fields with values
- Press F9 to recompute
- Change one more value
- Press Ctrl+S to save
- Close the document
- Repeat Step 3-8
- Select the View "$All"
- Delete the current document (Del key)
- Select the next document
- Select the deleted document
- Undelete the document
- Close the database
Update: Also checkout Part 2 of the story.
Some interesting factoids:
- The events fire a little off: QueryOpen of a view fires before the PostOpen of the database
- Input translation events fire with the formulas of computed fields. Input validation after that in their own sequence
- Subform events, even the JSHeader, fire after the form name has been identified
- Web only events don't fire in the client
- The QueryDocumentDelete also fires if you don't have the right to delete
- Terminate is really the last thing to fire, however the interesting objects are out of scope then
Posted by Stephan H Wissel on 06 July 2007 | Comments (2) | categories: Show-N-Tell Thursday


-
Staten Island Pediatric Dentistry
A site redesign project, still in development, currently on hold pending client content.
Project Scope: Web Development and Web Design
Languages: HTML, CSS3
http://staging.dcartdevelopment.com/sipd/ -
Pristine Credit Solutions
Client site I am working on that is still under development. The project currently on hold pending client content.
Project Scope: Web Development and Web Design
Languages: HTML, PHP, CSS3, jQuery, Javascript
http://staging.dcartdevelopment.com/pristinecredit/index -
Teen Vogue Insider
I was brought on as an extra resource to meet a deadline. I joined the development team, my roles was to flesh out some of the pages of the mobile app.
Project Scope: Web Development
Languages: HTML5, CSS3
https://itunes.apple.com/us/app/teen-vogue-insider/id522257705?mt=8


--- title: Treeview section: Clay Admin (Cadmin) ---
The class `show-component-expander-on-hover` displays the `component-expander` when the mouse hovers over the `treeview` component.


ContactPlugin that interfaces with obstacles, and provides contact points between obstacles and other components of the World. There exists one copy of this plugin for each obstacle, so each contact sensor is independent of any other.
More...
#include "include/contact_plugin.hpp"
|
| virtual void | Load (sensors::SensorPtr _sensor, sdf::ElementPtr _sdf) |
| |
- internal Gazebo callback when the plugin has been loaded
More...
|
| |
|
|
void | OnUpdate () |
| | Callback function for each time the sensor updates.
|
| |
ContactPlugin that interfaces with obstacles, and provides contact points between obstacles and other components of the World. There exists one copy of this plugin for each obstacle, so each contact sensor is independent of any other.
| void gazebo::ContactPlugin::Load |
( |
sensors::SensorPtr |
_sensor, |
|
|
sdf::ElementPtr |
_sdf |
|
) |
| |
|
virtual |
- internal Gazebo callback when the plugin has been loaded
- Parameters
-
| _sensor | - reference to the sensor |
| _sdf | - reference to the sdf model |
The documentation for this class was generated from the following files:
- /root/workspace/src/amazon_project/include/contact_plugin.hpp
- /root/workspace/src/amazon_project/src/contact_plugin.cpp


Mourinho Breaks The Internet Following Spurs Appointment!
by SL SocialIn news that completely rocked the football world, Jose Mourinho’s appointment as the new Tottenham Hotspur head coach sent social media into a frenzy. Have you seen some of the reactions?
It can be said that football is not the same without The Special One, with the Portuguese man offering his professional opinions as a pundit before becoming the Spurs manager on Wednesday morning.
Mourinho joining the London-based side will see him now manage his third different English club, having previously mentored both Chelsea and Manchester United.
Download The Soccer Laduma Social Media App & Earn Airtime for Selfies!
Since the announcement was made, social media was left a buzz as fans flocked to Twitter in sharing their opinions, memes and banter.
Here are some of the best reactions:
Do you think Mourinho will be a success at Spurs?


Bottom translator 1.0
Enter text below, then press either of the aptly titled buttons to
translate it. Any valid UTF-8 can be translated, with a highly efficient
encoding ratio of approximately 1
: 20 between input and output
bytes. The translator is implemented in rust (btw) and runs in the browser
using WASM, so it's super fast.


Play Framework Primer - Routing
23 Jun 2019This is part 2 of a series about basics of Play framework. In part 1, we scaffolded a play application using the playframework/play-scala-seed.g8
template and discussed the components in the resulting directory structure.
In this article, we will explore the basics of routing in Play.
What is routing
With any MVC framework like Play, an application follows a pre-defined structure and any component you create falls in one of 3 categories i.e. models, views or controllers.
Models for your domain objects, views for display and user interaction and controllers for business logic that receives input/requests and renders a view to give a response.
Each controller is a file that contains different units of logic called actions. Let’s look at the controller from our first article:
The method def index()
is a controller action. We can have an arbitrary number of actions in a controller, conventionally processing logic around a particular model.
Depending on the http request coming in, Play has to be able to map or translate it to the right controller action.
How we help Play do this is by creating routes which consist of mainly 3 parts: an http Method, a URI pattern and a call definition respectively on a single line, space delimited.
Below is the content of the routes file in our first article:
As you can see, we are telling Play framework that whenever a GET
request comes in at relative URL /
i.e. the root of the page, invoke the index
action on the HomeController
.
Also note that the call definition has to be the fully qualified class name of the controller class.
Each http request is seen as an event to react to by Play framework. The global method Global.onRouteRequest
is the callback method Play invokes to route the request.
This method ultimately uses a compiled version of the routes file along with Play’s in-built router to map request to action. This is a ripe area for customization(future article alert :)).
The routes file
In a basic Play application, the app/conf/routes
file is consulted by the play router to know which controller action to invoke when an http request is received.
This file is compiled when the application is building and any errors in it are forwarded directly to the client e.g. browser, curl, postman etc.
Just like in class files, the routes file can contain comments prepended with a pound/hash symbol:
Route types
A route declation defines a path the incoming request should follow. Play framework provides different ways we can declare a route to serve both simple and more complex use cases.
Static path
A static path matches an exact URI pattern. No further logical processing happens when such a path is matched. This means there can only ever be one URL string in the incoming request that can match this path.
Am assuming your project from the first article is running and when you visit http://localhost:9000
, the browser renders Hello world
The path we saw in the previous section is such an example. I think being the root path, it may be a bit confusing as /
. Let’s change this such that our URI pattern is /home
:
Now when we save in auto-reloading mode and visit http://localhost:9000/home
, we should still see Hello world
rendered.
Only typing http://localhost:9000/home
will ever match this route since it’s static. Contrasting with the dynamic path in the next subsection will make it clearer in case it is not.
Further more, notice that if we now visit http://localhost:9000
, we will see an error in the browser like Action Not Found
since we changed the route declaration.
Dynamic path, single path segment
Remember how we loaded a config value from the app/conf/Application.conf
file in the first article? Well that assumed that our config value would not change from request to request.
Now, if we want Play to process the request depending on a value we provide at request time, we can use a dynamic path. For that let us create another controller action to greet people from different planets. New controller code:
Declare the new route in the routes file:
When you save and visit http://localhost:9000/home/earth
in the browser, you should now see Hello earth
. If you replace earth
in the address bar with moon
, you should see Hello moon
.
You can have more than 1 dynamic part in the URI. Let’s update the controller with a new method:
And update the routes file with a new dynamic route:
Now visit http://localhost:9000/home/mars/french
, the browser should render Hello mars in french
.
Likewise you can mix both dynamic and static parts in the URI in any order, e.g. /home/:planet/english
.
Just make sure the number of parameters in the action match those coming in or provide a default value for parameters not provided in the URI or which are optional.
Dynamic path, arbitrary path segments
When you we wanted to add language in the path above, we had to declare a parameter in both action and URI declaration.
What if, for some arbitrary reason, we now want to allow the user to specify whether American or British in case the language is English but we don’t want other users that are used to the API to be affected.
We can define the dynamic part using the *id
syntax instead of the :id
syntax. The former accepts any number of path segments.
For instance, with the following route:
If we visited http://localhost:9000/home/earth/english/american
, then we would get the Action Not Found
error rendered in the browser.
But if we changed the route to:
Then the browser would render Hello earth in english/american
. This way, we can choose how to process the english/american
in the action while Hello mars in french
greetings remain unaffected.
Note that the Play Documentation clearly states that this kind of parameter is not decoded by the router so it’s your responsibility to validate and parse it. For example, it should not contain multiple leading slashes or non-ASCII characters.
Dynamic path, regex
Regex is used to match text. Play provides a way for us to restrict what would be a valid path segment using regex.
Let’s say we only want to greet in 2 languages i.e. english and french, and we want to make sure the user provides the whole word i.e. english and not en, french and not fr as Hello earth in en
would not make much sense in this context.
We can use the /$id<regex>
syntax in this case. Let’s update our internationalized greeting route to the following:
Now if we visit the site with a different language e.g. http://localhost:9000/home/earth/german
we will get Action Not Found for request /home/earth/german
, similarly http://localhost:9000/home/earth/en
will fail.
Only http://localhost:9000/home/earth/english
and http://localhost:9000/home/earth/french
will pass.
Dynamic path, assets
Play, like any useful web framework, gives us an idiomatic way to declare file download paths. This will enable us to download physical files from the server in the public directory.
Remember from the previous article, we discussed the public folder and its content.
As a first example, assume we want to download files from the app/public/images/
directory, we would declare a route using the /assets/*id
syntax.
Remember this syntax enables us to match an arbitrary number of path segments since there could be subdirectories in the app/public/images/
directory e.g. for app/public/images/avatars
. You can organize the app/public
folder the way you prefer:
Remember the syntax for the call definition? yes, Play ships with an inbuilt controller called Assets, which has an action called versioned
that takes 2 parameters as seen above: a root path which defaults to /public
and a file of param of type Asset
.
Now you can download any file in any subdirectory in the /public
directory e.g. http://localhost:9000/assets/images/favicon.png
.
Route Parameters
As we saw in the previous section, you can provide parameters in your URL that are searched for by the router to supply the controller action. We only saw path parameters e.g. http://localhost:9000/home/earth/english
.
Let’s look at another type of URI parameters in the form of query parameters.
Query Parameters
Just like path parameters, query parameters are used to send dynamic data from the client to the server. However, query parameters are named in the browser URL but path params are named in the URI path in the route definition.
Query parameters take the form of a query string appended to the path using a ?
sign, each query param is then added in name=value
form.
Say we want to add language parameter as a query parameter, our URL would be http://localhost:9000/home/earth?language=english
. To add more query params to the query string, we append the name-value pair with an ampersand (&) e.g. http://localhost:9000/home/earth?language=english&variant=american
.
Path parameters directly affect the mapping of request to a route. What I mean is that in the previous example, if I loaded http://localhost:9000/home/earth/english
yet my route is as follows:
then I would get an Action Not Found
error because there is an additional path seqment in my request which is not catered for in the route definition.
However, if I the path parameters are valid e.g. http://localhost:9000/home/earth
and I add a query string e.g. http://localhost:9000/home/earth?language=english
, it will not block the request from succeeding, even without any change to our code.
There is nothing special to do so as to access query parameters. Take a look at the following route:
The call definition has a controller action that takes 2 parameters i.e. planet
and language
, so the router will search for these in both the path and query params. Before invoking the action.
So when we load http://localhost:9000/home?planet=mars&language=english
the browser will render Hello mars in english
. One important fact is that if a param is provided in both path and query params, then the router will take the one in path.
To demonstrate, strip down the routes file to only have one route:
So planet
is provided in the URI pattern. Now let’s load http://localhost:9000/home/earth?planet=mars&language=english
. As you can notice, planet is available in both in path and query, but when it loads, the browser renders Hello earth in english
.
The final thing is that if a parameter is not captured in URI pattern and also does not appear in the query string, then Play will render a Bad Request
error.
Typing Parameters
You may have noticed that our parameters in the call definition are not typed:
Both planet
and language
don’t have type information. The play router will default to String
type. In case you want a specific type, then you may have to declare that in the call definition.
For example, if you added a new action called sum
which adds the 2 parameters it receives, you’d have to add the types as well like below:
And invoke them as http://localhost:9000/sum?x=3&y=8
Parameters with default values
Sometimes you want to provide a fallback value incase a parameter is not provided, take our internationalized greeting route for example:
Here, we have to provide both planet
and language
in the query string http://localhost:9000/home/earth?planet=mars&language=english
.
If we eliminate the language like so http://localhost:9000/home/earth?planet=mars
, we will get an error Bad Request For request 'GET /home?planet=mars' [Missing parameter: language]
.
However, in the real world, we may want to greet in english in case the user does not provide the language
param, in that case, we provide this value in the call definition using the ?=
operator:
Parameters with fixed values
In case you want to fix a parameter value such that it disregards any user provided value, then it is possible, similar to providing a default value.
Someone would wonder why we’d do that since if we don’t want a user to take a user’s input, we could just not pick the value from a parameter but rather from the config.
One scenario I can think of when this could come in handy is if our internationalized greeting was a public API and several clients were already consuming it.
Assume we wanted to temporarily restrict it only to English perhaps because we are fixing the French language translations. We would not have the luxury to remove it from the param list as this would break all existing clients.
We also don’t wan’t to just ignore it in code like so:
This would work technically but it would cause a lot of confusion especially if there are many developers going to work with the codebase, the confusion is because the error is in routing but we are fixing it in the controller by ignoring a variable.
Secondly unused variables are a code smell.
Why not make the change closer to the error, perhaps with a comment for clarity:
Notice that we use =
operator for fixed parameters
Optional parameters
We can also declare a parameter as optional by using Scala’s Option
monadic type such that if a user does not provide a value, the clients don’t break:
We also make a similar change in the controller action:
This way, we can handle a case where the value is not provided in a smart way.
Conclusion
In this article, we have explored basics of routing in Play framework. You should be able to leverage routing at this stage to handle most common scenarios in a web application.


What if?
Other comparisons of these cases
Note that these links won't work if you have too many cases in the table. How many is too many depends on the browser you are using.
- Compare carbon prices
- Compare natural gas consumption
- Compare electricity generation.
- Compare electricity build_rates.
- Compare annual investment in electricity generation.


--- layout: post title: Cold fusion 5 - Verity 2K tags: [] status: publish type: post published: true meta: {} ---
As of CF5.0, the engine shipped with the application server is Verity 2K. By default this engine is not enabled and thus the application server still makes use of the VDK (Verity Developer Kit).
To improve performance and take advantage of it?s ability to index more document types (such as PDFs) it is highly recommended to switch to Verity 2K mode. However this is services is not enabled and requires manual configuration and starting (read edit a .ini file and start the service).
Some limitations of Verity are:
So step 1 is to find the k2server.ini file and edit it:
Location of k2server.ini file = c:\cfusion\verity\
It's default settings are:
## portNo: TCP port number for client connections.
portNo=9901
## Each Collection section controls each collection
## and search service configured for the server
##
## Collection Path Examples:
## Assume there is the collection called "myCollection"
## created by ColdFusion.
##
## The following [coll-0] and [coll-1] collection sections
## register the collections created by ColdFusion.
##
## The "collAlias" entry is the collection alias name
## which is the collection name used by CFSEARCH CFML tag.
## (i.e. "myCollection_file" and "myCollection_custom")
##
## Make sure that the CFSEARCH tag parameter "external" is set to "No"
## and that the collection alias name is unique and not the same
## as any existing collection names managed by ColdFusion.
##
##[Coll-0]
##collPath=c:\cfusion\verity\collections\mycollection\file
##collAlias=myCollection_file
##topicSet=
##knowledgeBase=
##onLine=2
##[Coll-1]
##collPath=c:\cfusion\verity\collections\mycollection\custom
##collAlias=myCollection_custom
##topicSet=
##knowledgeBase=
##onLine=2
The only thing I changed for my local test was to create a collection. This was going to be aptly named: myCollection
[Coll-0]
collPath=c:\cfusion\verity\collections\myCollection
collAlias=myCollection
topicSet=
knowledgeBase=
onLine=2
Since there were no instructions on whether or not to create the folders I referenced here I didn't do it and proceeded to start the Verity 2k server. Again the documentation is slightly off for Windows as the executable for my installation was located in the same folder as my .ini file. So go to the command prompt and type in the following command:
2kserver iniFile 2kserver.ini
Now I am not too keen on manually starting processes, so I decided to make use of service configuration option.
k2server -iniFile k2server.ini -ntService 1
And this is the output to be displayed
K2SERVER - Verity, Inc. Version 2.20pr6
k2server Created
Starting k2server Now...
k2server Started
Now of course it's easy to stop and start the service through your usual techniques from the command line the stop/start commands would look as follows:
net stop "k2server"
net start "k2server"
Now all we need to is tell the Cold Fusion Administrator that a 2kserver is running and you do that by logging on and specifying the server name and port number after selecting the "Verity server" option from the menu (it's under Data Sources). In my case it was localhost as it was my dev machine and 9901 for the port number (taken from the 2kserver.ini file).
OK so far so good, the server is running, Cold Fusion knows about it's existence, next time we'll look into testing the installation.


Tuesday, May 12, 2015
Hardening Framework supports Puppet 4
We are happy to announce Puppet 4 support for the Hardening Framework. All puppet modules have been updated and are continously tested for Puppet 4 support, now:
- Puppet OS Hardening
- Puppet SSH hardening
- Puppet MySql Hardening
- Puppet Postgres Hardening
- Puppet Apache Hardening
- Puppet Nginx Hardening
In addition to Puppet 4, we still test our implementation against Puppet 2.7 & Puppet 3.6. This enables you to smoothly upgrade the Hardening Framwork.
In case you are not familiar with Puppet 4 yet, we recommend the great presentation about Puppet 4 features by Martin Alfke:
Stay tuned and follow us on Twitter.


Dynamic and animated list
{{ n }}
{{ countdown.length == 10 ? 'launch missile' : '...'}}
Reacting to events.
Toast Bread
Two-way data binding.
Toast Bread
Quantity to put in the oven: {{ toastedBreads }}
More interactive worlds.
{{ world }} --> click to destroy
Discover


We are the Sigma Chapter of Alpha Chi Sigma at the University of California, Berkeley.
Learn Moreits members with a tie of true and lasting friendship.
for the advancement of chemistry both as a science and as a profession.
its members by every honorable means in the attainment of their ambitions as chemists throughout their mortal lives.


0.3.6 2009-09-14
- Added -B CLI option to use the :body authentication scheme (Seth)
- Respect `—method` in `authorize` CLI command (Seth)
- Support POST and PUT with raw bodies (Yu-Shan Fung et al)
- Test clean-up (Xavier Shay, Hannes Tydén)
- Added :ca_file consumer option to allow consumer specific certificate
override. (Pelle)
0.3.5 2009-06-03
- `query` CLI command to access protected resources (Seth)
- Added -H, -Q CLI options for specifying the authentication scheme (Seth)
- Added -O CLI option for specifying a file containing options (Seth)
- Support streamable body contents for large request bodies (Seth Cousins)
- Support for OAuth 1.0a (Seth)
- Added proxy support to OAuth::Consumer (Marshall Huss)
- Added —scope CLI option for Google‘s ‘scope’
parameter (Seth)
0.3.4 2009-05-06
0.3.3 2009-05-04
- Corrected OAuth XMPP namespace (Seth)
- Improved error handling for invalid Authorization headers (Matt Sanford)
- Fixed signatures for non-ASCII under $KCODE other than ‘u’
(Matt Sanford)
- Fixed edge cases in ActionControllerRequestProxy where params were being
incorrectly signed (Marcos Wright Kuhns)
- Support for arguments in OAuth::Consumer#get_access_token (Matt Sanford)
- Add gem version to user-agent header (Matt Sanford)
- Handle input from aggressive form encoding libraries (Matt Wood)
0.3.2 2009-03-23
- 2xx statuses should be treated as success (Anders Conbere)
- Support applications using the MethodOverride Rack middleware (László
Bácsi)
- `authorize` command for `oauth` CLI (Seth)
- Initial support for Problem Reporting extension (Seth)
- Verify SSL certificates if CA certificates are available (Seth)
- Fixed ActionController
parameter escaping behavior (Thiago Arrais, László Bácsi, Brett Gibson,
et al)
- Fixed signature calculation when both options and a block were provided to
OAuth::Signature::Base#initialize (Seth)
- Added help to the ‘oauth’ CLI (Seth)
- Fixed a problem when attempting to normalize MockRequest URIs (Seth)
0.3.1 2009-1-26
- Fixed a problem with relative and absolute token request paths. (Michael
Wood)
0.3.0 2009-1-25
- Support ActionController::Request from Edge Rails (László Bácsi)
- Correctly handle multi-valued parameters (Seth)
- Added normalized_parameters to OAuth::RequestProxy::Base
(Pelle)
- OAuth::Signature.sign and friends now yield the RequestProxy instead of the
token when the passed block‘s arity is 1. (Seth)
- Token requests are made to the configured URL rather than generating a
potentially incorrect one. (Kellan Elliott-McCrea)
- Command-line app for generating signatures. (Seth)
- Improved test-cases and compatibility for encoding issues. (Pelle)
0.2.7 2008-9-10 The lets fix the last release release
- Fixed plain text signatures (Andrew Arrow)
- Fixed RSA requests using OAuthTokens. (Philip Lipu Tsai)
0.2.6 2008-9-9 The lets RSA release
- Improved support for Ruby 1.8.7 (Bill Kocik)
- Fixed RSA verification to support RSA providers now using Ruby and RSA
- Improved RSA testing
- Omit token when signing with RSA
- Added support for ‘private_key_file’ option for RSA signatures
(Chris Mear)
- Fixed several edge cases where params were being incorrectly signed (Scott
Hill)
- Fixed RSA signing (choonkeat)
0.2.2 2008-2-22 Lets actually support SSL release
0.2 2008-1-19 All together now release
This is a big release, where we have merged the efforts of various parties
into one common library. This means there are definitely some API changes
you should be aware of. They should be minimal but please have a look at
the unit tests.
0.1.2 2007-12-1
- Fixed checks for missing OAuth params to improve performance
- Includes Pat‘s fix for getting the realm out.
0.1.1 2007-11-26


{% extends 'base.html' %} {% block title %}Dashboard | Bear Blog{% endblock %} {% block nav %}{% include '../snippets/dashboard_nav.html' %}{% endblock %} {% block content %}
{% for error_message in error_messages %}
{{ error_message }}
{% endfor %}
The DNS records for {{ blog.domain }} have not been set up.
| Type | Name | Content | TTL |
|---|---|---|---|
| CNAME | {{ blog.blank_domain }} | domain-proxy.bearblog.dev | 3600 |
If you're using Cloudflare turn off the proxy (the little orange cloud).
It may take some time for the DNS records to propagate.
Having issues?


from item: {{item | json}}
from messages: {{messages | json}}
switch: {{switched ? "on" : "off" | json}}
radio: {{picked | json}}
Checked names: {{ checkedNames | json }}


Review of Testability¶
This chapter presents some design rework and implementation rework for testability purposes. While testability is very important, new programmers can be slowed to a crawl by the mechanics of building test drivers and test cases. We prefer to emphasize the basic design considerations first, and address testability as a feature to be added to a working class.
In Test Scaffolding we’ll look at the basic software components required to build unit tests.
One approach is to write tests first, then create software that passes the tests. We’ll look at this in Test-Driven Design.
The application works with random numbers. This is awkward for testing purposes. We’ll show one approach to solving this problem in Capturing Pseudo-Random Data.
We’ll touch on a few additional topics in Testability Questions and Answers.
In Testability Deliverables we’ll enumerate some deliverables that will improve the overall quality of our application.
We’ll look a little more deeply at random numbers in Appendix: On Random Numbers.
Test Scaffolding¶
Without pausing, we charged past an elephant standing in the saloon. It’s time to pause a moment a take a quick glance back at the pachyderm we ignored.
In the Roulette Game Class we encouraged creating a stub Player
class and
building a test that integrated the Game
, Table
, Wheel
,
and the stub Player
class into a kind of working application.
This is an integration test, not a proper unit test.
We’ve integrated our various classes into a working whole.
While this integration test reflects our overall goals, it’s not always the best way to assure that the individual classes work in isolation. We need to refine our approach somewhat.
Back in Wheel Class we touched on the problem of testing an application that includes a random number generator (RNG). There are two questions raised:
How can we develop formalized unit tests when we can’t predict the random outcomes? This is a serious testability issue in randomized simulations. This question also arises when considering interactive applications, particularly for performance tests of web applications where requests are received at random intervals.
Are the numbers really random? This is a more subtle issue, and is only relevant for more serious applications. Cryptographic applications may care more deeply about the randomness of random numbers. This is a large subject, and well beyond the scope of this book. We’ll just assume that our random number generator is good enough for statistical work. It must be consistently difficult to predict, but also as fair as the real world.
To address the testing issue, we need to develop some scaffolding that permits more controlled testing. We want to isolate each class so that our testing reveals problems in the class under test.
There are two approaches to replacing the random behavior with something more controlled.
One approach is to create a mocked implementation of
random.Random
that returns specific outcomes that are appropriate for a given test.A second approach is to record the sequence of random numbers actually generated from a particular seed value and use this to define the expected test results. We suggested forcing the seed to be 42 with
wheel.rng.seed(42)
.
Test-Driven Design¶
Good testability is achieved when classes are tested in isolation
and there are no changes to the class being tested.
We have to be careful that our design for the Wheel
class
works with a real random number generator as well as a mocked
version of a random number generator.
To facilitate this, we suggested making the
random number generator in the Wheel
class visible. Rather than
have a Wheel
instance use the random
module directly, we
suggesting creating an instance of the random.Random
class as an
attribute of each Wheel
instance.
This design choice reveals a tension between the encapsulation principle and the testability principle.
By Encapsulation we mean the design strategy where we define a class to
encapsulate the details of it’s implementation. It’s unclear if the
random number generator is an implementation detail or an explicit part
of the Wheel
class implementation.
By Testability we mean a design strategy where we can easily isolate each class for unit testing. This is sometimes achieved by using complex dependency injection. For testing, mock classes are injected; for real use, the real classes are injected. The dependency injection machinery in other languages is designed around the requirements of the compiler. Python doesn’t really need complex injection tools.
Generally, for must of the normal use cases, the random
number generator inside a Wheel
object is an invisible implementation detail.
However, for testing purposes, the random number generator needs to be a configurable feature
of the Wheel
instance.
One approach to making something more visible is to provide
default values in the constructor for the object. The following example
provides an rng
parameter to permit inserting a mocked random
number generator.
Wheel with Complex Initialization
class Wheel_RNG:
def __init__(self, bins: List[Bin], rng: random.Random=None) -> None:
self.bins = bins
self.rng = rng or random.Random()
def choose(self) -> Bin:
return self.rng.choice(self.bins)
For this particular situation, this technique is noisy. It introduces a feature that we’ll never use outside writing tests. The choice of a random number generator is made infrequently; often the choice is made only once when a generator with desired statistical properties is identified.
Because Python type checking happens at run time, it’s easier to patch a class as part of the unit test.
Here’s a simpler Wheel
class definition with simpler
initialization.
Wheel with Simpler Initialization
class Wheel:
def __init__(self, bins: List[Bin]) -> None:
self.bins = bins
self.rng = random.Random()
def choose(self) -> Bin:
return self.rng.choice(self.bins)
Since we can inject anything as the random number generator in a Wheel
instance,
our unit tests can look like this:
Mock Object Testing
def test_wheel_isolation():
mock_rng = Mock(
choice=Mock(return_value="bin1")
)
bins = ["bin1", "bin2"]
wheel = Wheel(bins)
wheel.rng = mock_rng # Replaces random.Random
value = wheel.choose()
assert value == "bin1"
mock_rng.choice.assert_called_with(bins)
This function creates a mocked instance of the random.Random
class.
The mock defines a choice()
method; this method always returns
the same value.
The test case builds a number of mocked Bin
instances. In this
case, we don’t even use the Bin
class definition, we can use
a simple string object.
The Wheel
instance is built from the mocked bins. The rng
attribute is then patched to use the mocked random number generator.
After the patch is applied, we can exercise the Wheel.choose()
method
to confirm that it properly uses the random number generator’s choice()
method.
Capturing Pseudo-Random Data¶
The other approach – using a fixed seed – means that we need to build and execute a program that reveals the fixed sequence of spins that are created by the non-random number generator.
We can create an instance of Wheel
class. We can set the
random number generator seed to a known, boring value, like 42
.
When can call the Wheel.choose()
method six
times, and print the winning Bin
instances. This
sequence will always be the result for a seed value of 42
.
This discovery procedure will reveal results needed to
create unit tests for Wheel
class and anything that uses
it, for example, Game
.
Repeatable Random Sequences
"""
Building Skills in Object-Oriented Design V4
Demo of repeatable random tests.
"""
import random
from collections import Counter
def dice():
return random.randint(1,6), random.randint(1, 6)
def dice_histogram(seed: int=42, samples: int=10_000) -> Counter:
"""
Generate a lot of random numbers.
>>> c = dice_histogram()
>>> c.most_common(5)
[(7, 1704), (8, 1392), (6, 1359), (9, 1116), (5, 1094)]
"""
random.seed(seed)
c = Counter(
sum(dice()) for _ in range(samples)
)
return c
Testability Questions and Answers¶
Why are we making the random number generator more visible? Isn’t object design about encapsulation?
Encapsulation isn’t exactly the same thing as “information hiding”. For some people, the information hiding concept can be a useful way to begin to learn about encapsulation. However, information hiding is often taken to extremes.
In this case, we want to encapsulate the bins of the wheel and the procedure for selecting the winning bin into a single object. However, the exact random-number generator (RNG) is a separate component, allowing us to bind any suitable RNG.
Consider the situation where we are generating random numbers for a cryptographic application. In this case, the built-in random number generator may not be random enough. In this case, we may have a third-party Super-Random-Generator that should replace the built-in generator. We would prefer to minimize the changes required to introduce this new class.
Our initial design has isolated the changes to the
Wheel
class, but required us to change the constructor. Since we are changing the source code for a class, we must to unit test that change. Further, we are also obligated unit test all of the classes that depend on this class. Changing the source for a class deep within the application forces us to endure the consequence of retesting every class that depends on this deeply buried class. This is too much work to simply replace one object with another.We do, however, have an alternative. We can change the top-level
main()
method, altering the concrete object instances that compose the working application. By making the change at the top of the application, we don’t need to change a deeply buried class and unit test all the classes that depend on the changed class. Instead, we are simply choosing among objects with the same superclass or interface.This is why we feel that constructors should be made very visible using the various design patterns for Factories and Builders. Further, we look at the main method as a kind of master Builder that assembles the objects that comprise the current execution of our application.
See our Roulette Solution Questions and Answers FAQ for more on this subject.
Looking ahead, we will have additional notes on this topic as we add the SevenReds Player Class subclass of
Player
class.
If setting the seed works so well, why use a mock object?
While setting the seed is an excellent method for setting up a test, it’s not actually a unit test. The
Wheel
is not used in isolation from other classes.
Why use 42 for a seed?
It’s mentioned in Douglas Adams’ The Hitchhiker’s Guide to the Galaxy. There are several boring numbers that are good choices because the numbers are otherwise mathematically uninteresting.
Testability Deliverables¶
There are two deliverables for this exercise. All of these deliverables need Python docstrings.
Appendix: On Random Numbers¶
Random numbers aren’t actually “random.” Since they are generated by an algorithm, they are properly called pseudo-random. The distinction is important. Pseudo-random numbers are generated in a fixed sequence from a given seed value. Computing the next value in the sequence involves a calculation that is expected to overflow the available number of bits of precision leaving apparently random bits as the next value. This leads to results which, while predictable, are arbitrary enough that they pass rigorous statistical tests and are indistinguishable from data created by random processes.
We can make an application more predictable by selecting a specific seed value. This provides reproducible results.
We can make an application less predictable by choosing a very
hard to predict seed value.
In most operating systems a special “device” is
available for producing random values. In Linux this is typically
/dev/random
. In Python, we can access this through
the os.urandom()
function as well as the secrets
module.
When we need to make an application’s output repeatable, we set a known seed value. For testing purposes, we can note the sequence of numbers generated and use this to assure a repeatable test.
We can also write a short demonstration program to see the effect of setting a fixed seed. This will also give us a set of predictable answers for unit testing.
Looking Forward¶
We’ve built a simple, prototype Player
class definition.
This player only places a limited number of bets. The house edge
in Roulette assures us that the play will, before long, run
out of money.
A bet on black pays winnings as if the probability of winning were . The actual probability is . The difference, , tells us that the expected number of spins is 38 before the player is out of money.
 We can, however,
simulate the variety of creative ways people apply fallacious reasoning
to try and prevent this inevitable loss. We’ll start with a general Player
class and then implement a number of stateful algorithms
for betting.


in Melbourne there are trams everywhere. i haven't taken any photos of them but i have taken photos of plenty of zoo animals from Weribee open range zoo.
my auntie alex lives here.
but elizabeth is used to the country.
we were lucky. we got to see a ford escort, the baby hippo at Werribee zoo, and a cormorant sitting in front of a plastic crocodile.
here are some other animals.


Survey about how you're using our products
How do you see our services?
What type of things you like about our company?
Add your suggestions:


# Example of how to search on a *HTML-table* written in Markdown
> [This previous example](example6.html) is a *StrapDown*-flavored HTML page is a demo of *how to write a table with Markdown*, and how a table will be (nicely) rendered by StrapDown.js.
#### Some help? (about that searching feature)
> The code I used is a [**jQuery**](https://www.jquery.com/) *plug-in*, called [QuickSearch](http://deuxhuithuit.github.io/quicksearch/). More detail can be found on [its documentation](http://deuxhuithuit.github.io/quicksearch/).
---
## Searching on a Markdown table?
> More details about the syntax for Markdown tables can be found on the **GitHub Flavored Markdown** document : [help.github.com/articles/github-flavored-markdown/#tables](https://help.github.com/articles/github-flavored-markdown/#tables).
The goal of this demo is to show how easy (and pretty) it is to add a search feature to any table, written in Markdown (or HTML).
That search feature is working **incredibly well**, on the box below, if you start typing "Su", it's already enough to select only the **Superman** line!
---
# A partial list of the [Justice League of America](https://en.wikipedia.org/wiki/Justice_League)
Here is an example of a table, displaying some *super heroes* ^^
(fake picture, fake email address, etc).
| Number | Name | Secret Name! | Organization | Gender | Email Address | Photo | *Awesomeness* |
| :----- |:----:|:------------:|:------------:|:------:|:-------------:| -----:| ------------: |
| 01 | **Wonder Woman** | *Secret!* | JLoA | Female | [Wonder.Woman<EMAIL_ADDRESS>| ![Picture for hero #01](https://randomuser.me/api/portraits/med/women/25.jpg "Picture for super-hero #01")| *Really awesome* |
| 02 | **Superman** | *Clark Kent* | JLoA | Male | [superman<EMAIL_ADDRESS>| ![Picture for hero #02](https://randomuser.me/api/portraits/med/men/72.jpg "Picture for super-hero #02")| *OK* |
| 03 | **Batman** | *Bruce Wayne* | JLoA | Male | [batman<EMAIL_ADDRESS>| ![Picture for hero #03](https://randomuser.me/api/portraits/med/men/45.jpg "Picture for super-hero #03")| *Wonderful* |
| 04 | **Green Lantern** | *Secret!* | JLoA | Male | [Green.Lantern<EMAIL_ADDRESS>| ![Picture for hero #04](https://randomuser.me/api/portraits/med/men/51.jpg "Picture for super-hero #04")| *OK* |
| 05 | **AwkGirl** | *Too lazy to [look for](https://www.duckduckgo.com/?q=AwkGirl+real+name) it* ([seriously](https://en.wikipedia.org/wiki/Hawkgirl#Fictional_character_biography)) | JLoA | Female | [AwkGirl<EMAIL_ADDRESS>| ![Picture for hero #05](https://randomuser.me/api/portraits/med/women/88.jpg "Picture for super-hero #05")| *Not great* |
> *Hint:* these emails addresses are really secret, keep them for yourself, but most importantly, keep them away from super villains! (Seriously: **pictures and emails they are fake!**)
> Thanks to the *awesome* [RandomUser.me](https://randomuser.me/) for providing **fake** profile pictures for our super-heroes! (And *free* and *open* to use pictures, thanks guys!)
---
# How to do it?
Three steps:
## 1) Add the search bar somewhere in your page
One simple line of HTML code:
```html
```
If you want to display on the right of the page (as I did above), let's use a cool [Bootstrap CSS feature](http://bootswatch.com/united):
```html
Search on that table?
```
## 2) Load jQuery and the QuickSearch plug-in
At the **end** of your [StrapDown.js](//lbesson.bitbucket.io/md/index.html) document, include the `jquery` javascript file (in my case `jquery.js`, but could be `jquery.min.js`), and the quicksearch plug-in (`jquery.quicksearch.min.js` in my case), with the good path.
In my example, I used the version that I stored on [my website](http://perso.crans.org/besson/), but you can use the **jQuery** CDN, or host them yourself on your site.
What I did here was just these two simple lines.
Be cautious to do it at *the end* of the document, **after the closing `xmp` tag** (or the `textarea` tag):
```html
```
## 3) Initialize the search feature
Finally, after loading the two scripts (step 2), one line of JavaScript in enough to conclude, by loading the QuickSearch plug-in, and initializing it:
```html
```
> More explanations? This Javascript line has three parts:
> 1. `$('input#id_search')` is using jQuery (the `$()` function) to select the DOM element of type `input` with `id=id_search` (id because of the `#`, it would be a class if `.`, like `div.navbar`),
> 2. `.quicksearch(...)` is calling the `quicksearch` function (available because QuickSearch has been registered as a jQuery plug-in), using it for that DOM element (the input search bar),
> 3. and finally we apply that function with the argument `'table tbody tr'`, which means that we initialize QuickSearch to look for all the `
` elements, only on their children `` (content of the table), and only on the different lines (`
`).
---
## End of the example
That's all for today! [Go back to StrapDown.js main page](index.html)?
---


represents annotator's output parts and their details
This class should grow once we start training on datasets and share params For now it stands as a dummy placeholder for future reference
This trait implements logic that applies nlp using Spark ML Pipeline transformers Should strongly change once UsedDefinedTypes are allowed https://issues.apache.org/jira/browse/SPARK-7768
Created by saif on 06/07/17.
Created by saif on 06/07/17.
AnnotatorApproach'es may extend this trait in order to allow RecursivePipelines to include intermediate steps trained PipelineModel's
Created by jose on 25/01/18.
Created by saif on 06/07/17.
represents annotator's output parts and their details
the type of annotation
the index of the first character under this annotation
the index after the last character under this annotation
associated metadata for this annotation


This is a collection of some things I’ve worked on that are easily viewable online. Anything that is not browser-friendly will not make the cut :(
Website themes
- Beautiful Jekyll - a Jekyll theme I created when making this website. You can view a demo or use it yourself to make a pretty website by visiting the GitHub project. The theme is extremely easy to install - you can have a site up and running in 2 minutes, and it is designed to look great on both mobile and large-screen devices. (The code that generates this site is very similar to Beautiful Jekyll, but I added a few more advanced features that I don’t think should be included in an all-purpose template)
R packages
-
shinyjs - perform common JavaScript operations in Shiny apps or call your own JavaScript functions easily using plain R code. Check out a demo online. Available on CRAN and on GitHub.
-
ggExtra - easily add histograms/density plots to ggplot2 scatterplots, plus a few more convenience functions. Check out a demo online. Available on CRAN and on GitHub.
-
ezknitr - avoid the typical working directory pain when using ‘knitr’. If you’re into R and reproducible research/generating reports with knitr, then do check it out. Available on CRAN and on GitHub.
-
ddpcr - analyze and visualize droplet digital PCR data. Available on GitHub.
-
lightsout - an implementation of the puzzle game Lights Out using R. Play the game online. Available on CRAN and on GitHub.
Many of my R packages/tutorials/thoughts are graciously shared on R-bloggers, which is a great resource for any useR that contains a vast collection of R-related blog posts.
Chrome extensions
-
GitHub Diff Navigator - allows you to easily navigate through the changes in a file that has been edited on GitHub. Especially useful when editing a markdown file within the browser, as GitHub will only show you the full changed file but not show you where the edits were made. I find this very helpful every time I make small edits to someone else’s large markdown document. Get the extension at the Google Web Store
-
Google Slides Auto Resize Speaker Notes - the slide previews in the Speaker Notes window of Google Slides are tiny and unreadable. This extension dynamically resizes the slides based on the window size to make them useful. Get the extension at the Google Web Store
-
Project Free TV Ad Bypass - Project Free TV serves a 10-second ad page before allowing users to continue to the video - this extension bypasses the ad page. Get the extension at the Google Web Store
-
Smileyfy My Facebook - Chrome extension that adds infinite happiness to your Facebook browsing, plus a little bonus rickrolling :) This is not the most useful (if at all..), but it was a way for me to learn about some more advanced features of Chrome extension development. Get the extension at the Google Web Store
Websites
-
Wish.com - a very popular shopping platform. I was one of the few original developers of the site (before it was even called Wish!) and contributed mostly to the frontend. I was part of Wish’s inception and initial growth, but since then it has grown to be a #1 Android Shopping app, and I can’t claim any credit to that. :)
-
MakeupBee.com - website for women to discover and talk about interesting makeup applications. Clearly my area of expertise! The site was mostly developed by Brent Francia (CEO) and I, and I was responsible for all aspects of the development, seeing as we were usually a 2-3 person team.
-
Glittr.com - spin-off of MakeupBee that was designed to be more focused on mainstream looks and have a cleaner feel. I’ve written most of the code for this site.
-
Jauntr.com - travel site with a social component, that is meant to help users discover and share places to go. It never really took off, but it was my first introduction to web development.
-
daattali.com - small personal website that I run on a virtual server just because I wanted a place to host my own R Shiny server and RStudio server.
-
deanattali.com - the site you’re currently on. Just a simple site to have some virtual presence.
Paid writing gigs
- Persistent data storage in Shiny apps - written for RStudio.
- How to Set Up R on Ubuntu 14.04 - written for DigitalOcean.
- How to Set Up Shiny Server on Ubuntu 14.04 - written for DigitalOcean.
- Book reviewer for Learning Shiny.
- Building Shiny apps - written for a course I TA’ed.
Misc
-
Impact Replays - I participated in a national hackathon (SportsHack15) and won 3rd place with this app. We had to build something that would increase engagement of CFL (Canadian Football League) fans. This app uses play-by-play data from games to let you focus on just the action moments of games.
-
Minesweeper - tiny Minesweeper game I built as part of the interview process with Airbnb. It’s not fancy at all, but it’s the best I could do in the two hours they allotted me back in the day.
-
Building your own portable oldies gaming console - I bought a raspberry pi and turned it into an awesome portable gaming console that supports SNES/PS1/GameGear/GameBoy. Super cool.
Java games
I have several cool Java games I wrote, but I currently don’t have a way to host the applet online without paying way too much money to buy a certificate. I might find a way around that in the future. Update: I decided to bite the bullet and purchase a code-signing certificate for $100/year so that I will be able to host Java applets online. The process to get the certificate is length but I will put up my applets once it’s done.


!
=
1. × 10
0
Add
?sigfigs=10
or whatever to the URL to change the maximum number of significant figures.


"The key to testing is the presence of seams (places where you can divert the normal execution flow)" http://tinyurl.com/6q9few
8/7/2008, 1:26:13 PM
Favs: 0
Retweets: 0
link--- layout: tweet ---
"The key to testing is the presence of seams (places where you can divert the normal execution flow)" http://tinyurl.com/6q9few
8/7/2008, 1:26:13 PM
Favs: 0
Retweets: 0
link


[ all classes ]
[ core.components.factories ]
Coverage Summary for Class: ParkingSlotsFactory (core.components.factories)
| Class | Class, % | Method, % | Line, % |
|---|---|---|---|
| ParkingSlotsFactory | 100% (1/ 1) | 42.9% (3/ 7) | 80% (16/ 20) |
1 package core.components.factories;
2
3 import core.components.ElectricalBicycle;
4 import core.components.MechanicalBicycle;
5 import core.components.ParkingSlot;
6
7 import java.util.ArrayList;
8 import java.util.List;
9
10 /**
11 * The ParkingSlotFactory class : This is the factory to create and add new parking slots to stations
12 * It is uses the simple factory design pattern
13 */
14 public class ParkingSlotsFactory {
15
16 /**
17 * This methods creates free parking slots (as a list) and return the new instances
18 *
19 * @param numberOfParkingSlots the quantity of parking slots that we need
20 * @return a list of free parking slots
21 */
22 public static List<ParkingSlot> createFreeParkingSlots(int numberOfParkingSlots) {
23
24 List<ParkingSlot> slots = new ArrayList<>();
25 for (int i = 0; i < numberOfParkingSlots; i++) {
26 slots.add(new ParkingSlot());
27 }
28
29 return slots;
30
31 }
32
33 /**
34 * This methods create a free parking slot and return the new instance
35 *
36 * @return a free parking slot instance
37 */
38 public static ParkingSlot createFreeParkingSlot() {
39
40 return new ParkingSlot();
41 }
42
43 /**
44 * This methods creates an electrical bicycle parking slot and return the new instance
45 *
46 * @return an electrical bicycle slot instance
47 */
48 public static ParkingSlot createElectricalBicycleSlot() {
49 return new ParkingSlot(1, new ElectricalBicycle());
50 }
51
52 /**
53 * This methods creates electrical parking slots (as a list) and return the new instances
54 *
55 * @param numberOfBicycles the quantity of parking slots that we need
56 * @return a list of electrical parking slots
57 */
58 public static List<ParkingSlot> createElectricalBicycleSlots(int numberOfBicycles) {
59 List<ParkingSlot> slots = new ArrayList<>();
60
61 for (int i = 0; i < numberOfBicycles; i++) {
62 ElectricalBicycle bicycle = new ElectricalBicycle();
63 ParkingSlot slot = new ParkingSlot(1, bicycle);
64 slots.add(slot);
65 }
66
67 return slots;
68 }
69
70 /**
71 * This methods creates a mechanical bicycle parking slot and return the new instance
72 *
73 * @return an electrical bicycle slot instance
74 */
75 public static ParkingSlot createMechanicalBicycleSlot() {
76 return new ParkingSlot(1, new MechanicalBicycle());
77 }
78
79 /**
80 * This methods creates mechanical parking slots (as a list) and return the new instances
81 *
82 * @param numberOfBicycles the quantity of parking slots that we need
83 * @return a list of mechanical parking slots
84 */
85 public static List<ParkingSlot> createMechanicalBicycleSlots(int numberOfBicycles) {
86 List<ParkingSlot> slots = new ArrayList<>();
87
88 for (int i = 0; i < numberOfBicycles; i++) {
89 MechanicalBicycle bicycle = new MechanicalBicycle();
90 ParkingSlot slot = new ParkingSlot(1, bicycle);
91 slots.add(slot);
92 }
93
94 return slots;
95 }
96 }


@(loggedInUser: common.User, breadcrumbs: String, localhost: Boolean, batchId: Long, allowedWorkerTypes: String, study: common.Study, jatosUrl: java.net.URL, studyResultCountsPerWorker: java.util.Map[String, Integer]) @views.html.gui.main(loggedInUser, breadcrumbs, localhost){
| Worker ID | User Email | Last Study State |
|---|
| Worker ID | Comment | Study State |
|---|
| Worker ID | Comment | Last Study State |
|---|
| Worker ID | MTurk Worker ID | Type | Study State |
|---|
| Worker ID | Study State |
|---|