Tutorial by Examples: active

You can rescue a RecordNotFound exception with a redirect instead of showing an error page: class ApplicationController < ActionController::Base # your other stuff rescue_from ActiveRecord::RecordNotFound do |exception| redirect_to root_path, 404, alert: I18n.t("errors.record...
It's a VBA Best Practice to always specify which workbook your VBA code refers. If this specification is omitted, then VBA assumes the code is directed at the currently active workbook (ActiveWorkbook). '--- the currently active workbook (and worksheet) is implied Range("A1").value = 3.1...
Having a button there is all well and good, but what's the point if clicking it does nothing? ActionListeners are used to tell your button, or other component to do something when it is activated. Adding ActionListeners is done as such. buttonA.addActionListener(new ActionListener() { @Overri...
globalize gem is a great solution to add translations to your ActiveRecord models. You can install it adding this to your Gemfile: gem 'globalize', '~> 5.0.0' If you're using Rails 5 you will also need to add activemodel-serializers-xml gem 'activemodel-serializers-xml' Model translations...
Many commands and programs in the remote side are screen-based (e.g. mc) or they need to ask password (e.g. sudo), to be able to run these kind of programs you can use option -t. ssh -t [email protected] sudo ls / [sudo] password for alice: bin root dev etc home lib mnt opt proc root run usr ...
// Add active class to active navigation link $(document).ready(function () { $('ul.nav.navbar-nav').find('a[href="' + location.pathname + '"]') .closest('li').addClass('active'); });
# application.rb config.time_zone = 'Eastern Time (US & Canada)' config.active_record.default_timezone = :local
ActiveWorkbook and ThisWorkbook sometimes get used interchangeably by new users of VBA without fully understanding which each object relates to, this can cause undesired behaviour at run-time. Both of these objects belong to the Application Object The ActiveWorkbook object refers to the workbook ...
Let's say there's a collection called Todos and the autopublish package is added. Here is the basic component. import { createContainer } from 'meteor/react-meteor-data'; import React, { Component, PropTypes } from 'react'; import Todos from '/imports/collections/Todos'; export class List exte...
:s/foo/bar/c Marks the first instance of foo on the line and asks for confirmation for substitution with bar :%s/foo/bar/gc Marks consecutively every match of foo in the file and asks for confirmation for substitution with bar
The logic of registering for push notification is recommended to be added in AppDelegate.swift as the callback functions (success, failure) will be called their. To register just do the following: let application = UIApplication.sharedApplication() let settings = UIUserNotificationSettings(forType...
An interesting but rather unknown usage of Active Patterns in F# is that they can be used to validate and transform function arguments. Consider the classic way to do argument validation: // val f : string option -> string option -> string let f v u = let v = defaultArg v "Hello&quo...
Active Patterns can be used to make calling some .NET API's feel more natural, particularly those that use an output parameter to return more than just the function return value. For example, you'd normally call the System.Int32.TryParse method as follows: let couldParse, parsedInt = System.Int32....
console.dir(object) displays an interactive list of the properties of the specified JavaScript object. The output is presented as a hierarchical listing with disclosure triangles that let you see the contents of child objects. var myObject = { "foo":{ "bar":"d...
Though the transaction class method is called on some ActiveRecord class, the objects within the transaction block need not all be instances of that class. This is because transactions are per-database connection, not per-model. In this example a balance record is transactionally saved even though ...
From within Emacs, type C-h t (Control-h, t) to get an excellent interactive tutorial within Emacs. The user learns basic navigation and editing by operating on the TUTORIAL text itself, as they read the tutorial. (Modifications to the tutorial are discarded when the tutorial is closed, so each ti...
C# Maximizing the window driver.Manage().Window.Maximize(); This is fairly straightforward, ensures that our currently active window is maximized. Position of the window driver.Manage().Window.Position = new System.Drawing.Point(1, 1); Here we essentially move the currently active window t...
git clean -i Will print out items to be removed and ask for a confirmation via commands like the follow: Would remove the following items: folder/file1.py folder/file2.py *** Commands *** 1: clean 2: filter by pattern 3: select by numbers 4: ask each 5: quit...
This returns the currently active spreadsheet, or null if there is none. var currentSheet = SpreadsheetApp.getActive(); var url = currentSheet.getUrl(); Logger.log( url );

Page 2 of 4