Tutorial by Examples: ase

This uses the SwiftyDropbox library to upload a file from a NSData to the Dropbox account, using upload sessions for larger files, handling every error case: import UIKit import SwiftyDropbox class ViewController: UIViewController { // replace this made up data with the real data le...
This uses the SwiftyDropbox library to share a folder, handling every error case: Dropbox.authorizedClient!.sharing.shareFolder(path: "/folder_path").response { response, error in if let result = response { print("response: \(result)") } else if let callError ...
let toInvite = [Sharing.AddMember(member: Sharing.MemberSelector.Email("<EMAIL_ADDRESS_TO_INVITE>"))] Dropbox.authorizedClient!.sharing.addFolderMember(sharedFolderId: "<SHARED_FOLDER_ID>", members: toInvite).response { response, error in if (response != nil...
var data = 'iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACN' + 'byblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHx' + 'gljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='; var characters = atob(data); var array = new Uint8Array(characters.length); for (var i = 0; i < characters.length; i++) { array[i] ...
A rebase switches the meaning of "ours" and "theirs": git checkout topic git rebase master # rebase topic branch on top of master branch Whatever HEAD's pointing to is "ours" The first thing a rebase does is resetting the HEAD to master; before cherry-picking...
The searched CASE returns results when a boolean expression is TRUE. (This differs from the simple case, which can only check for equivalency with an input.) SELECT Id, ItemId, Price, CASE WHEN Price < 10 THEN 'CHEAP' WHEN Price < 20 THEN 'AFFORDABLE' ELSE 'EXPENSIVE' E...
var favoriteColors: Set = ["Red", "Blue", "Green"] //favoriteColors = {"Blue", "Green", "Red"} You can use the insert(_:) method to add a new item into a set. favoriteColors.insert("Orange") //favoriteColors = {"Red&q...
alist = [1, 2, 3, 4, 1, 2, 1, 3, 4] alist.count(1) # Out: 3 atuple = ('bear', 'weasel', 'bear', 'frog') atuple.count('bear') # Out: 2 atuple.count('fox') # Out: 0
var favoriteColors: Set = ["Red", "Blue", "Green"] //favoriteColors = {"Blue", "Green", "Red"} You can use the contains(_:) method to check whether a set contains a value. It will return true if the set contains that value. if favorite...
Use Case CASE can be used in conjunction with SUM to return a count of only those items matching a pre-defined condition. (This is similar to COUNTIF in Excel.) The trick is to return binary results indicating matches, so the "1"s returned for matching entries can be summed for a count o...
Sometimes you may encounter members that have really long member names, such as thisIsWayTooLongOfAName(). In this case, you can import the member and give it a shorter name to use in your current module: import {thisIsWayTooLongOfAName as shortName} from 'module' shortName() You can import m...
This will draw a line at the bottom of every view but the last to act as a separator between items. public class SeparatorDecoration extends RecyclerView.ItemDecoration { private final Paint mPaint; private final int mAlpha; public SeparatorDecoration(@ColorInt int color, float w...
The base keyword is used to access members from a base class. It is commonly used to call base implementations of virtual methods, or to specify which base constructor should be called. Choosing a constructor public class Child : SomeBaseClass { public Child() : base("some string for th...
Occasionally you will find the need to encode binary data as a base64-encoded string. For this we can use the DatatypeConverter class from the javax.xml.bind package: import javax.xml.bind.DatatypeConverter; import java.util.Arrays; // arbitrary binary data specified as a byte array byte[] bi...
CASE's shorthand variant evaluates an expression (usually a column) against a series of values. This variant is a bit shorter, and saves repeating the evaluated expression over and over again. The ELSE clause can still be used, though: SELECT Id, ItemId, Price, CASE Price WHEN 5 THEN 'CHEAP' ...
C++11 for loops can be used to iterate over the elements of a iterator-based range, without using a numeric index or directly accessing the iterators: vector<float> v = {0.4f, 12.5f, 16.234f}; for(auto val: v) { std::cout << val << " "; } std::cout <<...
Commits can be squashed during a git rebase. It is recommended that you understand rebasing before attempting to squash commits in this fashion. Determine which commit you would like to rebase from, and note its commit hash. Run git rebase -i [commit hash]. Alternatively, you can type HE...
Create a snapshot of a whole database: mysqldump [options] db_name > filename.sql Create a snapshot of multiple databases: mysqldump [options] --databases db_name1 db_name2 ... > filename.sql mysqldump [options] --all-databases > filename.sql Create a snapshot of one or more tables...
mysql [options] db_name < filename.sql Note that: db_name needs to be an existing database; your authenticated user has sufficient privileges to execute all the commands inside your filename.sql; The file extension .sql is fully a matter of style. Any extension would work. You cannot spe...
// Check if service worker is available. if ('serviceWorker' in navigator) { navigator.serviceWorker.register('/sw.js').then(function(registration) { console.log('SW registration succeeded with scope:', registration.scope); }).catch(function(e) { console.log('SW registration failed...

Page 2 of 40