text:
# Change Log

## Under development

### 0.8.0

#### New Features:
* Installed/Enabled version of CodeIgniter upgraded to 3.0
* CI v2.x compatibility maintained, but requires [some additional steps to use/enable](https://github.com/ci-bonfire/Bonfire/blob/develop/bonfire/docs/ci2.md).

#### Closes Issues:

#### Additional Changes:

#### Known Issues:

## Released versions

### 0.7.4

#### New Features:

#### Closes Issues:
* #1119 Module Builder xss_clean error
* #1116 Syntax error in the builder-built view (when adding a required input field), pt 2
* #1115 Can't save settings, 'module' field not being sent to settings table
* #1114 Differences in Routing between CI2 and CI3
* #1113 Syntax error in the builder-built view (when adding a required input field)
* #1112 Can't login to site when offline in CI3

#### Additional Changes:

#### Known Issues:

### 0.7.3

#### New Features:
* If you are not using the installer, add `$config['bonfire.installed'] = "1";` to `/application/config/application.php`.
* Added `Template::setSessionUse($useSession = true)`, deprecated `Template::$ignore_session`. Note that the parameter accepted by `setSessionUse()` would be the opposite value of that used with `$ignore_session`.
* Added `form_validation->reset_validation()` support for CI 2 (in `BF_Form_Validation`, in CI 3 the method calls the parent method, in case of any future changes).
* Added `\application\language\english\bf_form_validation_lang.php` to store custom form validation language entries. This file is automatically loaded by the `BF_Form_validation` library when calling `$this->form_validation->run()`.

#### Closes Issues:
* #1110 `BF_Form_validation` not loaded in CI3
* #1109 Mobule Builder not using `lang(module_field_name)` for create/edit views.
* #1108 Can't create new user using CI3
* #1107 No model error generated for a failed update
* #1106 Settings controller displays error message on success.
* #1105 Doc searching - preg_match error when directory is encountered
* #1103 Installation using CI 3.0 fails due to use of sessions before CI 3 session table is created.
* #1033 Email sending test makes subnav bar crash

#### Additional Changes:
* Upgraded CI to v2.2.2.
* Fixes an issue when creating new roles which caused permissions to modify the new role not to be created/added to the admin/current user.
* Fixes issues with Emailer not displaying saved settings properly.
* Fixes issues with Add/Remove Shortcuts in UI module.
* Fixes result of `BF_Model->update_batch()` when the update completed successfully in CI 3, or failed in CI 2.
* Database module:
    * Fixed display of validation errors on backup.
    * Added message indicating user submitted index with the separator selected in the dropdown.
* CI 3 compatibility improvements:
    * Fix Runtime Notice for Users Settings: Only variables should be passed by reference.
    * Don't use `$this->load->driver('session')`, and don't check for the CI version before loading the session library.
    * Normalize the output of `uri->ruri_string()` before checking it in `App_hooks` (may be needed elsewhere).
    * Fix loading of `BF_`-prefixed libraries when a `MY_`-prefixed library is not present.
    * Don't display developer documentation for modules in the application docs.
* Installer improvements:
    * Updated a number of migrations to remove session use.
    * Removed session from autoload.
    * `bonfire.installed` setting added to application config by the installer.
    * `App_hooks` disables session use when `bonfire.installed` is not found.

#### Known Issues:

### 0.7.2

#### New Features:
* In CI 2.x, uses bfmysqli database driver (a modified version of the mysqli driver) by default.
* CommonMark support in Docs
    * View the [CommonMark Library docs](developer/commonmark) for more information.
* Added `BF_directory_helper`:
    * `bcDirectoryMap()` function provides the same output as CI2's `directory_map()` function. This was used primarily to make the Modules library and various portions of the translate module work properly in CI3.
    * In the long term, both the Modules library and translate module should be updated with more robust path/directory name handling, which would make this function unnecessary.

#### Closes Issues:
* #337 Can not login to admin when site is turned off (previously closed as non-issue, now fixed).
* #357 Custom Message When Site is Off/Closed
* #793 Wrong timezone setting (use `site.default_user_timezone` setting when $user->timezone is unavailable, instead of the admin's timezone).
* #603 Documentation updated to note the potential for `before_`/`after_user_update` events to receive an array in the `user_id` field, and for that field to potentially not include the user's ID.
* #565 `render_user_form` in the admin doesnt pass the payload.
* #1082 Strip '.php' extension from module config files in `config_file_helper`'s `read_config()` function when the file is found by `Modules::file_path()`.
* #1085 `s` key submits forms automatically
* #1087 Country dropdown in extended settings doesn't update state dropdown
* #1089 Fix error deleting roles for permissions during permission_model->update()
* #1097, 1081 Installer looks for database configuration only in /application/config/development/database.php

#### Additional Changes:
* Upgraded CI to v2.2.1
* [Improved support for CI 3](https://github.com/ci-bonfire/Bonfire/blob/develop/bonfire/docs/ci3.md).:
    * Renamed controller, library, and model files to uppercase first letter.
    * Added support for loading controller and model files named with uppercase first letter.
    * Accept null or false return from `config->item()` when config file has not been loaded.
    * Replaced use of `router->fetch_directory()` and `router->fetch_class()` with `router->directory` and `router->class`, respectively.
    * Replaced `random_string('unique', ...)` with `random_string('md5',...)`.
    * Replaced `read_file()` with `file_get_contents()`.
    * Replaced `do_hash()` with `sha1()`.
    * Added Constants from CI 3 to `/application/config/constants.php` (primarily EXIT_* constants).
* Removed mdash entities in documentation for "Submitting Bug Reports and Feature Requests" and updated link in Readme
* Profiler now displays boolean values in config section (displayed values are retrieved from the application_lang file, `'bf_profiler_true'` and `'bf_profiler_false'`).
* Added support for socket connections (prefixed with /) to bfmysqli database driver, similar to mysqli driver socket support in CI3.
* jwerty (keyboard shortcuts):
    * Updated URL for jwerty.
    * Updated jwerty.js to version 0.3.2.
* Added `$allowOffline` array to `/application/hooks/App_hooks.php` to configure pages which are allowed to bypass the site offline functionality. As long as `'/users/login'` is in this list, users with the correct permissions will be able to log in and bring the site back online. If a user does not have the correct permission, and no additional pages have been added to the list, they will still see the contents of the `/application/errors/offline.php` file once they log in to the site. If you want to disable user logins while the site is offline, set this variable to an empty array. Just make sure you don't log out of the site after setting it offline, or you will have to update the database to get the site back online.
* Application Helper:
    * `is_https()`:
        * Added `is_https()` function from CI 3's `core/Common` functions to ensure checks for use of https are consistent and accurate.
        * Modified `gravatar_link()` function to use `is_https()`.
        * Modified the Assets library to use `is_https()` (in `external_js()` and `find_files()`).
        * Did not modify CI 2 core classes to use it, but it could be useful in `core/Config` and `core/Security`. One possibility would be to override `csrf_set_cookie()` in `/bonfire/core/BF_Security.php`.
    * Modified `list_contexts()` to call `Contexts:getContexts()`, keeping the functionality of determining required and available contexts within the Contexts library.
* UI/Contexts Library:
    * Deprecated `set_contexts()` and `get_contexts()` (use `setContexts()` and `getContexts()`).
    * When using `setContexts()` in place of `set_contexts()`, be aware that the behavior has changed slightly:
        * when omitting the second argument (`$siteArea`), `setContexts()` will not change the internal `$site_area` variable, while `set_contexts()` would set it to `SITE_AREA`. (`SITE_AREA` is still the default value for the internal variable.)
        * `setContexts()` will add the required contexts if they are not included in the first argument.
    * `getContexts()` allows an optional first argument to only return contexts with landing pages (the functionality from the `application_helper`'s `list_contexts()` function).
    * Modified internal access of the `self::$contexts` array to use `self::getContexts()` and `self::setContexts()`.
* Language improvements:
    * CI Language files adapted from https://github.com/bcit-ci/codeigniter3-translations (official CI3 translations repository)
    * DB files modified to use `db_unsupported_compression` and `db_unsupported_feature` (instead of `db_unsuported_*`) and FTP library modified to use `ftp_unable_to_mkdir` instead of `ftp_unable_to_makdir`, so other language files may be pulled down from the official CI3 translations.
    * Updated `form_validation_lang` files to allow use with either CI 2 or 3.
    * Changed language prefix for emailer module from `em_` to `emailer_`.
    * Fixed russian language support for activities, logs, and sysinfo modules. Added russian language support to builder.
    * Changed language prefix for translate module from `tr_` to `translate_`.

#### Known Issues:

### 0.7.1

#### New Features:

* Composer Auto-loading may be enabled by setting `'composer_autoload'` to true (or the path to the autoload.php file) in /application/config/config.php. Please be aware that this currently requires hooks to be enabled and the `App_hooks->checkAutoloaderConfig()` method must be included in the `pre_controller` hooks in /application/config/hooks.php.
* Now works with [Sparks](http://getsparks.org) out of the box.
* Brand new documentation system that allows splitting your user and dev-related docs, and searching docs.
* Added bfmysqli driver to support more features in the MySQLi driver without changing the codeigniter driver. Set `$db['dbdriver'] = 'bfmysqli';` in the database config, configure the other settings as you would for the mysqli driver.
* Images controller can reference images from a module using the `module=...` parameter.
* Template class now provides a `check_segment` helper in addition to `check_class` and `check_method`.
* CSRF protection can be bypassed for individual controllers by setting `csrf_ignored_controllers` setting in the site's main index file.
* Added `'languages_available'` and `'database_types'` to Module Builder's configurable options. `languages_available` tells the builder which language files to attempt to build for a new module. `database_types` gives the builder some information about the types supported by the database, and is used in generating the "Database Type" select on the module builder form, as well as handling several other aspects of building the module.

#### Closes Issues:

* #1078 - Module Builder form's script would fail if other scripts using `localStorage` used URLs for keys. Failure of the script would cause collapsing areas in the form to stop functioning. DataTables v1.10 would cause this issue if the `saveState` option was enabled.
* #1075 - Removed statistics collection from installer.
* #1073 - Installation issues with App_hooks when settings table doesn't exist.
* #1048 - (almost) full russian language
* #1041 - Only display edit keyboard shortcuts link to users with permission to edit them
* #1040 - Documentation errors (Performance Tips)
* #1038 - Add HTML5 required attribute to builder-generated form inputs
* #1036 - Builder: Allow user to undo selecting an option under Input Limitations
* #1035, 1042 - Migrations library attempts to insert core version (duplicate key) during installation
* #1011 - `save_requested()` and `prep_redirect()` are broken again.
* #1009 - Activities reports 0 records found when attempting to delete.
* #1001 - Error handling in Module Builder, default max lengths for fields in existing tables, JavaScript updates of table name, use created/modified/soft deletes and log user as checkboxes
* #1000 - Cache errors when using custom ENVIRONMENT settings
* #983 - `Assets::js()` creates invalid path when `base_url` is set to a directory
* #982 - `MY_Security` renamed to `BF_Security`
* #979 - Calling `Modules::Run()` from view is broken
* #975 - `BF_Model->update()`: check validation result before continuing with update
* #968 - Error loading language file in languages other than English
* #967 - Should make the CSRF ignore list configurable.
* #965 - State input no longer required in extended settings
* #964 - Fixed documentation of `Template::set()`
* #962 - Updated docs system doesn't load module docs for application or module docs named something other than index
* #958 - ENVIRONMENT config files are being ignored.
* #957 - Documentation of required server configuration on display of root index.php
* #955 - Fixed the path of the User Modules' views
* #954 - `Assets::js()` returns nothing if string is passed as first parameter
* #952 - Documentation of `BF_Model`'s handling of validation 'label' parameter
* #948 - Add function strtolower in libraries: Module will be better.
* #947 - Remove PHP short tag from view for PHP 5.3 support
* #946 - Unable to load class cache.
* #941 - Model `set_date` when `time_reference` is set to GMT
* #940 - Model `update()` throws error in `modified_on()` when validation fails and `set_modified` is enabled.
* #939, 627 - sync `user_meta` state/country selects
* #937 - Module Builder support for `$log_user`, `$created_by_field`, `$modified_by_field`, and `$deleted_by_field`
* #932 - Resend Activation Link sends incorrect link, preventing user from activating account
* #928 - `min_length[8]` validation called regardless of minimum length setting for password
* #926 - Application helper iif issue
* #922 - Type of `MY_Model` `update_where()` method
* #919 - Incorrect documentation of `date_format` field in `MY_Model`
* #917 - Problem when `SITE_AREA` is changed
* #849 - No need to save `password_iterations` in the user table
* #769 - Filter out soft-deleted records on public index generated by module builder
* #757 - Migration version is always up when SQL migrations fail
* #737 - Paging data in Module Builder
* #726 - Admin notification for approval
* #709 - Language entry is now created when creating a new context
* #697 - Module Builder now warns about any names which pass a `class_exists()` check
* #687 - user-meta fields doesn't respect "required"
* #637 - Bonfire admin topbar CSS breaks scrolling features (Firefox)
* #612 - Modifying set created and set modified from models
* #578 - modulebuilder config: 3 "defaults" not used (except for some error handling which will cause confusion)

#### Additional Changes:

* Updated CodeIgniter to version 2.2
* Updated list of countries in /application/config/address.php and added state codes for a few more countries.
* Separated all Bonfire code from your Application's code
* Most Bonfire-specific code now uses a `BF_` prefix instead of the `MY_` prefix your application would use.
* Removed Settings related to the previously removed Updates module
* The user register form can be modified to include hidden fields named `register_url` and `login_url` that will override the current `REGISTER_URL` and `LOGIN_URL` values, respectively, to make it simpler to use the existing logic in custom modules.
* Added 4th parameter to `timezone_menu` in the date helper to allow passing additional attributes, such as an ID, for the generated select element. Updated the `user_fields` view to make sure of this parameter (and fix an accessibility error on the view).
* Application Helper:
    * The `module_*` methods in the `application_helper` have been moved to the Modules class. The `application_helper` methods are still there but are deprecated.
    * Deprecated `form_has_error()` method since CI's `form_error()` does the same thing.
* Assets Library:
    * Replaced `Assets::$asset_base`, `Assets::$asset_cache_folder`, and `Assets::$asset_folders` with a single `Assets::$directories` array (these were not deprecated because they were private properties). Allow a config item (`'assets.directories'`) to set the value of the new property, but if it is not set the library will attempt to use the old config items (`'assets.base_folder'`, `'assets.cache_folder'`, and `'assets.asset_folders'`).
    * Added closures to hold the functions for CSS/JS minification, which should facilitate swapping out the libraries that perform these functions in the future.
    * Deprecated `Assets::set_globals()`, `Assets::$external_scripts`, `Assets::$inline_scripts`, and `Assets::$module_scripts`. Replaced by `Assets::setGlobals()` and `Assets::$scripts['external']`/`Assets::$scripts['inline']`/`Assets::$scripts['module']`
* Database module:
    * Added support for bfmysqli driver.
    * Changed language files to use `database_` prefix instead of `db_` prefix to prevent conflicts with CodeIgniter's language files.
    * Moved CSS out of the views.
* Docs:
    * Docs system is much more robust now, including link fixing, separating application/developer docs in the UI, a basic search system, and more.
    * Added configuration options to docs module to set the environments in which the docs will be displayed and the name of the toc file.
    * Fixed an issue in the docs module that prevented the sidebar links from building properly for application or developer docs if a toc file was not used.
* Migrations:
    * The Migrations library now only requests version information which hasn't previously been retrieved by the library on the current request (2 static properties maintain the library's schema version and the current versions of the modules and the app/core migrations).
    * Significantly reduced the impact of using `migrate.auto_core` and `migrate.auto_app` when multiple controllers are loaded which inherit from `Base_Controller`.
    * Improved the load time of the migrations view (especially when a large number of modules are installed).
    * Fixed an error in the `version()` method when an error occurred in `glob()` while retrieving the migrations for a given step (see comment in the code for more details).
    * When running multiple migrations, only update the version in the database once.
    * Reduced the number of methods in the library with knowledge of the database table's structure.
    * Overhauled the library's API:
        * Added:
            * `getErrorMessage()` - return the most recent error message
            * `getErrors()` - return all errors
            * `getModuleVersions()` - retrieve the current version of all modules in one call
            * `Migrations::APP_MIGRATION_PREFIX` constant - the prefix used for app migrations (`'app_'`)
            * `Migrations::CORE_MIGRATIONS` constant - the migration type used for core migrations (`'core'`)
            * `Migrations::MAX_SCHEMA_VERSION` - the maximum version of the schema_version table supported by the library (`3`)
        * Deprecated (all of the below still work, but eventually will be removed, their performance may also be degraded, as the methods are now pass-throughs to the new methods):
            * `$error` property (use `getErrorMessage()`)
            * `auto_latest()` - use `autoLatest()`
            * `do_sql_migration()` - use `doSqlMigration()`
            * `get_available_versions()` - use `getAvailableVersions()`
            * `get_latest_version()` - use `getVersion($type, true)`
            * `get_schema_version()` - use `getVersion($type)`
            * `set_verbose()` - use `setVerbose()`
* Translations:
    * Partial Russian and Italian translations.
    * Many improvements to the Brazilian Portugeuse language handling.
    * Improved support for translations in the Activities, Builder, Logs, Sysinfo, and UI modules.
* Template Library:
    * Added `setLayout()` and `getLayout()` methods, deprecated the public `$layout` property (it will become private or protected in a future version).

#### Known Issues:

* If a module is named `'application'` or `'developer'`, the docs module won't be able to generate links to any documents which reside in that module.

### 0.7.0

* Minimum PHP version changed to 5.3
* Updated CodeIgniter to version 2.1.4
* Updated Bootstrap to version 2.3.2
* Updated .htaccess sections taken from html5boilerplate, supporting the new Apache 2.4.
* Updated jwerty to version 0.3.1 (seems to fix issue where creating a shortcut for '&' kills keyboard input on all admin pages)

#### New Features:

* [New Folder Structure](site_structure)
* The password hash changes from SHA1 (salted, but not iterated) to [phpass](http://www.openwall.com/phpass/) libraries. When on PHP 5.3 or with the Suhosin patch installed, Blowfish encryption is used. If bcrypt is not available, will fallback to extended DES-based hashes, or even to phpass' provided (but slower) hash method, if necessary.
* [MY_Model](bonfire_models) now supports Observer methods that allow your model to more easily hook into the default operations without having to rewrite the code.
* MY_Model now supports protecting attributes so they can never be set or updated.
* MY_Model handles return types differently now. Instead of passing to the functions, it's a class var that each model can set. Defaults to object. Can use new scope methods 'as_array', 'as_object()' and 'as_json()' within a call to change the output type temporarily.
* Template library's parser now includes the [Lex template language](https://github.com/pyrocms/lex) when $parse_views == TRUE in the Template.php library.
* Added get_filenames_by_extension() method to the file helper.
* MY_Controller file no longer used as we have split each controller into their own class file in application/core. This allows the HMVC autoloader to find them for us, and frees up the MY_Controller file for end-user only use.
* New front-end theme that is simply the latest Bootstrap theme with a couple of small minor tweaks.
* log_activity helper function included in the application helper. This removes the need for autoloading the activity model and also allows logging of activities to be turned off.
* New constants LOGIN_URL and REGISTER_URL are used in place throughout the site to make it easy to change the login and registration URLs.
* New docs system that provides basic methods for packaging documentation with your modules and application using Markdown formatted text files.

#### Closes named issues:

* #598 - Fix password help message for number required
* #557 - When logging in, check the user isn't banned
* #489 - users index: form buttons only worked for English users
* #575 - Add bf_action_edit and bf_action_undo to language file
* #580 - Add Portugese language for activities module
* #583 - Set display name when entered in the self-service user registration form
* #613 - module builder: SQL error while creating field type 'enum' and 'a', 'b', 'c' as values
* #631 - redirection to install folder fails (certain browser?)
* #617 - combine js doesn't work (when enabled in config)
* #674 - user meta should fallback to current-user if no user provided
* #672 - user meta is considered "empty" if the value is "0"
* #678 - save_meta_for returns void, but it should indicate success/failure
* #683 - Create Module from existing DB Table doesn't generate correct form field IDs
* #680 - Gravatar default images don't work for non-public sites
* #664 - Translate editor: saving sysinfo_lang.php causes CodeIgniter error
* #708 - UI module causes error when admin profiler is disabled
* #720 - builder: don't insist on providing a "length" for INT fields
* #727 - users index page: Filter wont go along with pagination
* #749 - Don't silently ignore values of password_min_length less than 8 (issue #749)
* #750 - AUTO_INCREMENT portability, fixes install errors seen on Percona Server
* #751 - Fix SITE_AREA/ homepage, if you have changed SITE_AREA
* #759 - username validation is bypassed when !auth.use_usernames
* #767 - Don't allow deleting the default role, it causes problems
* #785 - email activation can fail with "The URI you submitted has disallowed characters"

#### Additional changes:

* $table in MY_Model changed to $table_name to avoid potential conflict with the table library.
* database backup - fix effect of yes/no dropdowns for languages other than English
* database backup: .gzip doesn't work very well; use .gz instead
* Template::redirect() - fix escaping of url [XSS?]
* Template::redirect() - should not require javascript support, unless the current request was by ajax
* Template::render() - ajax responses - remove incorrect Content-Type and caching override headers
* builder generated index_front: escape values from user-editable data [XSS]
* users auth library: fix has_permission() when called with a role parameter
* users module: deactivate() shouldn't send "user activated" email
* users module: deactivate() should not show an error when it succeeds
* users login: don't show error when auth.allow_register==FALSE
* users forgotten password: fix "Cannot find that email in our records" message
* default theme: don't show "Sign up" link if auth.allow_register==FALSE
* fix "remember me" in modal_login
* ctrl+s should not perform dangerous actions like deleting tables, because the user might have intended to invoke a harmless browser shortcut
* tentatively standardized on `isset($_POST['save'])` when testing submit buttons.  It's not too ugly, especially when you understand the pitfalls of the alternatives.
* $return_type removed from the user_model functions: find, find_all, and find_by. Use as_array() instead.
* Template::yield() changed to Template::content() due to the addition of generators in PHP 5.5.

#### Upgrade notes

Migrations should be set to auto-run in the application config file so that the new password hash is enforced before you try to login the first time after updating. The migrations force all users to create new passwords so that the newer encryption methods are used.

The "ban" button in the users page is working now, and the permission `Site.Signin.Allow` has been removed.  If you created a custom role which banned logins by excluding this permission, they will now be able to log in.

If you attempt to downgrade to 0.6.*, Bonfire will at best restore `Site.Signin.Allow` to the Administrator role. No other role will be able to log in.  This was written with developers in mind, not downgrading a production system.  (But it would be interesting to hear any feedback).

The comment recommending `IS_AJAX` as a security check has been removed.  `IS_AJAX` is not effective as a security check.  It may have happened to prevent CSRF on AJAX methods, but Bonfire now supports CodeIgniter CSRF protection (see upgrade notes for 0.6.1).  For other purposes, you may prefer to avoid the Bonfire-specific constant in favour of the standard CodeIgniter method `$this->input->is_ajax_request()`.

Because the `MY_Controller` file no longer ships with Bonfire, you should make a backup of your current `MY_Controller` file, if you have made any changes. This file will be renamed to `Base_Controller.php`. Any changes you made should then be redistributed over the new Controller files in application/core.

If you use the $table class var within any of your module's model files, you will need to change that reference to $table_name.

If your module calls the `activity_model` for logging purposes, you will need to either switch the code to the new `log_activity()` helper method or load the `activity_model` explicitly.

All templates that use the current `Template::yield()` function must be updated to `Template::content()` due to the addition of generators in PHP 5.5.

### 0.6.1

#### Regression fixes

- Permissions Matrix silently didn't work - issue #596
- Redirect after login - was redirecting to '/', regardless of the previous page or per-role redirect settings
- Site settings failed to save sometimes, under PHP 5.4 - issue #618

#### Upgrade Notes:

Version 0.6 prevented CSRF attacks using a standard CodeIgniter option.  This should protect against clicking a malicious link (e.g. in an email or forum post), which attempts to perform actions on Bonfire.  E.g. deleting modules or changing user access rights.

When upgrading to Bonfire 0.6.1, you should make sure to update config.php in the application/config folder.  This is necessary in order to enable and configure CSRF protection.

As a result, any AJAX POST request you have will need to include the CSRF token.  If you don't already know how to do this, Bonfire 0.6.1 includes a simple solution.  You just need two extra lines.

In the controller for the page which launches the AJAX request:

    Assets::add_js('codeigniter-csrf.js')

In the AJAX request, an extra data field:

    // assuming your data is not passed as a string
    $.ajax({ ..., type: "POST", data:
                   { ... 'ci_csrf_token' : ci_csrf_token() } } );
    // or
    $.post(url,
                   { ... 'ci_csrf_token' : ci_csrf_token() }, ... );
    // or
    $(elt).load(url,
                   { ... 'ci_csrf_token' : ci_csrf_token() } );

### Version 0.6

#### Additions:

- Major UI Upgrade to use Twitter Bootstrap
- Application and other settings are moved into the DB
- Renaming Module Builder to Code Builder
- Adding Context creation UI to Code Builder
- Many security improvements
- Many User Profile improvements including password strength and email verification
- Language preferences
- Cleanup of permissions
- Language Translation UI
- Custom User Fields
- More Keyboard Shortcuts
- Installer improvements
- Many other bug fixes and improvements

### Version 0.5.2

#### Additions:

- Fix for parse_views in the Template library
- Change text to use lang file - issue #360
- Fixing Database backups - issue #362
- Cleanup of helpers - issue #366
- Adding Persian language text - issue #324
- Change to the version message in /admin/developer/update

### Version 0.5.1

#### Additions:

- Hotfix for issue in Module Builder
- Edit Profile for the front end user - issue #197
- Mode_rewrite check in the installer to set the base_url - issue #52
- Adding extra functionality to the config_file_helper to allow reading and writing of module config files
- Config setting for front end controller which is checked inside the MY_Controller/Front_Controller
- Adding "matches_pattern" method to Form Validation to ensures a string matches a basic pattern
- Upgrading the Migrations DB schema (issue #180) so that we use records instead of DB table columns for the modules
- Moved the Settings into the DB
- Frontend User Profile editing
- New Installer
- Module Builder - various improvements, including Creating a module from an existing DB table
- Updated jquery.forms to 2.94
- Emailer improvements
- Localization improvements, including Persian language files (thanks to Github user "sajjad-ser")

### Version 0.5

#### Additions:

- Edit Profile for the front end user - issue #197
- Mode_rewrite check in the installer to set the base_url - issue #52
- Adding extra functionality to the config_file_helper to allow reading and writing of module config files
- Config setting for front end controller which is checked inside the MY_Controller/Front_Controller
- Adding "matches_pattern" method to Form Validation to ensures a string matches a basic pattern
- Upgrading the Migrations DB schema (issue #180) so that we use records instead of DB table columns for the modules
- Moved the Settings into the DB
- Frontend User Profile editing
- New Installer
- Module Builder - various improvements, including Creating a module from an existing DB table
- Updated jquery.forms to 2.94
- Emailer improvements
- Localization improvements, including Persian language files (thanks to Github user "sajjad-ser")

#### Bugs:

- #236 - Email Settings - fixing the password validation
- #252 - MY_Form_Validation unique() not working
- #260 - `<ul>` tag was closed with `</li>`
- #262 - Front End User Profile update adds table prefix
- #265 - Installer config_file_helper Setup Bug
- #266 - Module Builder: Creating Module
- #276 - Module creation with field with uppercase name
- #282 - Using 'unique' rule on form validation
- #254 - Module Builder - Validation of Decimal fields
- #286 - Backend, Module: create new: wait animation doesn't disappear
- #284 - Delete Module fails
- #288 - Changed "Remember me for two weeks" to "Remember me"
- #290 - First name and last name were previously not being added to the database
- #301 - Fix Line 27 $error_message undefined variable modulebuilder
- #294 - Modulebuilder: Can not delete module
- #239 - Developer Context Fails to Delete Update Cache File
- #292 - Installer locations
- #303 - Emailer queue error
- #304 - Assets::add_module_js() causes fatal error unknown function module_file_path()
- #306 - Fixed redirect on auth->restrict & Fixed database module anchors
- #302 - Horizontal scroll bar appearing in FF
- #307 - Emailer: SMTP Password format error
- #293 - Saving email settings
- #295 - Modulebuilder: form validation callback functions do not work
- #309 - Convert Some text to language file & some fix & RTL layout
- #310 - Fixed Database Module
- #300 - Installer : Assets cache should be writeable
- #314 - Disallow spaces in the keyboard shortcuts

### Version 0.2

#### Additions:

- Major revamp to the ModuleBuilder
- Added new date_difference function to MY_date_helper.
- Removed the Tester module and replaced with integrated SimpleTest suite.
- You can now view and delete system-wide activities in the Reports context.

#### Enhancements:

- Emailer has better tools for testing the Queue.
- Activities logged for more activities throughout Bonfire.
- Added soft_deletes, created and modified fields to ModuleBuilder.
- ModuleBuilder creates better localized files.
- ModuleBuilder now automatcially runs the migration files for a new module.
- Permission names are now allowed to be 255 chars long (up from 50).
- where() method in MY_Model now accepts arrays or custom strings as parameter.
- Better permissions in place to prevent users of other roles from modifying roles you don't want them to.
- Added set_default_theme() method and parameter to Template lib.
- Installer improvements to make it more usable and stable (we hope)
- Creating and deleting roles adds/removes proper permissions to the system.

#### Bugs:

- Fixed bug in MY_Form_Validation to allow the form validation library to work with Modular Extensions HMVC. See http://www.mahbubblog.com/php/form-validation-callbacks-in-hmvc-in-codeigniter/ for more details.
- User module plays better with various display/login options
- User module allows for saving empty usernames.
- Permission matrix now no longer throws PHP error in certain cases.
- If no user existed with provided email/username, the system was throwing PHP errors instead of displaying the proper error to the user.
- Assets lib no longer using site_url() to build file names and causing errors.
- Fixed broken path for asset caching.
- Assets lib now properly finds module assets for both core and user modules.
- Assets lib now works under SSL conditions.
- Email Template now saves to correct location.
- Emailer now correctly sends HTML emails from the queue instead of text-only.
- User_model now returns correct 'deleted' flag (instead of the role's deleted flag).
- Auth library now loads the User model if it's not already loaded.
- Users can no longer delete themselves.
- Modulebuilder no longer spits out html char codes for single quotes in generated migration SQL.
- Modulebuilder now creates safer code when using cdeditor.
- Reports context now checks for proper permisisons (instead of checking for content context permissions).
- Deleted users can no longer log into the system.
- When changing the name of a role, the corresponding Permission.[ROLENAME].Manage now updated to reflect the new name.
- Base_Controller now actually populates the previous_page url.
- Profile no longer causing errors in IE7.
- Removed E_STRICT from default error_reporting as it was reporting errors from CodeIgniter and HMVC that we had no control over.

### Version 0.2-RC1

Released: August 11, 2011

#### Additions:

- The Emailer class has a new setting, html or text email format.
- Emailer class now has a way to test your email settings.
- Emailer class has allows you to view the unsent emails in your queue under Statistics / Emailer.
- Updated email class to wrap the $message in the email template by default.
- A new `Unit Testing` framework has been started. Currently supports Unit Testing only. Web/Functional Testing coming later.
- A new `System Events` feature has been added.
- A logit() function was added to the application helper to provide a simple interface to log to both the Console and the log file.
- Added new Activities module to allow other modules a core utility for tracking user activity. Was incorporated into the Users module.
- Added a new Module Builder module that helps create skeleton code for new modules.
- Now has a proper AJAX loading display.
- Adding Activity records to the Module Builder

#### Enhancements:

- Forgot Password feature was revised for better security.
- Users can have countries stored with their profile. A country table added to db as well as a country_select function to the helper.
- Migrations has better interface. Supports both up/down migrations anytime.
- Migrations have been separated so that the core Bonfire migrations are separate from the app-specific migrations.
- Each module can maintain it's own set of migrations.
- Modules can have a settings array that allows for drop-down menus, custom names, and more. Added module_config() method to application helper.
- Initial translation to Portuguese.
- Bonfire core database migrations moved to migrations/core/ to remove conflicts between your app and Bonfire.
- Roles can now be set as deletable or not in the UI. New Permission: Bonfire.Roles.Delete to use to check if the role is allowed to delete other roles.
- Improved the installer - user brought to the install page if the app hasn't been installed already, allows user to choose which environment is being installed, tries to set the file and folder permissions.
- Adding created_on and modified_on into protected variable of the BF_Model
- Adding activity log when saving the App settings
- Moved site, update and email based config settings into the new settings database table - this removed the need for the config/email.php

#### Bugs:

- Upgraded to the latest version of head.js to fix a bug where AJAX page loads were not working in FF3 and IE.
- Misc. bugfixes in the install routine that should allow for smooth installation in a larger number of cases.
- Deleted users can now be restored.
- Controller override function now doesn't override AJAX layouts.
- Fixed admin theme styles for IE7 and IE8.
- Install no longer fails on unsuccessful migration.
- Timezone settings checked and optionally set by date_default_timezone_set() because of PHP5.3 in index.php.
- Creating new user now correctly checks for existing email address.
- Tester now correctly runs tests from multiple modules at once.
- Migrations now checks that the application helper is loaded.
- Config helper now allows apostrophes in config items.
- HMVC modules locations array moved to application/config.php so it won't be overwritten in the future.
- write_config() function now writes backups to application/archives like it should have been.

### Version 0.1 - Initial Release
Released: March 30, 2011


text:
## Incoming channels with wildcard URIs

Hosting in a dynamic environment, like Azure Service Fabric, can make it difficult to find the correct hostname to bind incoming channels to. Incoming channels with wildcard URIs are allowed from version 2.0.1 of the gateway to support this scenario.

The supported format is `http://+:port/{name of the endpoint}`. For example, `http://+:25899/` will listen on port 25899 on any IP/hostname available on the machine.

The channel URI  is used to populate the `ReplyTo` header of any messages sent by the gateway instance. Using a wildcard in the `ReplyTo` header makes little sense as it would not be routable back from a replying gateway. An additional default channel with a fully qualified URI is therefore required whenever incoming channels with wildcard URIs are used. The default channel uri will be used in the `ReplyTo` header of any message sent.

#### Example

snippet: configureWildcardGatewayChannel

branch_name: refs/heads/master

extension: md

gha_language: C#

gha_license_id: NOASSERTION

license_type: permissive


text:
[![Build Status](https://travis-ci.org/IBM/watson-second-opinion.svg?branch=master)](https://travis-ci.org/IBM/watson-second-opinion)

# Create a Review Analyzer with Watson Discovery

In this Code Pattern, we will create a Node.js app that takes the reviews from an online shopping website, Amazon, and feeds them into the Watson Discovery service. The reviews will be stored in a Cloudant or couchdb database. The Watson Discovery service will show the overall sentiments of the reviews. The sample application will do all the reading of reviews for you and will give an overall insight about them. The Code Pattern can be useful to developers that are looking into processing multiple documents with Watson Discovery.

When the reader has completed this Code Pattern, they will understand how to:

* Interact with Watson Discovery using Watson's Node SDK
* Build a user interface around the result of Watson Discovery
* Deploy the app in Kubernetes
* Deploy and connect a CouchDB in the same instance of Kubernetes Cluster

![Architecture](/docs/app-architecture.png)

## Flow
1. The user deploys the app in Kubernetes. The user interacts with the user interface of the app.
2. The user enters the product ID and the app would start getting the reviews of the Product.
3. The app then stores the reviews in a database for later use.
4. The app starts to upload the reviews in Watson Discovery.
5. After Watson Discovery finishes processing the reviews, the app then stores the result (General Sentiment and Top Entities) in the CouchDB. The user will see the result in the UI.

## Included components
* [Watson Discovery](https://www.ibm.com/watson/services/discovery/):  A cognitive search and content analytics engine for applications to identify patterns, trends, and actionable insights.
* [Kubernetes Cluster](https://console.bluemix.net/containers-kubernetes/catalogCluster): Create and manage your own cloud infrastructure and use Kubernetes as your container orchestration engine.

## Featured technologies
* [Node.js](https://nodejs.org/): An open-source JavaScript run-time environment for executing server-side JavaScript code.
* [Databases](https://en.wikipedia.org/wiki/IBM_Information_Management_System#.22Full_Function.22_databases): Repository for storing and managing collections of data.
* [Cloud](https://www.ibm.com/developerworks/learn/cloud/): Accessing computer and information technology resources through the Internet.

## Watch the Video

[![](docs/youtubePicture.png)](https://www.youtube.com/watch?v=wwNAEvbxd54&list=PLVztKpIRxvQXhHlMQttCfYZrDN8aELnzP&index=1&t=1s)

# Prerequisite

Create a Kubernetes cluster with either [Minikube](https://kubernetes.io/docs/getting-started-guides/minikube) for local testing, or with [IBM Bluemix Container Service](https://github.com/IBM/container-journey-template/blob/master/README.md) to deploy in cloud. The code here is regularly tested against [Kubernetes Cluster from Bluemix Container Service](https://console.ng.bluemix.net/docs/containers/cs_ov.html#cs_ov) using Travis.

Install [Docker](https://www.docker.com) by following the instructions [here](https://www.docker.com/community-edition#/download) for your preferred operating system.
You would also need a Docker Registry. [Docker Hub](https://hub.docker.com/) lets you create one quickly.

# Steps

1. [Clone the repo](#1-clone-the-repo)
2. [Create IBM Cloud services](#2-create-ibm-cloud-services)
3. [Build your Docker image](#3-build-your-docker-image)
4. [Configure deployment files](#4-configure-deployment-files)
5. [Deploy the application](#5-deploy-the-application)
6. [Search for a product in Amazon](#6-search-for-a-product-in-amazon)

## Deploy to IBM Cloud

[![Deploy to Bluemix](https://metrics-tracker.mybluemix.net/stats/7044d7c07bc30cff6a6c2a52e804ad8a/button.svg)](https://bluemix.net/deploy?repository=https://github.com/IBM/watson-review-analyzer.git)

1. Create the following service:
    * [**Watson Discovery**](https://console.ng.bluemix.net/catalog/services/discovery)
    * [**IBM Cloud Kubernetes**](https://console.bluemix.net/containers-kubernetes/catalog/cluster)
      > You can use an existing IBM Cloud Kubernetes cluster

2. Press the above `Deploy to IBM Cloud`
    > The toolchain uses GitHub for its source control. You may be asked to authenticate the toolchain to use your account. The toolchain will clone this repo and will be used for its deployment.
3. Fill out the following fields.
    * If you don't have an API key for your account, create one [here](https://console.ng.bluemix.net/iam/#/apikeys)
    * For the cluster name, choose the one you have created
    * For the image registry namespace, use an existing one if you have previously created an [IBM Cloud Container Registry](https://console.bluemix.net/containers-kubernetes/registry/start) or use a unique name for yourself. The toolchain will create one for you if the namespace is existing
      > Toolchain will fail if the namespace is taken
    * For the Discovery username and Discovery password, use the one you have just created
![fields](docs/fields.png)

4. The IP address of your app can be found in the logs of the delivery pipeline's deploy stage.
![deploy](docs/deploy.png)
![link](docs/link.png)

## Deploy to Kubernetes

### 1. Clone the repo

```
$ git clone https://github.com/IBM/watson-second-opinion
$ cd watson-second-opinion/
```

### 2. Create IBM Cloud services

Create the following service:

* [**Watson Discovery**](https://console.ng.bluemix.net/catalog/services/discovery)
* [**IBM Cloud Kubernetes**](https://console.bluemix.net/containers-kubernetes/catalog/cluster)

### 3. Build your Docker image
Login to Docker using your username and password for your Docker Registry.

```
$ docker login
```

The Node.js app will be packaged into a Docker image. This will be used by the Kubernetes Cluster.

```
$ docker build -t YOUR_DOCKERHUB_USERNAME/watson-review-analyzer:1.0 .
$ docker push YOUR_DOCKERHUB_USERNAME/watson-review-analyzer:1.0
```

### 4. Configure deployment files
Login to IBM Cloud (formerly called Bluemix). If not an IBM employee, use your IBM Cloud account username and password to login

```
$ bx login
```

If IBM employee, use --sso option and follow link for one time code, and use it to login.

```
$ bx login --sso
```

After you are logged in to IBM Cloud, you should see something like this:

```
API endpoint: https://api.ng.bluemix.net

One Time Code (Get one at https://iam-id-2.ng.bluemix.net/identity/passcode)>
Authenticating...
OK

Targeted account IBM (d5a44c1--------1a852cef31136c)

Targeted resource group default

API endpoint:     https://api.ng.bluemix.net (API version: 2.92.0)
Region:           us-south
User<EMAIL_ADDRESS>Account:          IBM (d5a44c1--------1a852cef31136c)
Resource group:   default
```

Next, setup kubectl to use your cluster

```
$ bx cs cluster-config <your-cluster-name>
```
Use the configuration for your cluster by exporting the environment variables - copy and paste the full line starting with:

```
$ export KUBECONFIG=
```

Add your Watson Discovery credentials in `config.json.sample` and rename it to `config.json`:

![Discovery Credentials](docs/discovery-credentials.png)

`config.json`:
```
{
  "discoveryUsername" : "YOUR_WATSON_DISCOVERY_USERNAME",
  "discoveryPassword" : "YOUR_WATSON_DISCOVERY_PASSWORD"
}
```

Create configmap in Kubernetes for `config.json`

```
$ kubectl create configmap watson-discovery-config --from-file=config.json
```

Modify `watson-review-analyzer.yaml`. In the line where you specify the image name, use the docker image you just built.
Change `horeaporutiu/watson-review-analyzer:2.1` to `YOUR_DOCKERHUB_USERNAME/watson-review-analyzer:1.0`.

    spec:
      containers:
        - image: horeaporutiu/watson-review-analyzer:2.1
          imagePullPolicy: Always
          name: watson-reviews

### 5. Deploy the application

Deploy the CouchDB database. This is where the reviews and Watson Discovery results will be stored.

```
$ kubectl apply -f couchdb.yaml
```

Deploy the Watson Review Analyzer app.

```
$ kubectl apply -f watson-review-analyzer.yaml
```

Check if your Pods are running. You should see a couchdb pod and the watson-review-analyzer pod.

```
$ kubectl get pods

NAME                                         READY     STATUS    RESTARTS   AGE
couchdb-deployment-78c87bf5bf-2nhc2          1/1       Running   0          4d
watson-reviews-deployment-859b8d454f-4zxkw   1/1       Running   0          4d
```

You can access the application in the browser via the Load Balancer's IP (External IP).
If you don't have the Load Balancer enabled, you can access it through one of your Kubernetes' worker IP and service Node port of watson-review-analyzer.

$ kubectl get service

NAME             CLUSTER-IP       EXTERNAL-IP      PORT(S)          AGE
couchdb          <IP_ADDRESS>    169.xy.xyz.220   5984:32402/TCP   13d
kubernetes       <IP_ADDRESS>       &ltnone&gt           443/TCP          27d
watson-reviews   <IP_ADDRESS>   169.48.xyz.221   80:31385/TCP     15m

If you don't have the Load Balancer and need the worker IP:

$ bx cs workers YOUR_CLUSTER_NAME

OK
ID                                                 Public IP       Private IP       Machine Type   State    Status   Zone    Version
kube-dal12-cr5c30966926aa444f9c02c72d5c3e1ca5-w1   169.xy.xyz.35   <IP_ADDRESS>   b2c.16x64      normal   Ready    dal12   1.8.6_1506*

Go to `169.xy.xyz.221` or `169.xy.xyz.35:31385` (for clusters without a Load Balancer)

![Landing Page](docs/empty.png)

### 6. Search for a product in Amazon

To use the app, search for the product you want the reviews to be uploaded to Watson Discovery and get its product ID (ASIN).

`https://www.amazon.com/Samsung-Thinnest-Premium-Anti-Scratch-Protective/dp/`**`B06XZ2CM2H`**`/ref=cm_cr_arp_d_product_top?ie=UTF8`

In this case, the product ID is **B06XZ2CM2H**

![Landing Page](docs/analysis.png)

Go ahead and press `Go`.

After Watson Discovery finishes processing all the reviews, the app should show you its General Sentiment and Top entities found.

![Landing Page](docs/concepts.png)

# Privacy Notice

Sample Kubernetes Yaml file that includes this package may be configured to track deployments to [IBM Cloud](https://www.bluemix.net/) and other Kubernetes platforms. The following information is sent to a [Deployment Tracker](https://github.com/IBM/metrics-collector-service) service on each deployment:

* Kubernetes Cluster Provider(`IBM Cloud, Minikube, etc`)
* Kubernetes Cluster ID (Only from IBM Cloud's cluster)

This data is collected from the Kubernetes Job in the sample application's yaml file. This data is used by IBM to track metrics around deployments of sample applications to IBM Cloud to measure the usefulness of our examples so that we can continuously improve the content we offer to you. Only deployments of sample applications that include code to ping the Deployment Tracker service will be tracked.

## Disabling Deployment Tracking

Please comment out/remove the Metric Kubernetes Job portion in the `watson-review-analyzer.yaml` file.

# Links

* [Watson Node.js SDK](https://github.com/watson-developer-cloud/node-sdk)

# Learn more

* **Node.js Code Patterns**: Enjoyed this Code Pattern? Check out our other [Node.js Code Patterns](https://developer.ibm.com/code/technologies/node-js/)
* **Artificial Intelligence Code Patterns**: Enjoyed this Code Pattern? Check out our other [AI Code Patterns](https://developer.ibm.com/code/technologies/artificial-intelligence/).
* **AI and Data Code Pattern Playlist**: Bookmark our [playlist](https://www.youtube.com/playlist?list=PLzUbsvIyrNfknNewObx5N7uGZ5FKH0Fde) with all of our Code Pattern videos
* **With Watson**: Want to take your Watson app to the next level? Looking to utilize Watson Brand assets? [Join the With Watson program](https://www.ibm.com/watson/with-watson/) to leverage exclusive brand, marketing, and tech resources to amplify and accelerate your Watson embedded commercial solution.

# License
[Apache 2.0](LICENSE)

repository: chyangzhang/wso-demo

repo_name: chyangzhang/wso-demo


text:
### SUMMARY
List and description of the tasks achieved.

### CHECKLIST
Code Review
✓ Performed a personal code review.

✓ Completed any relevant TODOs or documented them in an easily discoverable location; e.g. Slack, comments.

✓ A full project compilation completes without issue.

✓ Scala Checkstyle reports zero warnings.

✓ No unnecessary or leftover dependencies or imports.

✓ All files modified follow the expected convention for the language they are written in; whitespace, format, spelling, etc.

✓ Ensured that the test coverage is above 80%.

repository: girdharshubham/sparkle

repo_name: girdharshubham/sparkle


text:
# GistPy

Clones all your (private) gists for you

Note: `py Clone.py` will dump all gists in current working directory.

You will be asked for user and password during execution.

## Credit

Special Thanks to Jan-Piet Mens and his [Post](https://jpmens.net/2019/04/03/backup-all-my-gists/).
Unfortunately his script wasn't functional any more.

I just added user and password prompt and fixed the clone command.

license: MIT

repository: Gustice/GistPy

repo_name: Gustice/GistPy


text:
# Value Obtainer

[![Build Status](https://travis-ci.org/Wiredcraft/value-obtainer.svg?branch=master)](https://travis-ci.org/Wiredcraft/value-obtainer) [![Coverage Status](https://coveralls.io/repos/github/Wiredcraft/value-obtainer/badge.svg?branch=master)](https://coveralls.io/github/Wiredcraft/value-obtainer?branch=master)

Function builder.

Build a function that validates a value or a sub-element of an object (any level) and returns it.

repository: Wiredcraft/value-obtainer

repo_name: Wiredcraft/value-obtainer


text:
---
title: Creating my own black wash
tags: terrain
date: 2020-08-29
layout: post
---

![image-20200829220549682](image-20200829220549682.png)

I followed instruction of Black Magic Craft to make my own black wash and was incredibly happy with the results. One layer on primed miniatures already showed the details more sharply.

![image-20200829220636124](image-20200829220636124.png)

Also worked well on some tiles I was crafting to test some colors chemes. It really tones down the color so I really shouldn't be afraid of using bright colors.

branch_name: refs/heads/main

gha_language: JavaScript

gha_license_id: MIT


text:
# Live Departure Board Service (ldbs-json)
This is a node module that will interface to the National Rail Enquiries **Live Departure Boards Service** which powers the Live Departure Boards and the **Live Departure Boards Staff Service** which powers the Staff Version of the Live Departure Boards. More details can be found here:

 * [user service OpenLDBWS](https://lite.realtime.nationalrail.co.uk/OpenLDBWS/)
 * [staff service OpenLDBSVWS](https://lite.realtime.nationalrail.co.uk/OpenLDBSVWS/)

 It is designed to deliver the XML data returned by both API's in JSON format.

 # Using the module
 The first step is to install the module into your node project
  - **npm install -s ldbs-json**

Then to test just do the following
```
const useStaffVersion = false;
const LiveDepartureBoardService = require('ldbs-json');
const token = "0000-0000-0000-0000"; // put a valid token here

// Set up the options for the call
const options = {
  numRows: 2,
  crs:"KGX",
};

// Now do the required query
// note that if in an async function you can use await rather that .then
const api = new LiveDepartureBoardService(token, useStaffVersion);
api.call("GetDepBoardWithDetails", options).then(board => {
  console.log(board);
});

```

There are 3 examples ( two STAFF versions and one USER version that can be found in the included *examples* directory of the project). The additional staff version is to access the Reference Data Enpoint calls (this example uses **GetStationList**).

This module is a continuation from my other module https://www.npmjs.com/package/ldbws-json which was only for use with the USER version of the OpenLDBWS web service.

## Updates May 2020
This update has replaced the user of the **request** module and it now uses **node-fetch**. Some simple error checks on the return status of the API are now made and the examples have also been updated.

## New Options for the api.call() method (Dec 2019)
The API will still work as it did but there are 2 new (optional) flags that can be past in when making an API call. The call now :

- api.call(*method*, *options*, *useRef*, *withAttributes*)

The parameters **method** and **options** are the same as they were but there are 2 new options **useRef** and **withAttributes** (both default to false so have no impact if not specified).

 - **useRef** can be set to true so that a Staff API call can access the Reference Data Endpoint
 - **withAttributes** can be set to true to stop the attributes  being stripped from the result. **NB: setting this to true will change the JSON data structure returned**.

# Acknowledgements
- The LDBS-JSON module is powered by National Rail Enquiries.

repository: dwaynedibleyuk/ldbs-json

repo_name: dwaynedibleyuk/ldbs-json


text:
# BlockBench Deployment Scripts

## Setup
Run the `install.sh` script inside `ethereum` , `hyperledger` and `quorum` directory to install `geth` and
hyperledger-fabric respectively. Both need `sudo` privilege.
More details in [ethereum](ethereum/README.md), [hyperledger](hyperledger/README.md) , [parity](pairty/README.md) , [quorum_raft](quorum_raft/README.md) and [quorum_vote](quorum_vote/README.md) directories

## Source structure
+ Smart contract sources are in `contracts` directory
+ Instructions and scripts to run benchmarks for Ethereum, Hyperledger , Parity and Quorum are in [ethereum](ethereum),
[hyperledger](hyperledger) , [parity](pairty) , [quorum_raft](quorum_raft) and [quorum_vote](quorum_vote) directories respectively

## Others
+ Notes on implementation and deployment:
    + [Smart contracts in Ethereum & Parity & quorum](ethereum/contracts.md)
    + [Chaincode in Hyperledger](hyperledger/contracts.md)


text:
---
title: AWS Local Development with LocalStack
date: 2019-07-20
draft: false
featured: false
comment: true
toc: true
reward: false
pinned: false
carousel: false
featuredImage: false
# series:
#   - API development with R
categories:
  - Development
tags:
  - AWS
  - Docker
  - Docker Compose
  - AWS Lambda
  - LocalStack
  - S3
  - SQS
  - Python
  - Flask
  - Flask-RestPlus
authors:
  - JaehyeonKim
images: []
description: LocalStack provides an easy-to-use test/mocking framework for developing AWS applications. In this post, I'll demonstrate how to utilize LocalStack for development using a web service.
---

[LocalStack](https://github.com/localstack/localstack) provides an easy-to-use test/mocking framework for developing AWS applications. In this post, I'll demonstrate how to utilize LocalStack for development using a web service.

Specifically a simple web service built with [Flask-RestPlus](https://flask-restplus.readthedocs.io/en/stable/) is used. It supports simple CRUD operations against a database table. It is set that SQS and Lambda are used for creating and updating a record. When a _POST_ or _PUT_ request is made, the service sends a message to a SQS queue and directly returns _204_ reponse. Once a message is received, a Lambda function is invoked and a relevant database operation is performed.

The source of this post can be found [here](https://github.com/jaehyeon-kim/play-localstack).

## Web Service

As usual, the _GET requests_ returns all records or a single record when an ID is provided as a path parameter. When an ID is not specified, it'll create a new record (_POST_). Otherwise it'll update an existing record (_PUT_). Note that both the _POST_ and _PUT_ method send a message and directly returns _204_ response - the source can be found [here](https://github.com/jaehyeon-kim/play-localstack/blob/master/api/namespace/records.py).

```python
ns = Namespace("records")

@ns.route("/")
class Records(Resource):
    parser = ns.parser()
    parser.add_argument("message", type=str, required=True)

    def get(self):
        """
        Get all records
        """
        conn = conn_db()
        cur = conn.cursor(real_dict_cursor=True)
        cur.execute(
            """
            SELECT * FROM records ORDER BY created_on DESC
            """)

        records = cur.fetchall()
        return jsonify(records)

    @ns.expect(parser)
    def post(self):
        """
        Create a record via queue
        """
        try:
            body = {
                "id": None,
                "message": self.parser.parse_args()["message"]
            }
            send_message(flask.current_app.config["QUEUE_NAME"], json.dumps(body))
            return "", 204
        except Exception as e:
            return "", 500

@ns.route("/<string:id>")
class Record(Resource):
    parser = ns.parser()
    parser.add_argument("message", type=str, required=True)

    def get(self, id):
        """
        Get a record given id
        """
        record = Record.get_record(id)
        if record is None:
            return {"message": "No record"}, 404
        return jsonify(record)

    @ns.expect(parser)
    def put(self, id):
        """
        Update a record via queue
        """
        record = Record.get_record(id)
        if record is None:
            return {"message": "No record"}, 404

        try:
            message = {
                "id": record["id"],
                "message": self.parser.parse_args()["message"]
            }
            send_message(flask.current_app.config["QUEUE_NAME"], json.dumps(message))
            return "", 204
        except Exception as e:
            return "", 500

    @staticmethod
    def get_record(id):
        conn = conn_db()
        cur = conn.cursor(real_dict_cursor=True)
        cur.execute(
            """
            SELECT * FROM records WHERE id = %(id)s
            """, {"id": id})

        return cur.fetchone()
```

## Lambda

The SQS queue that messages are sent by the web service is an event source of the following [lambda function](https://github.com/jaehyeon-kim/play-localstack/blob/master/init/lambda_package/lambda_function.py). It polls the queue and processes messages as shown below.

```python
import os
import logging
import json
import psycopg2

logger = logging.getLogger()
logger.setLevel(logging.INFO)

try:
    conn = psycopg2.connect(os.environ["DB_CONNECT"], connect_timeout=5)
except psycopg2.Error as e:
    logger.error(e)
    sys.exit()

logger.info("SUCCESS: Connection to DB")

def lambda_handler(event, context):
    for r in event["Records"]:
        body = json.loads(r["body"])
        logger.info("Body: {0}".format(body))
        with conn.cursor() as cur:
            if body["id"] is None:
                cur.execute(
                    """
                    INSERT INTO records (message) VALUES (%(message)s)
                    """, {k:v for k,v in body.items() if v is not None})
            else:
                cur.execute(
                    """
                    UPDATE records
                       SET message = %(message)s
                     WHERE id = %(id)s
                    """, body)
    conn.commit()

    logger.info("SUCCESS: Processing {0} records".format(len(event["Records"])))
```

## Database

As RDS is not yet supported by LocalStack, a postgres db is created with Docker. The web service will do CRUD operations against the table named as _records_. The [initialization SQL script](https://github.com/jaehyeon-kim/play-localstack/blob/master/init/db/run.sql) is shown below.

```sql
CREATE DATABASE testdb;
\connect testdb;

CREATE SCHEMA testschema;
GRANT ALL ON SCHEMA testschema TO testuser;

-- change search_path on a connection-level
SET search_path TO testschema;

-- change search_path on a database-level
ALTER database "testdb" SET search_path TO testschema;

CREATE TABLE testschema.records (
	id serial NOT NULL,
	message varchar(30) NOT NULL,
	created_on timestamptz NOT NULL DEFAULT now(),
	CONSTRAINT records_pkey PRIMARY KEY (id)
);

INSERT INTO testschema.records (message)
VALUES ('foo'), ('bar'), ('baz');
```

## Launch Services

Below shows the [docker-compose file](https://github.com/jaehyeon-kim/play-localstack/blob/master/docker-compose.yml) that creates local AWS services and postgres database.

```yaml
version: '3.7'
services:
  localstack:
    image: localstack/localstack
    ports:
      - '4563-4584:4563-4584'
      - '8080:8080'
    privileged: true
    environment:
      - SERVICES=s3,sqs,lambda
      - DEBUG=1
      - DATA_DIR=/tmp/localstack/data
      - DEFAULT_REGION=ap-southeast-2
      - LAMBDA_EXECUTOR=docker-reuse
      - LAMBDA_REMOTE_DOCKER=false
      - LAMBDA_DOCKER_NETWORK=play-localstack_default
      - AWS_ACCESS_KEY_ID=foobar
      - AWS_SECRET_ACCESS_KEY=foobar
      - AWS_DEFAULT_REGION=ap-southeast-2
      - DB_CONNECT='postgresql://testuser:testpass@postgres:5432/testdb'
      - TEST_QUEUE=test-queue
      - TEST_LAMBDA=test-lambda
    volumes:
      - ./init/create-resources.sh:/docker-entrypoint-initaws.d/create-resources.sh
      - ./init/lambda_package:/tmp/lambda_package
      # - './.localstack:/tmp/localstack'
      - '/var/run/docker.sock:/var/run/docker.sock'
  postgres:
    image: postgres
    ports:
      - 5432:5432
    volumes:
      - ./init/db:/docker-entrypoint-initdb.d
    depends_on:
      - localstack
    environment:
      - POSTGRES_USER=testuser
      - POSTGRES_PASSWORD=testpass
```

For LocalStack, it's easier to illustrate by the environment variables.

* SERVICES - _S3, SQS and Lambda_ services are selected
* DEFAULT_REGION - Local AWS resources will be created in _ap-southeast-2_ by default
* LAMBDA_EXECUTOR - By selecting _docker-reuse_, Lambda function will be invoked by another container (based on [lambci/lambda](https://github.com/lambci/lambci) image). Once a container is created, it'll be reused. Note that, in order to invoke a Lambda function in a separate Docker container, it should run in privileged mode (**privileged: true**)
* LAMBDA_REMOTE_DOCKER - It is set to _false_ so that a Lambda function package can be added from a local path instead of a zip file.
* LAMBDA_DOCKER_NETWORK - Although the Lambda function is invoked in a separate container, it should be able to discover the database service (_postgres_). By default, Docker Compose creates a network (`<parent-folder>_default`) and, specifying the network name, the Lambda function can connect to the database with the DNS set by *DB_CONNECT*

Actual AWS resources is created by [*create-resources.sh*](https://github.com/jaehyeon-kim/play-localstack/blob/master/init/create-resources.sh), which will be executed at startup. A SQS queue and Lambda function are created and the queue is mapped to be an event source of the Lambda function.

```bash
#!/bin/bash

echo "Creating $TEST_QUEUE and $TEST_LAMBDA"

aws --endpoint-url=http://localhost:4576 sqs create-queue \
    --queue-name $TEST_QUEUE

aws --endpoint-url=http://localhost:4574 lambda create-function \
    --function-name $TEST_LAMBDA \
    --code S3Bucket="__local__",S3Key="/tmp/lambda_package" \
    --runtime python3.6 \
    --environment Variables="{DB_CONNECT=$DB_CONNECT}" \
    --role arn:aws:lambda:ap-southeast-2:000000000000:function:$TEST_LAMBDA \
    --handler lambda_function.lambda_handler \

aws --endpoint-url=http://localhost:4574 lambda create-event-source-mapping \
    --function-name $TEST_LAMBDA \
    --event-source-arn arn:aws:sqs:elasticmq:000000000000:$TEST_QUEUE
```

The services can be launched as following.

```bash
docker-compose up -d
```

## Test Web Service

Before testing the web service, it can be shown how the SQS and Lambda work by sending a message as following.

```sh
aws --endpoint-url http://localhost:4576 sqs send-message \
    --queue-url http://localhost:4576/queue/test-queue \
    --message-body '{"id": null, "message": "test"}'
```

As shown in the image below, LocalStack invokes the Lambda function in a separate Docker container.

![](send-message.png#center)

The web service can be started as following.

```sh
FLASK_APP=api FLASK_ENV=development flask run
```

Using [HttPie](https://httpie.org/), the record created just before can be checked as following.

```bash
http http://localhost:5000/api/records/4
```

```json
{
    "created_on": "2019-07-20T04:26:33.048841+00:00",
    "id": 4,
    "message": "test"
}
```

For updating it,

```bash
echo '{"message": "test put"}' | \
    http PUT http://localhost:5000/api/records/4

http http://localhost:5000/api/records/4
```

```json
{
    "created_on": "2019-07-20T04:26:33.048841+00:00",
    "id": 4,
    "message": "test put"
}
```

gha_language: Dockerfile


text:
# habitat snippets

These are a collection of [habitat][habitat] snippets for [text-mate][text], or [yasnippet][ya].

# Usage

## emacs
For emacs with yasnippet, I suggest you create a `~/.emacs.d/snippets/sh-mode` directory
and place these in there. When working on most of the habitat files, they will be
in the `sh-mode`.

## text-mate

TODO

## Contributing
1. Fork the repository on Github
2. Create a named feature branch (like `add_component_x`)
3. Write your change
4. Write tests for your change (if applicable)
5. Run the tests, ensuring they all pass
6. Submit a Pull Request using Github

## License and Authors
- Author:: JJ Asghar<EMAIL_ADDRESS>
```text
Copyright 2016 JJ Asghar

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```

[habitat]: https://www.habitat.sh
[text]: https://macromates.com/
[ya]: https://github.com/joaotavora/yasnippet

repository: jjasghar/habitat-snippets

repo_name: jjasghar/habitat-snippets


text:
# Policial :cop:

[![Gem Version](https://badge.fury.io/rb/policial.svg)](http://badge.fury.io/rb/policial)
[![Build Status](https://travis-ci.org/volmer/policial.svg)](https://travis-ci.org/volmer/policial)

*Policial* is a gem that investigates pull requests and accuses style guide
violations. It is based on thoughtbot's
[Hound project](https://github.com/thoughtbot/hound).
It currently supports RuboCop, SCSS and CoffeeLint.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'policial'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install policial

## Usage

1. First, instantiate a new Detective:
  ```ruby
  detective = Policial::Detective.new
  ```

  You might need to pass an Octokit client with your GitHub credentials.
  For more information on this please check the
  [Octokit README](https://github.com/octokit/octokit.rb).

  ```ruby
  octokit = Octokit::Client.new(access_token: 'mygithubtoken666')
  detective = Policial::Detective.new(octokit)
  ```
  If you don't pass an Octokit client Policial will use the global Octokit
  configuration.

2. Let's investigate! Start by briefing your detective about the pull request it
  will run an investigation against. You can setup a pull request manually:

  ```ruby
  detective.brief(
    repo: 'volmer/my_repo',
    number: 3,
    head_sha: 'headsha'
  )
  ```

  _N. B._ It's important to configure
  [auto pagination](<https://github.com/octokit/octokit.rb#auto-pagination>)
  for your client to receive reliable results on PRs with lot of files.

  Or you can brief it with a
  [GitHub `pull_request` webhook](https://developer.github.com/webhooks):

  ```ruby
  event = Policial::PullRequestEvent.new(webhook_payload)
  detective.brief(event)
  ```

3. Now you can run the investigation using the linters you want:

  ```ruby
  # Let's investigate this pull request and get a list of violations:
  result = detective.investigate(linters: [Policial::Linters::RuboCop.new])
  result.violations
  # => [#<Policial::Violation:0x007ff0b5abad30 @filename="lib/test.rb", @line_number=1, ...>]

  result.violations.first.message
  "Prefer single-quoted strings when you don't need string interpolation or special symbols."
  ```

## RuboCop

You can setup your RuboCop code style rules with a `.rubocop.yml` file in
your repo. Please see [RuboCop's README](https://github.com/bbatsov/rubocop).

## CoffeeLint

You can setup your CoffeeLint code style rules with a `coffeelint.json`
file in your repo. For more information on how customize the linter rules please
visit the [Coffeelint website](http://coffeelint.org).

## SCSS

SCSS linting is disabled by default. To enable it, you need to install the
[SCSS-Lint](https://github.com/brigade/scss-lint) gem:

```
gem install scss_lint
```

Or add the following to your `Gemfile` and run `bundle install`:

```ruby
gem 'scss_lint', require: false
```

The `require: false` is necessary because `scss-lint` monkey patches `Sass`.
More info [here](https://github.com/brigade/scss-lint#installation).

Now you can use the SCSSLint linter when calling `Detective#investigate`:

```ruby
violations = detective.investigate(linters: [Policial::Linters::SCSSLint.new])
```

You can setup your SCSS code style rules with a `.scss-lint.yml` file in your
repo. For more information on how customize the linter rules please
read [SCSS-Lint's README](https://github.com/brigade/scss-lint#configuration).

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request


text:
Compass-
========

This is a compass made with the HTML5 canvas and JavaScript. You can see a live demo at [http://codepen.io/JoshuaCarroll/pen/dXVoVV](http://codepen.io/JoshuaCarroll/pen/dXVoVV).

----------

# Usage

1. Clone the repo or otherwise copy the compass.js file into your web site.

2. Add a reference to the script in your HTML.

    `<script src="compass.js"></script>`

3. In the body of your HTML document, add a canvas object with an ID.

    `<canvas id="canvasCompass" width="200" height="200"></canvas>`

4. Add a script to instantiate a Compass object, and give it a default value.

``` javascript
    <script>
        var compass = new Compass("canvasCompass");
        compass.set(1);
    </script>
```

5. Call animateCompass to change the value of the compass at any time.

    `compass.animate(95);`

repository: JoshuaCarroll/Compass-

repo_name: JoshuaCarroll/Compass-


text:
POC CloudAMQP

  Techs   |
  Project   |
  License

## 🚀 Techs

Technologies used in this project.

- [Node](https://nodejs.org/en/)
- [Typescript](https://www.typescriptlang.org/)
- [amqplib](https://www.npmjs.com/package/amqplib)

## 💻 Project

This project is a **POC** from cloudAMQP lib.

Test this project.

Needs to create `.env` file with `AMQP_URL` environment.

Servie to create AMQP_URL -> https://cloudamqp.com

```shell
yarn

yarn consumer:station
yarn consumer:customer-saver
yarn consumer:crm

yarn producer:station
```

---

Station -> Station.
```js

```

---

Station -> [Customer-Saver, CRM].
```js

```

---

Station -> [CRM].
```js

```

---

Station -> Station with priority.
```js

```

---

Station -> Station with retry.
```js

```

## 📝 License

Used MIT license.

---

By

[👽 Roberto Umbelino](https://github.com/robertoumbelino)

[👽 Anderson Espindola](https://github.com/andersonespindola)

repository: robertoumbelino/cloudamqp

repo_name: robertoumbelino/cloudamqp


text:
---
hrs_structure:
  division: '3'
  volume: '12'
  title: '28'
  chapter: 514A
  section: 514A-104.5
type: hrs_section
tags:
  - Property
  - Family
menu:
  hrs:
    identifier: HRS_0514A-0104_0005
    parent: HRS0514A
    name: 514A-104.5 Affidavit
weight: 32530
title: Affidavit
full_title: 514A-104.5 Affidavit
---
**§514A-104.5 Affidavit.** (a) The owner-occupant affidavit required by section 514A-104 shall expire after three hundred sixty-five consecutive days have elapsed after the recordation of the instrument conveying the apartment to the affiant. The affidavit shall expire prior to this period upon acquisition of title to the property by an institutional lender or investor through mortgage foreclosure, foreclosure under power of sale, or a conveyance in lieu of foreclosure.

(b) The affidavit shall include statements by the affiant affirming that the affiant shall notify the commission immediately upon any decision to cease being an owner-occupant.

(c) The affidavit shall be personally executed by all the prospective owner-occupants of the residential apartment and shall not be executed by an attorney-in-fact. [L 1992, c 50, pt of §1; am L 1993, c 217, §1; am L 1997, c 135, §15; am L 2000, c 210, §6]

repository: SamMade/BlueAndKrabby

repo_name: SamMade/BlueAndKrabby


text:
A powerful and elegant C# library for Razer Chroma's SDK.

| | GitHub | AppVeyor | Travis |
|-|-|-|-|
| [**`master`**][master] | [![Workflow status][gha-master-badge]][gha-master] | [![Build status][appveyor-master-badge]][appveyor-master-status] | [![TravisCI Status][travis-master-badge]][travis-master-status] |
| [**`develop`**][develop] | [![Workflow status][gha-develop-badge]][gha-develop] | [![Build status][appveyor-develop-badge]][appveyor-develop-status] | [![TravisCI Status][travis-develop-badge]][travis-develop-status] |

| [`master`][master] | [![Test status][test-master-badge]][test-master-status] | [![Codecov coverage][codecov-master-badge]][codecov-master] | [![CodeFactor][codefactor-master-badge]][codefactor-master] |
|-|-|-|-|
| [**`develop`**][develop] | [![Test status][test-develop-badge]][test-develop-status] | [![Codecov coverage][codecov-develop-badge]][codecov-develop] | [![CodeFactor][codefactor-develop-badge]][codefactor-develop] |

Getting started
---------------

If you are a new developer and are looking for a helpful guide on how to get started, head on over to the [documentation](https://chroma-sdk.github.io/Colore/docs/articles/getting-started.html) which describes getting Colore installed and running some example code.

Contributing
------------

[![Discussions][discussions-badge]][discussions]
[![Discord][discordbadge]][discord]

*For discussing, you can [discuss right here in the repo][discussions] or join the Razer Community Discord server using the badges above. If you want to join the Slack chat, contact [Adam Hellberg][sharp] ([sharparam@sharparam.com](mailto:sharparam@sharparam.com)).*

Contributors are very welcome! If you have code fixes, please [submit a pull request][newpull] here on GitHub.

If you want to join the development team, please contact [Sharparam][sharp] on GitHub.

All authors and contributors are listed in the [`AUTHORS`](AUTHORS) file.
Feel free to add yourself to this file under a relevant section in your pull request.

Please read the [`CONTRIBUTING.md`](CONTRIBUTING.md) file before making a pull request.

### Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct][coc].
By participating in this project you agree to abide by its terms.

License
-------

Copyright © 2015-2021 by [Adam Hellberg][sharp] and [Brandon Scott][bs].

This project is licensed under the MIT license, please see the file [`LICENSE`](LICENSE) for more information.

Razer is a trademark and/or a registered trademark of Razer USA Ltd.
All other trademarks are property of their respective owners.

Installing
----------

Using Colore in your project is simple, all you have to do is install it with NuGet!

```powershell
Install-Package Colore
```

Or using the .NET CLI tools:

```powershell
dotnet add package Colore
```

You can also search for it in Visual Studio by right clicking your project and choosing "Manage NuGet Packages..." and install it the GUI way.

### Pre-releases

New release candidate versions will be uploaded to NuGet and marked as pre-releases there (vX.Y.Z-rcDDDD).

You can also find pre-release versions for [Colore][gpr-colore] and any additional extensions in [the GitHub package registry][gpr]. The GitHub package registry will be the place where you'll always find the most bleeding edge packages.

### Extensions

The [WPF][colore-wpf] and [WinForms][colore-winforms] extension packages for Colore are not yet available for the new Colore version, but will be on NuGet soon™, so stay tuned!

Using
-----

Obtain a reference to an `IChroma` instance by calling `Colore.ColoreProvider.CreateNative()`.

This instance initializes the Chroma SDK so it is important you **save this reference** for the lifetime of your application!
If you need to dispose of it and obtain a new one later, be sure to call the uninitialize method first!

Colore supports binding to both the [native Chroma SDK][chroma-native] and the [REST API][chroma-rest].
To use the REST API, create an `IChroma` instance by calling `Colore.ColoreProvider.CreateRestAsync(AppInfo)`.
The REST API requires information about your application, so you'll have to pass an instance of `AppInfo` to `CreateRestAsync` containing details about your application or game.

For a more in-depth guide on how to get started, check out [our wiki][getting-started].

For more information on the native and REST SDKs that Colore uses, check out [Razer's official page for the Chroma SDK][rzdev] and their [page about SDK tools][chroma-sdk-tools].

Dependencies
------------

Colore depends on the Razer Chroma SDK (`RzChromaSDK64.dll` or `RzChromaSDK.dll`).

The Razer Chroma SDK is provided by Razer and installed together with the [Synapse application][synapse].
More information can be read [on their website][rzdev].

Other dependencies are installed via NuGet and listed in each project file.

Building
--------

Colore supports building for multiple target frameworks.
At the moment, these are .NET Standard 1.3 and .NET Framework 4.5.1.
When building the project, DLLs for both frameworks will be generated in the output folders, under the folder names `netstandard1.3` and `net451`.
Use the ones fitting for your application.

The below examples compiles Colore in Release mode.

```powershell
.\build.ps1 -Configuration Release
```

You can also use the "CI" build target to generate the same artifacts made available for each release of Colore.

```powershell
.\build.ps1 -Configuration Release -Target CI
```

You will find the resulting artifact files under the `artifacts` folder in the root of the repository.

Note that the above commands are executed with [PowerShell][ps]. If you are building on a Linux system or macOS,
use the `build.sh` script in place of `build.ps1` (you may have to make it executable first with `chmod +x build.sh`).

Native Documentation
--------------------
As Colore is built upon the native Chroma SDK for C++, it can be worth taking a look at their [documentation][chroma-native].

REST Documentation
------------------

Colore's REST mode is built on Razer's official REST API, which [has its own documentation][chroma-rest].

Razer Chroma Workshop
---------------------

Many of the games and apps featured on the [Razer Chroma Workshop][workshop] have used the Colore library.

The official [Razer Chroma Workshop][workshop] is your one-stop-shop to get the most out of your Chroma devices. Whether it's smart lighting based on in-game events, standalone apps or stunning profiles created by fans around the world, the Chroma Workshop is where you can explore, download and even share your own creations.

Games using Colore
------------------

The following games (powered by Unity) are using Colore:

[![DubWars](http://cdn.akamai.steamstatic.com/steam/apps/290000/capsule_184x69.jpg)](https://store.steampowered.com/app/290000/)
[![Masquerada: Songs and Shadows](http://cdn.akamai.steamstatic.com/steam/apps/459090/capsule_184x69.jpg)](https://store.steampowered.com/app/459090/)
[![Nevermind](http://cdn.akamai.steamstatic.com/steam/apps/342260/capsule_184x69.jpg)](https://store.steampowered.com/app/342260/)
[![Please, Don't Touch Anything 3D](http://cdn.akamai.steamstatic.com/steam/apps/529590/capsule_184x69.jpg)](https://store.steampowered.com/app/529590/)
[![Starcrawlers](http://cdn.akamai.steamstatic.com/steam/apps/318970/capsule_184x69.jpg)](https://store.steampowered.com/app/318970/)
[![The Little Acre](http://cdn.akamai.steamstatic.com/steam/apps/423590/capsule_184x69.jpg)](https://store.steampowered.com/app/423590/)

Projects using Colore
---------------------

[Aurora](https://www.project-aurora.com/) - Unified lighting effects across multiple brands and various games. ([GitHub](https://github.com/antonpup/Aurora))

There may be others we are unaware of, so please let us know if there are any others.

[coc]: CODE_OF_CONDUCT.md
[getting-started]: https://github.com/chroma-sdk/Colore/wiki/Getting-started
[newpull]: https://github.com/chroma-sdk/Colore/pull/new/develop
[sharp]: https://github.com/Sharparam
[contrib]: CONTRIBUTING.md
[bs]: https://github.com/brandonscott
[master]: https://github.com/chroma-sdk/Colore/tree/master
[develop]: https://github.com/chroma-sdk/Colore/tree/develop

[license]: https://opensource.org/licenses/MIT
[licensebadge]: https://img.shields.io/badge/license-MIT-blue.svg
[ghrelease]: https://github.com/chroma-sdk/Colore/releases
[ghreleasebadge]: https://img.shields.io/github/release/chroma-sdk/Colore.svg?logo=github
[ng]: https://www.nuget.org/packages/Colore
[ngverbadge]: https://img.shields.io/nuget/v/Colore.svg
[gpr]: https://github.com/chroma-sdk/Colore/packages
[gpr-colore]: https://github.com/chroma-sdk/Colore/packages/274021

[gha-develop]: https://github.com/chroma-sdk/Colore/actions?query=workflow%3ACI+branch%3Adevelop
[gha-develop-badge]: https://github.com/chroma-sdk/Colore/workflows/CI/badge.svg?branch=develop
[appveyor-develop-status]: https://ci.appveyor.com/project/chroma-sdk/colore/branch/develop
[appveyor-develop-badge]: https://ci.appveyor.com/api/projects/status/on4kfnasv564yhh9/branch/develop?svg=true
[travis-develop-status]: https://travis-ci.org/chroma-sdk/Colore
[travis-develop-badge]: https://travis-ci.org/chroma-sdk/Colore.svg?branch=develop
[test-develop-status]: https://ci.appveyor.com/project/chroma-sdk/colore/branch/develop/tests
[test-develop-badge]: https://img.shields.io/appveyor/tests/chroma-sdk/Colore/develop.svg
[codecov-develop]: https://codecov.io/gh/chroma-sdk/Colore/branch/develop
[codecov-develop-badge]: https://codecov.io/gh/chroma-sdk/Colore/branch/develop/graph/badge.svg
[codefactor-develop]: https://www.codefactor.io/repository/github/chroma-sdk/colore/overview/develop
[codefactor-develop-badge]: https://www.codefactor.io/repository/github/chroma-sdk/colore/badge/develop

[gha-master]: https://github.com/chroma-sdk/Colore/actions?query=workflow%3ACI+branch%3Amaster
[gha-master-badge]: https://github.com/chroma-sdk/Colore/workflows/CI/badge.svg?branch=master
[appveyor-master-status]: https://ci.appveyor.com/project/chroma-sdk/colore/branch/master
[appveyor-master-badge]: https://ci.appveyor.com/api/projects/status/on4kfnasv564yhh9/branch/master?svg=true
[travis-master-status]: https://travis-ci.org/chroma-sdk/Colore
[travis-master-badge]: https://travis-ci.org/chroma-sdk/Colore.svg?branch=master
[test-master-status]: https://ci.appveyor.com/project/chroma-sdk/colore/branch/master/tests
[test-master-badge]: https://img.shields.io/appveyor/tests/chroma-sdk/Colore/master.svg
[codecov-master]: https://codecov.io/gh/chroma-sdk/Colore
[codecov-master-badge]: https://codecov.io/gh/chroma-sdk/Colore/branch/master/graph/badge.svg
[codefactor-master]: https://www.codefactor.io/repository/github/chroma-sdk/colore/overview/master
[codefactor-master-badge]: https://www.codefactor.io/repository/github/chroma-sdk/colore/badge/master

[gitter]: https://gitter.im/chroma-sdk/Colore
[gitterbadge]: https://badges.gitter.im/Join%20Chat.svg
[discord]: https://discord.gg/4ysuMYK
[discordbadge]: https://img.shields.io/discord/342761229544194048.svg?label=discord&logo=discord
[discussions]: https://github.com/chroma-sdk/Colore/discussions
[discussions-badge]: https://img.shields.io/badge/github-discussions-brightgreen?logo=github

[colorelogo]: https://files.sharparam.com/2017/10/31/colore-logo.png
[colore-wpf]: https://github.com/chroma-sdk/Colore.Wpf
[colore-winforms]: https://github.com/chroma-sdk/Colore.WinForms

[rzdev]: https://developer.razer.com/chroma/
[chroma-sdk-tools]: https://developer.razer.com/works-with-chroma/download/
[synapse]: https://www.razer.com/synapse-3
[chroma-native]: https://assets.razerzone.com/dev_portal/C%2B%2B/html/en/index.html
[chroma-rest]: https://assets.razerzone.com/dev_portal/REST/html/index.html

[ps]: https://docs.microsoft.com/en-us/powershell/

[workshop]: https://www.razer.com/chroma-workshop

repository: ulasguner/Colore

repo_name: ulasguner/Colore


text:
# Objective

We are approached by a newly built library:

 > "We need an app where both the visitors and the library can see if a list of books is available, it would be nice to see both the title and the author of the book. The library needs to store these books in a file where we can easily check if a book is available or not. The library also needs the visitors to check out books after finding the title they want. Depending on the time of the checkout the library needs the books to be returned within a month and obviously, it would be nice for the visitor to know which date to return the book."

 #### Learning objectives from Craft Academy
* Practice TDD to drive your development process

* Adapt to a new domain

* Work with data stored in hashes and perform

* Learn about YAML

* Learn about storing information in a text file

* Practice writing documentation

* Learn to write user stories

* Practice Pair programming

# Problem statement
The library needs a simple and flexible way of tracking the books in their posession, checking the availability status of books, modifying their stock and allowing it's visitors to check out books on their own.

# User stories

```
As a Library
In order to know how many books I have
I would like a list of all the books in my possession
```

* Create the YAML file (unique code for every book, name of who we give it)
* Create Library Class
* Create an instance variable books for Library class
* Create a method to search the YAML file by title, the method returns all data
* Create a method to search the YAML file by author, the method returns all data

```
As a Library
In order to serve my visitors efficiently
I would like to check out books for my visitors.
```

* Create a method that checks out the book using the index number. It pushes in the "available" and "return_date" values in the YAML file.
* Create a class double for Visitor class and add the function that pushes "borrowed_by" value into the YAML file.

```
As a Library
In order to make new books accesible to public
I would like to be able to add new books to the system.
```

* Create a method to add new entries to the YAML file

```
As a Visitor
In order to be able to choose
I would like to be able to search the list of books
```

* Create Visitor Class (attribute name)
* Create a method to read the YAML file (no name access)
* Create a method to search the YAML file by title (no name access)
* Create a method to search the YAML file by author (no name access)

```
As a Visitor
In order not to wait in the line
I would like to be able to checkout a book by myself and know when to return it
```
* Create a method that lets a visitor checkout the book and prints a message with the return date

```
As a Library
In order to have my book list updated at all times
I would like to have a feature for returning books.
```

* Create a return_book method

```
As a Visitor
In order to know what books I am borrowing at the moment
I would like to have a feature to provide me a list of books and return dates.
```

* Create my_books method

# Authors' view on the scope

This is our first project using YAML. We noticed that the YAML file is doing us a favour and is acting like a bridge between Visitor and Library class. Therefore, we agreed that there is no need connecting these two classes via code.

We just gave different access levels to the YAML file, based on the class that the methods are called upon.

# Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on your Interactive Ruby Shell (IRB) system.

# Prerequisites

* You will need Ruby installed on your system.
* You will need Bundler installed on your system.
* You will need IRB installed on your system.

# Installing

Make sure you are in the project folder.

Run IRB in your Terminal:

`irb`

Load the visitor.rb file or library.rb file depending on what type of access you want to have.

`load './lib/visitor.rb'`

`load './lib/library.rb'`

You are good to go!

# Running the tests

After you fork the repository, run `bundle install` in your Terminal and make sure you are in the project folder. That should install RSPEC on your computer.

Then, from your Terminal go to the project folder and run `rspec`.

# Deployment
#### FROM THE VISITOR'S POINT OF VIEW

To create a library visitor, run

```
visitor = Visitor.new("name")
```

To view the list of books library has, run
```
visitor.view_books
```
To search a book by title, run
```
visitor.search_by_title("Book title or a part of it")
```

To search a book by author, run
```
visitor.search_by_author("Author's name and/or surname")
```

To checkout the book, run
```
visitor.checkout_book(book index number)
```
To see if you are currently borrowing any books, run

```
visitor.my_books
```

#### FROM THE LIBRARY'S POINT OF VIEW

To initialize a library run

```
library = Library.new
```

To search a book by title, run
```
library.search_by_title("Book title or a part of it")
```

To search a book by author, run
```
library.search_by_author("Author's name and/or surname")
```

To checkout the book, run
```
library.checkout_book(book index number, visitor's name)
```
To add a new book to your database, run
```
library.add_new_book(title, author)
```

To return a book, run
```
library.return_book(book index number)
```

# Built with

[Ruby](https://www.ruby-lang.org/en/) - The worlds best programming language.

# Tested with

[RSPEC](http://rspec.info) - Making TDD Productive and Fun.

# Authors

* **Zane Neikena** - [zanenkn](https://github.com/zanenkn)
* **George Tomaras** - [raptorf1](https://github.com/raptorf1)

# License

This project utilizes the MIT open-source license. https://opensource.org/licenses/MIT

# Acknowledgments

Kudos to [PurpleBooth](https://gist.github.com/PurpleBooth/109311bb0361f32d87a2) for the README template

repository: zanenkn/library-challenge

repo_name: zanenkn/library-challenge