Tutorial by Examples: al

SilverStripe can be installed via composer or through the extraction of downloaded zip file. To install through composer we run the following command composer create-project silverstripe/installer /path/to/project 3.4.0 A download zip file can be found on the download page of the SilverStripe w...
It is possible to detect whether an operator or function can be called on a type. To test if a class has an overload of std::hash, one can do this: #include <functional> // for std::hash #include <type_traits> // for std::false_type and std::true_type #include <utility> // for s...
You can validate any object, even plain ruby. class User include ActiveModel::Validations attr_reader :name, :age def initialize(name, age) @name = name @age = age end validates :name, presence: true validates :age, numericality: { only_integer: true, greater_than...
Swift func createCollectionView() { let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout() let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height), collectionViewLayout: layout) collectionView.dataSource = sel...
You can use an initializer to set default property values: struct Example { var upvotes: Int init() { upvotes = 42 } } let myExample = Example() // call the initializer print(myExample.upvotes) // prints: 42 Or, specify default property values as a part of the property...
struct MetricDistance { var distanceInMeters: Double init(fromCentimeters centimeters: Double) { distanceInMeters = centimeters / 100 } init(fromKilometers kilos: Double) { distanceInMeters = kilos * 1000 } } let myDistance = MetricDistance(fromCentim...
open my $fh, '<', $filename or die "Could not open $filename for reading: $!"; my $contents = do { local $/; <$fh> }; After opening the file (read man perlio if you want to read specific file encodings instead of raw bytes), the trick is in the do block: <$fh>, the ...
To install the latest version of a package named SomePackage: $ pip install SomePackage To install a specific version of a package: $ pip install SomePackage==1.0.4 To specify a minimum version to install for a package: $ pip install SomePackage>=1.0.4 If commands shows permission den...
To uninstall a package: $ pip uninstall SomePackage
To list installed packages: $ pip list # example output docutils (0.9.1) Jinja2 (2.6) Pygments (1.5) Sphinx (1.1.2) To list outdated packages, and show the latest version available: $ pip list --outdated # example output docutils (Current: 0.9.1 Latest: 0.10) Sphinx (Current: 1.1.2 Late...
virtual and override The virtual keyword allows a method, property, indexer or event to be overridden by derived classes and present polymorphic behavior. (Members are non-virtual by default in C#) public class BaseClass { public virtual void Foo() { Console.WriteLine("Foo...
import locale locale.setlocale(locale.LC_ALL, '') Out[2]: 'English_United States.1252' locale.currency(762559748.49) Out[3]: '$762559748.49' locale.currency(762559748.49, grouping=True) Out[4]: '$762,559,748.49'
Detailed instructions on getting razor set up or installed.
Swift textField.textAlignment = .Center Objective-C [textField setTextAlignment: NSTextAlignmentCenter]; In the example, we have set the NSTextAlignment to center. You can also set to .Left, .Right, .Justified and .Natural. .Natural is the default alignment for the current localization. Th...
Python minimally evaluates Boolean expressions. >>> def true_func(): ... print("true_func()") ... return True ... >>> def false_func(): ... print("false_func()") ... return False ... >>> true_func() or false_func() true_func(...
resources :photos do member do get 'preview' end collection do get 'dashboard' end end This creates the following routes in addition to default 7 RESTful routes: get '/photos/:id/preview', to: 'photos#preview' get '/photos/dashboards', to: '...
You can use curly braces to interpolate expressions into string literals: def f(x: String) = x + x val a = "A" s"${a}" // "A" s"${f(a)}" // "AA" Without the braces, scala would only interpolate the identifier after the $ (in this case f...
You can also use loop with curly brackets like this: if ( have_posts() ) { while ( have_posts() ) { the_post(); var_dump( $post ); } }
A common use case for wanting to calculate the frame a label will take up is for sizing table view cells appropriately. The recommended way of doing this is using the NSString method boundingRectWithSize:options:attributes:context:. options takes String drawing options: NSStringDrawingUsesLineFr...
jquery-ui-rotatable is a plugin for jQuery UI that works in a similar way to Draggable and Resizable, without being as full-featured. By default, it puts a small rotation icon in the bottom left of whatever element you want to make rotatable. <html> <head> <title>My Ro...

Page 44 of 269