Sometimes, we want some fields in the JSON string to be optional. For example,
data Person = Person { firstName :: Text
, lastName :: Text
, age :: Maybe Int
}
This can be achieved by
import Data.Aeson.TH
$(deriveJSON ...
In a data declaration, prefixing a type with a bang (!) makes the field a strict field. When the data constructor is applied, those fields will be evaluated to weak head normal form, so the data in the fields is guaranteed to always be in weak head normal form.
Strict fields can be used in both rec...
The expiration values of a key can be managed by a user outside of the update commands. Redis allows a user to determine the current time to live (TTL) of a key using the TTL command:
TTL key
This command will return the TTL of a key in seconds or will return the special values -1 or -2. A -1 ...
The following example demonstrates using Lumen in WAMP / MAMP / LAMP environments.
To work with Lumen you need to setup couple of things first.
Composer
PHPUnit
git (not required but strongly recommended)
Assuming you have all these three components installed (at least you need composer), f...
Retrolambda lets you run Java 8 code with lambda expressions, method references and try-with-resources statements on Java 7, 6 or 5. It does this by transforming your Java 8 compiled bytecode so that it can run on an older Java runtime.
Backported Language Features:
Lambda expressions are back...
It is possible to use integer variables with latex. To create a new variable we need the \newcounter{name} command, where name is the name of the new counter. The name must contain only letters. This command creates a new one with name \thename. With this command we can print name variable onto the ...
Copy the database from the emulator/phone to view it. It can be done by using ADB:
adb pull /data/data/<packagename>/files/
That command will pull all Realm files created by Realm.getInstance(getContext()) or Realm.getInstance(new RealmConfiguration.Builder(context).build()). The default d...
Nested for loops may be used to iterate over a number of unique iterables.
result = []
for a = iterable_a
for b = iterable_b
push!(result, expression)
end
end
Similarly, multiple iteration specifications may be supplied to an array comprehension.
[expression for a = iterabl...
&& chains two commands. The second one runs only if the first one exits with success.
|| chains two commands. But second one runs only if first one exits with failure.
[ a = b ] && echo "yes" || echo "no"
# if you want to run more commands within a logical c...
The | takes the output of the left command and pipes it as input the right command. Mind, that this is done in a subshell. Hence you cannot set values of vars of the calling process wihtin a pipe.
find . -type f -a -iname '*.mp3' | \
while read filename; do
mute --noise "...
Adding a video that will autoplay on a loop and has no controls or sound. Perfect for a video header or background.
<video width="1280" height="720" autoplay muted loop poster="video.jpg" id="videobg">
<source src="video.mp4" type="...
DIGEST() functions generate a binary hash of the given data. This can be used to create a random hash.
Usage: digest(data text, type text) returns bytea
Or: digest(data bytea, type text) returns bytea
Examples:
SELECT DIGEST('1', 'sha1')
SELECT DIGEST(CONCAT(CAST(current_timestamp AS...
Glyphicons can be used in text, buttons, toolbars, navigation, forms, etc (Source: W3Schools). Glyphicons are basically icon forms that can be used to style any of the aforementioned. These examples outline the usage of glyphicons inside two types of buttons by simply using a span inside the buttons...
There are many responsive scenarios where it's necessary to have column units exceeding 12 in a single .row element. This is known as column wrapping.
If more than 12 columns are placed within a single row, each group of
extra columns will, as one unit, wrap onto a new line.
For example, cons...
Typically, you will want to create your SimpleJdbcCalls in a Service.
This example assumes your procedure has a single output parameter that is a cursor; you will need to adjust your declareParameters to match your procedure.
@Service
public class MyService() {
@Autowired
private DataSour...
There are a number of issues with Oracle. Here's how to resolve them.
Assuming your procedure output parameter is ref cursor, you will get this exception.
java.sql.SQLException: Invalid column type: 2012
So change Types.REF_CURSOR to OracleTypes.CURSOR in simpleJdbcCall.declareParameters()
...
You can create custom dialogs which contains many component and perform many functionality on it. It behaves like second stage on owner stage.
In the following example an application that shows person in the main stage tableview and creates a person in a dialog (AddingPersonDialog) prepared. GUIs c...
With a simple for loop, all zip archives in a directory can be extracted.
for (i in dir(pattern=".zip$"))
unzip(i)
The dir function produces a character vector of the names of the files in a directory matching the regex pattern specified by pattern. This vector is looped through w...