How can I get Moment.js to return “Today” or other relevant terms? I cannot find anything in the docs that cover this.
Answer
You can also use calendar function:
moment().calendar(moment().add(1, 'day')); // "Yesterday at 9:14 PM"
How can I get Moment.js to return “Today” or other relevant terms? I cannot find anything in the docs that cover this.
You can also use calendar function:
moment().calendar(moment().add(1, 'day')); // "Yesterday at 9:14 PM"
What is the source of this error and how could it be fixed?
2015-11-29 19:40:04,670 FATAL org.apache.hadoop.hdfs.server.datanode.DataNode: Initialization failed for Block pool <registering> (Datanode Uuid unassigned) service to anmol-vm1-new/10.0.1.190:8020. Exiting. java.io.IOException: All specified directories are not accessible or do not exist. at org.apache.hadoop.hdfs.server.datanode.DataStorage.recoverTransitionRead(DataStorage.java:217) at org.apache.hadoop.hdfs.server.datanode.DataStorage.recoverTransitionRead(DataStorage.java:254) at org.apache.hadoop.hdfs.server.datanode.DataNode.initStorage(DataNode.java:974) at org.apache.hadoop.hdfs.server.datanode.DataNode.initBlockPool(DataNode.java:945) at org.apache.hadoop.hdfs.server.datanode.BPOfferService.verifyAndSetNamespaceInfo(BPOfferService.java:278) at org.apache.hadoop.hdfs.server.datanode.BPServiceActor.connectToNNAndHandshake(BPServiceActor.java:220) at org.apache.hadoop.hdfs.server.datanode.BPServiceActor.run(BPServiceActor.java:816) at java.lang.Thread.run(Thread.java:745) 2015-11-29 19:40:04,670 WARN org.apache.hadoop.hdfs.server.datanode.DataNode: Ending block pool service for: Block pool <registering> (Datanode Uuid unassigned) service to anmol-vm1-new/10.0.1.190:8020 2015-11-29 19:40:04,771 INFO org.apache.hadoop.hdfs.server.datanode.DataNode: Removed Block pool <registering> (Datanode Uuid unassigned)
there are 2 Possible Solutions to resolve
First:
Your namenode and datanode cluster ID does not match, make sure to make them the same.
In name node, change ur cluster id in the file located in:
$ nano HADOOP_FILE_SYSTEM/namenode/current/VERSION
In data node you cluster id is stored in the file:
$ nano HADOOP_FILE_SYSTEM/datanode/current/VERSION
Second:
Format the namenode at all:
Hadoop 1.x: $ hadoop namenode -format Hadoop 2.x: $ hdfs namenode -format
I’ve coded a very simple CRUD API and I’ve started recently coding also some tests using chai
and chai-http
but I’m having an issue when running my tests with $ mocha
.
When I run the tests I get the following error on the shell:
TypeError: app.address is not a function
Here is a sample of one of my tests (/tests/server-test.js):
var chai = require('chai'); var mongoose = require('mongoose'); var chaiHttp = require('chai-http'); var server = require('../server/app'); // my express app var should = chai.should(); var testUtils = require('./test-utils'); chai.use(chaiHttp); describe('API Tests', function() { before(function() { mongoose.createConnection('mongodb://localhost/bot-test', myOptionsObj); }); beforeEach(function(done) { // I do stuff like populating db }); afterEach(function(done) { // I do stuff like deleting populated db }); after(function() { mongoose.connection.close(); }); describe('Boxes', function() { it.only('should list ALL boxes on /boxes GET', function(done) { chai.request(server) .get('/api/boxes') .end(function(err, res){ res.should.have.status(200); done(); }); }); // the rest of the tests would continue here... }); });
And my express
app files (/server/app.js):
var mongoose = require('mongoose'); var express = require('express'); var api = require('./routes/api.js'); var app = express(); mongoose.connect('mongodb://localhost/db-dev', myOptionsObj); // application configuration require('./config/express')(app); // routing set up app.use('/api', api); var server = app.listen(3000, function () { var host = server.address().address; var port = server.address().port; console.log('App listening at http://%s:%s', host, port); });
and (/server/routes/api.js):
var express = require('express'); var boxController = require('../modules/box/controller'); var thingController = require('../modules/thing/controller'); var router = express.Router(); // API routing router.get('/boxes', boxController.getAll); // etc. module.exports = router;
I’ve tried logging out the server
variable in the /tests/server-test.js file before running the tests:
... var server = require('../server/app'); // my express app ... console.log('server: ', server); ...
and I the result of that is an empty object: server: {}
.
You don’t export anything in your app module. Try adding this to your app.js file:
module.exports = server
So I’ve got a fresh install of El Capitan and I’m giving these task runners another go.
I’m following sitepoint’s An introduction to Gulp.js, but I’m stuck on step four, when I try to run gulp jshint
I get “Error: Cannot find module 'jshint/src/cli'
”
I’ve no idea what’s causing this, which is why I’m asking here. Below are a couple of screen grabs to help with the issue.
As always, I’m eternally grateful for any advice.
You need to install jshint as well, that will sort out the issue.
> npm install --save-dev jshint gulp-jshint
I have a problem with PreferenceFragment and CollapsingToolbarLayout. I have a base layout:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/mainLayout" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".activities.base.BaseActivity"> <android.support.design.widget.AppBarLayout android:id="@+id/appbarLayout" android:layout_width="match_parent" android:layout_height="@dimen/nav_header_height" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/ctlLayout" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_scrollFlags="scroll|exitUntilCollapsed"> <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:minHeight="?attr/actionBarSize" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:layout_collapseMode="pin" app:popupTheme="@style/ThemeOverlay.AppCompat.Light"></android.support.v7.widget.Toolbar> </android.support.design.widget.CollapsingToolbarLayout> </android.support.design.widget.AppBarLayout> <FrameLayout android:id="@+id/fragment_container" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" android:nestedScrollingEnabled="true"/> <android.support.design.widget.FloatingActionButton android:id="@+id/fabFav" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="85dp" android:src="@android:drawable/ic_menu_save" app:layout_anchor="@id/appbarLayout" app:layout_anchorGravity="bottom|right|end" android:visibility="gone" /> <android.support.design.widget.FloatingActionButton android:id="@+id/fabShare" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="@dimen/fab_margin" android:src="@android:drawable/ic_menu_share" app:borderWidth="0dp" app:layout_anchor="@id/appbarLayout" app:layout_anchorGravity="bottom|right|end" android:visibility="gone" /> <fragment android:id="@+id/search_fragment" android:layout_width="match_parent" android:layout_height="match_parent" android:name="com.eventum.raedictionary.fragments.SearchFragment" tools:layout="@layout/fragment_search"/>
The problem is when I inflate the Framelayout with a PreferenceFragment the scroll doesn’t work but with a normal Fragment works properly.
BaseSettingFragment settingsFragment = new BaseSettingFragment(); fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.setCustomAnimations(R.transition.fade_in, R.transition.fade_out); fragmentTransaction.replace(R.id.fragment_container, settingsFragment); fragmentTransaction.commit();
I haven’t found any solutions for this problem, can anyone help me?
Thank you in advance.
PD: Sorry for my English.
PreferenceFragment
is based on ListView
, which does not support the nested scrolling APIs required for CollapsingToolbarLayout
. You can instead use the Preference Support Library and PreferenceFragmentCompat, which is based on RecyclerView
and does support the nested scrolling APIs required.