When executing a Bash script, parameters passed into the script are named in accordance to their position: $1 is the name of the first parameter, $2 is the name of the second parameter, and so on.
A missing parameter simply evaluates to an empty string. Checking for the existence of a parameter can...
Interfaces can seem abstract until you seem them in practice. The IComparable and IComparable<T> are great examples of why interfaces can be helpful to us.
Let's say that in a program for a online store, we have a variety of items you can buy. Each item has a name, an ID number, and a price.
...
There are two possible ways of including LaTeX preamble commands (e.g. \usepackage) in a RMarkdown document.
1. Using the YAML option header-includes:
---
title: "Including LaTeX Preample Commands in RMarkdown"
header-includes:
- \renewcommand{\familydefault}{cmss}
- \usepacka...
Most websites require a much more complicated process than the one demonstrated above.
Common steps for logging into a website are:
Get the unique cookie from the initial login form.
Inspect the login form to see what the destination url is for the authentication request
Parse the login form t...
Flask has that feature which lets you stream data from a view by using generators.
Let's change the app.py file
add from flask import Response
add from datetime import datetime
add from time import sleep
create a new view:
@app.route("/time/")
def time():
def streamer():
...
' Create filestream to file
Using fileStream = New IO.FileStream("archive.zip", IO.FileMode.Create)
' open zip archive from stream
Using archive = New System.IO.Compression.ZipArchive(fileStream, IO.Compression.ZipArchiveMode.Create)
' create file_in_archive.txt in arch...
Self types can be used in traits and classes to define constraints on the concrete classes it is mixed to. It is also possible to use a different identifier for the this using this syntax (useful when outer object has to be referenced from an inner object).
Assume you want to store some objects. Fo...
Normally Android-SQLiteOpenHelper does not allow fully qualified path names where the database should be stored. So public database files are not possible.
You can use the SQLiteOpenHelper with a custom path if you provide a custom ContextClass and if you have write access in the target directory.
...
If you wish to make a complete backup of a large MySql installation and do not have sufficient local storage, you can dump and compress it directly to an Amazon S3 bucket. It's also a good practice to do this without having the DB password as part of the command:
mysqldump -u root -p --host=localho...
AMD is a module definition system that attempts to address some of the common issues with other systems like CommonJS and anonymous closures.
AMD addresses these issues by:
Registering the factory function by calling define(), instead of immediately executing it
Passing dependencies as an array...
The column text may change upon the horizontal resizing of a column. There are three methods to accomplish this:
Method NameMaximum Length of Headingset_short_text10set_medium_text20set_long_text40
The following example shows usage of all three. A column object is declared and instantiated as a re...
Suppose you have a parentView into which you want to insert a new subView programmatically (eg. when you want to insert an UIImageView into a UIViewController's view), than you can do it as below.
Objective-C
[parentView addSubview:subView];
Swift
parentView.addSubview(subView)
You can also...
CSS
.bordered {
border-image: linear-gradient(to right, red 20%, green 20%, green 40%, blue 40%, blue 60%, maroon 60%, maroon 80%, chocolate 80%); /* gradient with required colors */
border-image-slice: 1;
}
HTML
<div class='bordered'>Border on all sides</div>
The above ex...
This technique details how to ensure that your .apk has been signed with your developer certificate, and leverages the fact that the certificate remains consistent and that only you have access to it.
We can break this technique into 3 simple steps:
Find your developer certificate signature.
Em...
This example will call the windows calculator. It's important to notice that the exit code will vary accordingly to the program/script that is being called.
package process.example;
import java.io.IOException;
public class App {
public static void main(String[] args) {
try {
...
For example:
ActiveRecord::Base.transaction do
david.withdrawal(100)
mary.deposit(100)
end
This example will only take money from David and give it to Mary if neither withdrawal nor deposit raise an exception. Exceptions will force a ROLLBACK that returns the database to the state before ...
The SUBDIRS ability of qmake can be used to compile a set of libraries, each of which depend on another. The example below is slightly convoluted to show variations with the SUBDIRS ability.
Directory Structure
Some of the following files will be omitted in the interest of brevity. They can be a...