Tutorial by Examples

Continuing on the mtcars example, here is a simple way to produce a plot of your linear regression that is potentially suitable for publication. First fit the linear model and fit <- lm(mpg ~ wt, data = mtcars) Then plot the two variables of interest and add the regression line within the d...

GCT

The GCT file format is a tab-delimited text file format used for describing processed gene expression or RNAi data, typically derived from microarray chip analysis. This data is arranged with a single annotated gene or probe per line, and a single chip sample per column (beyond the annotation colum...
The Math.max() function returns the largest of zero or more numbers. Math.max(4, 12); // 12 Math.max(-1, -15); // -1 The Math.min() function returns the smallest of zero or more numbers. Math.min(4, 12); // 4 Math.min(-1, -15); // -15 Getting maximum and minimum from an array: var ...
To use the constant simply use its name: if (EARTH_IS_FLAT) { print "Earth is flat"; } print APP_ENV_UPPERCASE; or if you don't know the name of the constant in advance, use the constant function: // this code is equivalent to the above code $const1 = "EARTH_IS_FLAT&quo...
Java SE 7 switch itself can not be parameterised to be case insensitive, but if absolutely required, can behave insensitive to the input string by using toLowerCase() or toUpperCase: switch (myString.toLowerCase()) { case "case1" : ... break; case &...
Per the Haskell 2010 Language Specification the following are standard IO functions available in Prelude, so no imports are required to use them. putChar :: Char -> IO () - writes a char to stdout Prelude> putChar 'a' aPrelude> -- Note, no new line putStr :: String -> IO () - writ...
As-per the Haskell 2010 Language Specification, the following are standard IO functions available in Prelude, so no imports are required to use them. getChar :: IO Char - read a Char from stdin -- MyChar.hs main = do myChar <- getChar print myChar -- In your shell runhaskell MyChar...
Encoding //convert the image to NSData first let imageData:NSData = UIImagePNGRepresentation(image)! // convert the NSData to base64 encoding let strBase64:String = imageData.base64EncodedStringWithOptions(.Encoding64CharacterLineLength) Decoding let dataDecoded:NSData = NSData(base64Encoded...
ENUM provides a way to provide an attribute for a row. Attributes with a small number of non-numeric options work best. Examples: reply ENUM('yes', 'no') gender ENUM('male', 'female', 'other', 'decline-to-state') The values are strings: INSERT ... VALUES ('yes', 'female') SELECT ... --> ...
Let's say we have type ENUM('fish','mammal','bird') An alternative is type TINYINT UNSIGNED plus CREATE TABLE AnimalTypes ( type TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, name VARCHAR(20) NOT NULL COMMENT "('fish','mammal','bird')", PRIMARY KEY(type), INDEX(na...
Let's say we have type ENUM('fish','mammal','bird') An alternative is type VARCHAR(20) COMENT "fish, bird, etc" This is quite open-ended in that new types are trivially added. Comparison, and whether better or worse than ENUM: (same) INSERT: simply provide the string (worse?)...
ALTER TABLE tbl MODIFY COLUMN type ENUM('fish','mammal','bird','insect'); Notes As with all cases of MODIFY COLUMN, you must include NOT NULL, and any other qualifiers that originally existed, else they will be lost. If you add to the end of the list and the list is under 256 items, the ALTER...
Haskell supports many forms of concurrency and the most obvious being forking a thread using forkIO. The function forkIO :: IO () -> IO ThreadId takes an IO action and returns its ThreadId, meanwhile the action will be run in the background. We can demonstrate this quite succinctly using ghci: ...
Changing an auto-increment value is useful when you don't want a gap in an AUTO_INCREMENT column after a massive deletion. For example, you got a lot of unwanted (advertisement) rows posted in your table, you deleted them, and you want to fix the gap in auto-increment values. Assume the MAX value o...
To insert data retrieved from SQL query (single or multiple rows) INSERT INTO Table_name (FirstName, LastName, Position) SELECT FirstName, LastName, 'student' FROM Another_table_name Note, 'student' in SELECT is a string constant that will be inserted in each row. If required, you can select a...
Following query will provide information about TempDb usage. Analyzing the counts you can identify which thing is impacting TempDb SELECT SUM (user_object_reserved_page_count)*8 as usr_obj_kb, SUM (internal_object_reserved_page_count)*8 as internal_obj_kb, SUM (version_store_reserved_page_cou...
Below query can be used to get TempDB database details: USE [MASTER] SELECT * FROM sys.databases WHERE database_id = 2 OR USE [MASTER] SELECT * FROM sys.master_files WHERE database_id = 2 With the help of below DMV, you can check how much TempDb space does your session is using. This query...
using System; using System.Linq; using System.Security.Cryptography; namespace YourCryptoNamespace { /// <summary> /// Salted password hashing with PBKDF2-SHA1. /// Compatibility: .NET 3.0 and later. /// </summary> /// <remarks>See http://crackstation.net/h...
When a single parameter is passed to the .attr() function it returns the value of passed attribute on the selected element. Syntax: $([selector]).attr([attribute name]); Example: HTML: <a href="/home">Home</a> jQuery: $('a').attr('href'); Fetching data attributes: jQue...
If you want to add an attribute to some element you can use the attr(attributeName, attributeValue) function. For example: $('a').attr('title', 'Click me'); This example will add mouseover text "Click me" to all links on the page. The same function is used to change attributes' values...

Page 596 of 1336