View jsFiddle: https://jsfiddle.net/HimmatChahal/jb5trg67/
Copy + Pasteable code below:
<html>
<body>
<h1>This will fade in at 60 frames per second (or as close to possible as your hardware allows)</h1>
<script>
// Fad...
Omitting the return statement in a function which is has a return type that is not void is undefined behavior.
int function() {
// Missing return statement
}
int main() {
function(); //Undefined Behavior
}
Most modern day compilers emit a warning at compile time for this kind o...
pd.read_excel('path_to_file.xls', sheetname='Sheet1')
There are many parsing options for read_excel (similar to the options in read_csv.
pd.read_excel('path_to_file.xls',
sheetname='Sheet1', header=[0, 1, 2],
skiprows=3, index_col=0) # etc.
Returning lambdas (or closures) from functions can be tricky because they implement traits and thus their exact size is rarely known.
// Box in the return type moves the function from the stack to the heap
fn curried_adder(a: i32) -> Box<Fn(i32) -> i32> {
// 'move' applies move se...
The primary way that you make UI updates to your React applications is through a call to the setState() function. This function will perform a shallow merge between the new state that you provide and the previous state, and will trigger a re-render of your component and all decedents.
Parameters
...
pip may be used to install BeautifulSoup. To install Version 4 of BeautifulSoup, run the command:
pip install beautifulsoup4
Be aware that the package name is beautifulsoup4 instead of beautifulsoup, the latter name stands for old release, see old beautifulsoup
The default property getters and setters can be overridden:
@interface TestClass
@property NSString *someString;
@end
@implementation TestClass
// override the setter to print a message
- (void)setSomeString:(NSString *)newString {
NSLog(@"Setting someString to %@", newS...
The syntax for Java generics bounded wildcards, representing the unknown type by ? is:
? extends T represents an upper bounded wildcard. The unknown type represents a type that must be a subtype of T, or type T itself.
? super T represents a lower bounded wildcard. The unknown type repres...
Extension methods can be used for writing strongly typed wrappers for dictionary-like objects. For example a cache, HttpContext.Items at cetera...
public static class CacheExtensions
{
public static void SetUserInfo(this Cache cache, UserInfo data) =>
cache["UserInfo"] ...
Installing OPAM
OPAM is a package manager for OCaml. It builds and manages compiler versions and OCaml libraries for you easily.
The easiest way to install OPAM on your operating system is to use a package manager for your system. e.g apt-get, yum or homebrew.
Mac OSX Installation Instructions
U...
You can also receive regular updates of the user's location; for example, as they move around while using a mobile device. Location tracking over time can be very sensitive, so be sure to explain to the user ahead of time why you're requesting this permission and how you'll use the data.
if (naviga...
Microsoft describes 3 ways of installing WinDbg:
as part of the WDK (Windows Driver Kit)
as part of the SDK (Software Development Kit)
with the installer of the SDK and deselecting everything else but "Debugging Tools for Windows"
To get the installer, visit Download the WDK, WinDb...
Since JUnit is a Java library, all you have to do to install it is to add a few JAR files into the classpath of your Java project and you're ready to go.
You can download these two JAR files manually: junit.jar & hamcrest-core.jar.
If you're using Maven, you can simply add in a dependency into...
Optional Parameters
In TypeScript, every parameter is assumed to be required by the function. You can add a ? at the end of a parameter name to set it as optional.
For example, the lastName parameter of this function is optional:
function buildName(firstName: string, lastName?: string) {
// ...
Pointer Methods
Pointer methods can be called even if the variable is itself not a pointer.
According to the Go Spec,
. . . a reference to a non-interface method with a pointer receiver using an addressable value will automatically take the address of that value: t.Mp is equivalent to (&t)....
You can mix normal parameters and parameter arrays:
public class LotteryTicket : IEnumerable{
public int[] LuckyNumbers;
public string UserName;
public void Add(string userName, params int[] luckyNumbers){
UserName = userName;
Lottery = luckyNumbers;
}
}
...
Directives comes with the AngularJS library itself. A sample directive can be created as:
angular.module('simpleDirective', [])
.directive('helloData', function() {
return {
template: 'Hello, {{data}}'
};
});
And can be used as:
JS:
angular.module('app', ['simpleDirective'])
.con...
In go it can sometimes be useful to know which underlying type you have been passed. This can be done with a type switch. This assumes we have two structs:
type Rembrandt struct{}
func (r Rembrandt) Paint() {}
type Picasso struct{}
func (r Picasso) Paint() {}
That implement the Painter ...