Tutorial by Examples: ai

Configuration files for rails can be found in config/environments/. By default rails has 3 environments, development, production and test. By editing each file you are editing the configuration for that environment only. Rails also has a configuration file in config/application.rb. This is a common...
DISCLAIMER: Scaffolding is not recommended unless it's for very conventional CRUD apps/testing. This may generate a lot of files(views/models/controllers) that are not needed in your web application thus causing headaches(bad :(). To generate a fully working scaffold for a new object, including mod...
Any lodash collection method has two syntaxes. Without chaining: var arr1 = [10, 15, 20, 25, 30, 15, 25, 35]; var arr2 = _.filter(arr1, function(item){ return item % 10 === 5 }); // arr2 now contains [15, 25, 15, 25, 35] var arr3 = _.uniq(arr2); // arr3 now contains [15, 25, 35] var arr...
Exceptions in Laravel are handled by App\Exceptions\Handler.php This file contains two functions by default. Report & Render. We will only be using the first public function report(Exception $e) The report method is used to log exceptions or send them to an external service like BugSnag...
iota can be used in expressions, so it can also be used to assign values other than simple incrementing integers starting from zero. To create constants for SI units, use this example from Effective Go: type ByteSize float64 const ( _ = iota // ignore first value by assigning to b...
Because iota is incremented after each ConstSpec, values within the same expression list will have the same value for iota: const ( bit0, mask0 = 1 << iota, 1<<iota - 1 // bit0 == 1, mask0 == 0 bit1, mask1 // bit1 == 2, mask1 == 1 _, _ ...
Iota can be very useful when creating a bitmask. For instance, to represent the state of a network connection which may be secure, authenticated, and/or ready, we might create a bitmask like the following: const ( Secure = 1 << iota // 0b001 Authn // 0b010 Ready ...
.message color: white background: black .message-important @extend .message font-weight: bold .message-error @extend .message-important font-style: italic This code causes .message-error to extend from .message-important, which means that it will contain code from both .me...
Lets say we have a class as (defclass person () (name email age)) To obtain the names of the slots of the class we use the function class-slots. This can be found in the closer-mop package, provided by the closer-mop system. To load it the running lisp image we use (ql:quickload :closer-mop)....
The password in a credential object is an encrypted [SecureString]. The most straightforward way is to get a [NetworkCredential] which does not store the password encrypted: $credential = Get-Credential $plainPass = $credential.GetNetworkCredential().Password The helper method (.GetNetworkCrede...
public static class ArrayHelpers { public static bool Contains<T>(this T[] array, T[] candidate) { if (IsEmptyLocate(array, candidate)) return false; if (candidate.Length > array.Length) return false; for (int a = 0; a <...
Rails is shipped by default with ActiveRecord, an ORM (Object Relational Mapping) derived from the pattern with the same name. As an ORM, it is built to handle relational-mapping, and more precisely by handling SQL requests for you, hence the limitation to SQL databases only. However, you can stil...
An Explain infront of a select query shows you how the query will be executed. This way you to see if the query uses an index or if you could optimize your query by adding an index. Example query: explain select * from user join data on user.test = data.fk_user; Example result: id select_type...
You can start some slow process in parallel and then collect the results when they are done: Public Sub Main() Dim results = Task.WhenAll(SlowCalculation, AnotherSlowCalculation).Result For Each result In results Console.WriteLine(result) Next End Sub Async Functio...
Because of security reasons, by default cookies are accessible only on the same domain from which they were set. For example, if you have set a cookie on domain example.com, you cannot get it on domain www.example.com. So if you're planning to use subdomains (i.e. admin.example.com, profile.exampl...
In case of autologin or "remember me" cookie, the same quirks as in case of subdomain cookies are applying. But this time you need to configure user component, setting identityCookie array to desired cookie config. Open you application config file and add identityCookie parameters to use...
It is possible to create custom routing constraint which can be used inside routes to constraint a parameter to specific values or pattern. This constrain will match a typical culture/locale pattern, like en-US, de-DE, zh-CHT, zh-Hant. public class LocaleConstraint : IRouteConstraint { pri...
import os, sys from openpyxl import Workbook from datetime import datetime dt = datetime.now() list_values = [["01/01/2016", "05:00:00", 3], \ ["01/02/2016", "06:00:00", 4], \ ["01/03/2016", "07:00:00",...
If your application is available in different languages, you usually show the current locale in the URL. scope '/(:locale)', locale: /#{I18n.available_locales.join('|')}/ do root 'example#root' # other routes end Your root will be accessible via the locales defined in I18n.available_l...
To create a new Rails 5 API, open a terminal and run the following command: rails new app_name --api The following file structure will be created: create create README.rdoc create Rakefile create config.ru create .gitignore create Gemfile create app create app/as...

Page 13 of 47