Although this works only for WebKit based browsers, this is helpful:
/* ----------- Non-Retina Screens ----------- */
@media screen
and (min-width: 1200px)
and (max-width: 1600px)
and (-webkit-min-device-pixel-ratio: 1) {
}
/* ----------- Retina Screens ----------- */
@media scre...
When working with large files, you can use the System.IO.File.ReadLines method to read all lines from a file into an IEnumerable<string>. This is similar to System.IO.File.ReadAllLines, except that it doesn't load the whole file into memory at once, making it more efficient when working with l...
Well, if you want a switch/case construct, the most straightforward way to go is to use the good old if/else construct:
def switch(value):
if value == 1:
return "one"
if value == 2:
return "two"
if value == 42:
return "the answer to...
Another way, which is very readable and elegant, but far less efficient than a if/else structure, is to build a class such as follows, that will read and store the value to compare with, expose itself within the context as a callable that will return true if it matches the stored value:
class Switc...
I created custom label with wrapper around FormattedText property:
public class MultiComponentLabel : Label
{
public IList<TextComponent> Components { get; set; }
public MultiComponentLabel()
{
var components = new ObservableCollection<TextComponent>();
...
It is possible to perform ViewActions on a view using the perform method.
The ViewActions class provides helper methods for the most common actions, like:
ViewActions.click()
ViewActions.typeText()
ViewActions.clearText()
For example, to click on the view:
onView(...).perform(click());
onVi...
Inherits
Specifies the base (or parent) class
Public Class Person
End Class
Public Class Customer
Inherits Person
End Class
'One line notation
Public Class Student : Inherits Person
End Class
Possible objects:
Dim p As New Person
Dim c As New Customer
Dim s As New Student
...
Overridable
Allows a property or method in a class to be overridden in a derived class.
Public Class Person
Public Overridable Sub DoSomething()
Console.WriteLine("Person")
End Sub
End Class
Overrides
Overrides an Overridable property or method defined in the base...
In C, character constants and string literals are different things.
A character surrounded by single quotes like 'a' is a character constant. A character constant is an integer whose value is the character code that stands for the character. How to interpret character constants with multiple charac...
To know the path of the directory your file is in you can use:
Esc to enter command mode
:pwd
This will print the path to the directory at the bottom of the editor, like this
I'm a ninja
~
~
~
~
~
/home/ubuntu/myfolder 1,5 All
Now...
Singleton classes share their instance/class variables with their object.
class Example
@@foo = :example
end
def Example.foo
class_variable_get :@@foo
end
Example.foo #=> :example
class Example
def initialize
@foo = 1
end
def foo
@foo
end
end
e = Ex...
In Normal, type the following to delete a range of lines into a named register
:10,20d a
This will delete lines 10,20 in register "a.
We can verify this by typing
:reg
This will show the text that was delete in register "a.
To paste the contents in "a, just type
"ap
...
The canvas can be used to display video from a variety of sources. This example shows how to load a video as a file resource, display it and add a simple click on screen play/pause toggle.
This stackoverflow self answered question How do I display a video using HTML5 canvas tag shows the following ...
let fetchRequest = NSFetchRequest(entityName: "Foo")
var thePredicate: NSPredicate?
thePredicate = NSPredicate(format: "message == 'example'")
The entity Foo has a message string attribute
Since Laravel version 5.2.31 the web middleware is applied by default within the RouteServiceProvider (https://github.com/laravel/laravel/commit/5c30c98db96459b4cc878d085490e4677b0b67ed)
In app/Providers/RouteServiceProvider.php you will find the following functions which apply the middleware on ev...
To open a new window, add the following code somewhere where you can keep a reference to the new window (I.E., the app delegate).
Swift
let storyboard:NSStoryboard = NSStoryboard(name: "Main", bundle: nil)
guard let controller:NSWindowController = storyboard.instantiateControllerWithIde...
It is unlikely for a developer to not come across a deprecated API during a development process. A deprecated program element is one that programmers are discouraged from using, typically because it is dangerous, or because a better alternative exists. Compilers and analyzers (like LINT) warn when a...
Example below shows how to create a BroadcastReceiver which is able to receive BOOT_COMPLETED events. This way, you are able to start a Service or start an Activity as soon device was powered up.
Also, you can use BOOT_COMPLETED events to restore your alarms since they are destroyed when device is ...