Tutorial by Examples: ti

A program can easily waste time by calling a processor-intensive function multiple times. For example, take a function which looks like this: it returns an integer if the input value can produce one, else None: def intensive_f(value): # int -> Optional[int] # complex, and time-consuming cod...
Having type column in a Rails model without invoking STI can be achieved by assigning :_type_disabled to inheritance_column: class User < ActiveRecord::Base self.inheritance_column = :_type_disabled end
Create setup script ~/.perlbrew.sh: # Reset any environment variables that could confuse `perlbrew`: export PERL_LOCAL_LIB_ROOT= export PERL_MB_OPT= export PERL_MM_OPT= # decide where you want to install perlbrew: export PERLBREW_ROOT=~/perlbrew [[ -f "$PERLBREW_ROOT/etc/bashrc" ]...
<!-- All boilerplate for now --> <Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Application.Resources> </Application.Reso...
Getting Started Install NuGet packages: Microsoft.AspNet.Identity.EntityFramework Microsoft.AspNet.Identity.Core Microsoft.AspNet.Identity.OWIN Register action - Account controller [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public async Task<ActionResult> R...
In MVC, there are some scenerios where you want to specify an action for routing purposes, either for a link, form action, or a redirect to action. You can specify an action via the MVC namespace. When given a Controller, such as HomeController: public class HomeController : Controller { pub...
The Flexbox (Flexible box) layout, introduced in CSS3 provides a more efficient way to lay out, align and distribute space among children elements(flex items) within a container element(flex container). Most importantly even when their sizes are unknown or dynamic and hence the term "flex"...
import sys from PyQt5.QtWidgets import QApplication, QWidget from PyQt5.QtGui import QIcon class Example(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): self.setGeometry(300, 30...
import sys from PyQt5.QtWidgets import (QWidget, QToolTip, QPushButton, QApplication) from PyQt5.QtGui import QFont class Example(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): ...
Dockerize zookeeper-3.4.6 Create a Dockerfile: ####################################################### # Image: img.reg.3g:15000/zookeeper:3.4.6 ####################################################### FROM img.reg.3g:15000/jdk:1.7.0_67 MAINTAINER [email protected] USER root ENV ZO...
You can use Try..Catch to rollback database operation by placing the rollback statement at the Catch Segment. Try 'Do the database operation... xCmd.CommandText = "INSERT into ...." xCmd.ExecuteNonQuery() objTrans.Commit() ...
Note : I am assuming that you know about how to use BottomNavigationView. This example I will explain how to add selector for BottomNavigationView. So you can state on UI for icons and texts. Create drawable bottom_navigation_view_selector.xml as <?xml version="1.0" encoding="...
Repository interface; public interface IRepository<T> { void Insert(T entity); void Insert(ICollection<T> entities); void Delete(T entity); void Delete(ICollection<T> entity); IQueryable<T> SearchFor(Expression<Func<T, bool>> predicate);...
Although Catch ex As Exception claims that it can handle all exceptions - there are one exception (no pun intended). Imports System Static Sub StackOverflow() ' Again no pun intended StackOverflow() End Sub Static Sub Main() Try StackOverflow() Catch ex As Exception ...
Generally most of the exceptions are not that critical, but there are some really serious exceptions that you might not be capable to handle, such as the famous System.StackOverflowException. However, there are others that might get hidden by Catch ex As Exception, such as System.OutOfMemoryExceptio...
<zippy (open)="onOpen($event)" (close)="onClose($event)"></zippy>
As of Jekyll 3.2, you can use the filter where_exp to filter a collection by any of its properties. Say you have the following collection item in an "albums" collection: --- title: My Amazing Album --- ... You can combine the where_exp and first filters to grab just that one item: ...
Given an 'albums' collection, you can loop through and output each item: {% for album in site.albums %} {{ album.content }} {% endfor %} Any custom front matter variables are also available within the loop. {% for album in site.albums %} {{ album.title }} {{ album.content }} {%...
Given an 'albums' collection, an item can be added by creating a file in the <source>/_albums directory. Note that files not including frontmatter will be ignored. For instance, adding a file called my_album.md to the _albums directory would add it to the collection: --- title: "My Alb...
The jars for CXF JAX-RS are found in Maven: <!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-rs-client --> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-client</artifactId> <version>3.1.10</version> ...

Page 432 of 505