Use swap (from Data.Tuple) to swap the components of a pair.
import Data.Tuple (swap)
swap (1, 2) -- evaluates to (2, 1)
Or use pattern matching.
case (1, 2) of (x, y) => (y, x) -- evaluates to (2, 1)
Using comments in your projects is a handy way of leaving explanations of your design choices, and should aim to make your (or someone else's) life easier when maintaining or adding to the code.
There are a two ways of adding a comment to your code.
Single line comments
Any text placed after // w...
Setup Spark context in R
To start working with Sparks distributed dataframes, you must connect your R program with an existing Spark Cluster.
library(SparkR)
sc <- sparkR.init() # connection to Spark context
sqlContext <- sparkRSQL.init(sc) # connection to SQL context
Here are infos how...
SQL Server 2008 R2
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
This isolation level is the 2nd most permissive. It prevents dirty reads. The behavior of READ COMMITTED depends on the setting of the READ_COMMITTED_SNAPSHOT:
If set to OFF (the default setting) the transaction uses shared l...
Foreign keys enables you to define relationship between two tables. One (parent) table need to have primary key that uniquely identifies rows in the table. Other (child) table can have value of the primary key from the parent in one of the columns. FOREIGN KEY REFERENCES constraint ensures that valu...
sys.foreignkeys system view returns information about all foreign key relationships in database:
select name,
OBJECT_NAME(referenced_object_id) as [parent table],
OBJECT_NAME(parent_object_id) as [child table],
delete_referential_action_desc,
update_referential_action_desc
from sys.foreign...
After installing a Java SDK, it is advisable to check that it is ready to use. You can do this by running these two commands, using your normal user account:
$ java -version
$ javac -version
These commands print out the version information for the JRE and JDK (respectively) that are on your sh...
If you're using an icon to add some extra decoration or branding, it does not need to be announced to users as they are navigating your site or app aurally. Additionally, if you're using an icon to visually re-emphasize or add styling to content already present in your HTML, it does not need to be r...
The method charCodeAt retrieves the Unicode character code of a single character:
var charCode = "µ".charCodeAt(); // The character code of the letter µ is 181
To get the character code of a character in a string, the 0-based position of the character is passed as a parameter to charCo...
qnew: create a new patch
qpop: pop the current patch off the stack
qpush: push the next patch onto the stack
qrefresh: update the current patch
qapplied: print the patches already applied
qseries: print the entire series file
qfinish: move applied patches into repository history
qdelete: re...
The wheel collider inside unity is built upon Nvidia's PhysX wheel collider, and therefore shares many similar properties. Technically unity is a "unitless" program, but to make everything make sense, some standard units are required.
Basic Properties
Mass - the weight of the wheel in ...
Documenting your work
Remember what you've done and retain long outputs which can't be kept in WinDbg's buffer. It's always good to have a log available for reproducing debugging steps, e.g. to ask questions on Stack Overflow.
CommandPurpose.logopencreate a log file.logcloseclose the log file.dump...
Following are the Prerequisites for installing Cookiecutter:
pip
virtualenv
PostgreSQL
Create a virtualenv for your project and activate it:
$ mkvirtualenv <virtualenv name>
$ workon <virtualenv name>
Now install Cookiecutter using:
$ pip install cookiecutter
Change dire...
Unlike most other JavaScript objects, symbols are not automatically converted into a string when performing concatenation.
let apple = Symbol('Apple') + ''; // throws TypeError!
Instead, they have to be explicitly converted into a string when necessary, (for example, to get a textual description...
Print the path to the active developer directory (selected Xcode)
xcode-select -p
Select a different version of Xcode, e.g. Beta
sudo xcode-select -s /Applications/Xcode-beta.app
Reset to the default version of Xcode
sudo xcode-select -r
This is equivalent to running sudo xcode-select -s /Appl...