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...
# not all of this is required, but just here for reference
bl_info = {
"name": "Hello World", # name of the add-on
"author": "Blender developer", # name of the author
"version": (1, 0), ...
Enable pipelines in your settings.py
ITEM_PIPELINES = {
'project_folder.pipelines.MyPipeline': 100
}
Then write this code in items.py
# -*- coding: utf-8 -*-
from scrapy import Item, Field
from collections import OrderedDict
class DynamicItem(Item):
def __setitem__(self, key, v...
ghcjs can be invoked with the same command line arguments as ghc. The generated programs can be run directly from
the shell with Node.js and SpiderMonkey jsshell.
for example:
$ ghcjs -o helloWorld helloWorld.hs
$ node helloWorld.jsexe/all.js
Hello world!
Suppose we want to write a constraint which matches a number, but approximatively. Say, you are supposed to have 95 people in a survey, but 93 or 96 will do as well. We can write a custom constraint of the form:
public class AlmostEqualToConstraint : Constraint
{
readonly int _expected;
...
Redis provides two functions for removing keys from the database: del and unlink.
The del function removes one or more keys from the database. The del command causes Redis to immediately reclaim the memory for the deleted key on the current thread of execution. The execution time for del is propo...
To create a new project ng new [project-name] which initializes git.Install packages for tooling via npm. It creates the project successfully.
cd [project-name] and execute either npm start or ng serve
It'll run the server in the given default port.
Application will refresh according to the chan...
Go to terminal,
cd projectFolder
git remote -v (it will show previous git url)
git remote set-url origin https://[email protected]/username/newName.git
git remote -v (double check, it will show new git url)
git push (do whatever you want.)
A single line comment starts with two hyphens (--) and extends up to the end of the line. Example :
-- This process models the state register
process(clock, aresetn)
begin
if aresetn = '0' then -- Active low, asynchronous reset
state <= IDLE;
elsif rising_edge(clock) then --...
Starting with VHDL 2008, a comment can also extend on several lines. Multi-lines comments start with /* and end with */. Example :
/* This process models the state register.
It has an active low, asynchronous reset
and is synchronized on the rising edge
of the clock. */
process(clock, ...