Note: you need to install Boot before trying this example out. See the Installation and Setup section if you haven't installed it yet.
Boot allows making executable Clojure files using shebang (#!) line. Place the following text into a file of your choice (this example assumes it's in the "cur...
In the material design, a Floating action button represents the primary action in an Activity.
They are distinguished by a circled icon floating above the UI and have motion behaviors that include morphing, launching, and a transferring anchor point.
Make sure the following dependency is added to ...
The simplest use case is using the subprocess.call function. It accepts a list as the first argument. The first item in the list should be the external application you want to call. The other items in the list are arguments that will be passed to that application.
subprocess.call([r'C:\path\to\a...
In Angular $scope is the glue between the Controller and the View that helps with all of our data binding needs. Controller As is another way of binding controller and view and is mostly recommended to use. Basically these are the two controller constructs in Angular (i.e $scope and Controller As).
...
For cases when we don't want to write special classes to handle some resource, we may write a generic class:
template<typename Function>
class Finally final
{
public:
explicit Finally(Function f) : f(std::move(f)) {}
~Finally() { f(); } // (1) See below
Finally(const Final...
It is possible to extract a date out of a text using the dateutil parser in a "fuzzy" mode, where components of the string not recognized as being part of a date are ignored.
from dateutil.parser import parse
dt = parse("Today is January 1, 2047 at 8:21:00AM", fuzzy=True)
pr...
A tbl_df (pronounced tibble diff) is a variation of a data frame that is often used in tidyverse packages. It is implemented in the tibble package.
Use the as_data_frame function to turn a data frame into a tbl_df:
library(tibble)
mtcars_tbl <- as_data_frame(mtcars)
One of the most notable ...
Although it is possible to create a fragment constructor with parameters, Android internally calls the zero-argument constructor when recreating fragments (for example, if they are being restored after being killed for Android's own reasons). For this reason, it is not advisable to rely on a constru...
let string1 = "Hello" //simple string
let string2 = "Line\nNewLine" //string with newline escape sequence
let string3 = @"Line\nSameLine" //use @ to create a verbatim string literal
let string4 = @"Line""with""quoutes inside" //dou...
When trying to select from a table called order like this
select * from order
the error rises:
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order' at line 1
Reserved keywords in MySQ...
Each enum class contains an implicit static method named values(). This method returns an array containing all values of that enum. You can use this method to iterate over the values. It is important to note however that this method returns a new array every time it is called.
public enum Day {
...
Lambda expressions can be used to handle events, which is useful when:
The handler is short.
The handler never needs to be unsubscribed.
A good situation in which a lambda event handler might be used is given below:
smtpClient.SendCompleted += (sender, args) => Console.WriteLine("Ema...
Find properties with a custom attribute - MyAttribute
var props = t.GetProperties(BindingFlags.NonPublic | BindingFlags.Public |
BindingFlags.Instance).Where(
prop => Attribute.IsDefined(prop, typeof(MyAttribute)));
Find all custom attributes on a given property
va...
The android:process field defines the name of the process where the service is to run. Normally, all components of an application run in the default process created for the application. However, a component can override the default with its own process attribute, allowing you to spread your applicat...
Given the model:
class MyModel(models.Model):
name = models.CharField(max_length=10)
model_num = models.IntegerField()
flag = models.NullBooleanField(default=False)
We can use Q objects to create AND , OR conditions in your lookup query. For example, say we want all objects that ...
Django default project layout creates a single settings.py. This is often useful to split it like this:
myprojectroot/
myproject/
__init__.py
settings/
__init__.py
base.py
dev.py
prod.py
tests.py
This enables...
Django manger is an interface through which the django model queries the database. The objects field used in most django queries is actually the default manager created for us by django (this is only created if we don't define custom managers).
Why would we define a custom manager/queryset?
To avo...
Assuming a class
from django.db import models
class Author(models.Model):
name = models.CharField(max_length=50)
def __str__(self):
return self.name
def get_absolute_url(self):
return reverse('view_author', args=[str(self.id)])
class Book(models.Mo...