Archives 2005 - 2019    Search

The configuration language in the widgets of riemann-dash

published Nov 10, 2015 12:40   by admin ( last modified Nov 10, 2015 01:51 )

Pattern matching is done with the "=~" operator, and "%" is the wildcard. "|" can be used to give alternative values. Haven't used pipe yet but I believe that alternative values are grouped inside a a pair of brackets: "(val1|val2). See monitoring-setup/dashboard.json at master · algernon/monitoring-setup

service =~ "process:%:cpu:percent"

"Rows" and "Columns" decides if the data will be presented row-wise or column-wise per host.


How to get a terminal window unstuck after broken pipe to SSH session

published Nov 10, 2015 10:27   by admin ( last modified Nov 10, 2015 10:27 )



Type ~. (i.e. tilde, period) at the beginning of a line.

...and then hit return.
 

Read more: Link - What can I do when my SSH session is stuck? - Ask Different


Monitoring with Riemann & riemann-dash

published Nov 07, 2015 01:05   by admin ( last modified Nov 10, 2015 01:51 )

This blog post is a work in progress

Riemann is a monitoring system written in Clojure. It can aggregate streams of data, called events, and it can filter, combine and over limited time windows integrate data, and it can also send notifications over e-mail and SMS.

Riemann is scripted in clojure, which is a Lisp-like language that runs on the Java virtual machine (JVM). Riemann is used to monitor the health and status of services such as Linux machines, databases, web servers. It is used e.g. by The Guardian newspaper, see guardian/riemann-config.

Riemann is not primarily a logger, although inside of Riemann you can define a stream that can be sent to logging.

Riemann-dash

There is an ecosystem surrounding the Riemann server, consisting of data sources, clients and a rather nice-looking and easily configurable web GUI for monitoring called riemann-dash, although I currently think I have some problems with memory leaks while running it in Google Chrome.

Config language of Riemann-dash

Riemann-dash has a configuration language, formally documented here:

reimann/Query.g at master · jdmaturen/reimann

(That is an old version of Riemann but is has the language definition as of now)

In order to select what to show in riemann-dash, you put the field you want to match against. Like so:

service = "cpu"

...if you want to monitor the CPU from the data generated by riemann-health.

The output will then be of the metric field which seems to be the default and maybe the only choice. Not sure how to change what field to display the value of.

See: Four Hours with Riemann

Pattern matching is done with the "=~" operator, and "%" is the wildcard. "|" can be used to give alternative values. Haven't used pipe yet but I believe that alternative values are grouped inside a a pair of brackets: "(val1|val2). See monitoring-setup/dashboard.json at master · algernon/monitoring-setup

Here is a working example of how to get metrics from Supermann, a plugin to Supervisord that sends data to Riemann:

service =~ "process:%:cpu:percent"

"Rows" and "Columns" decides if the data will be presented row-wise or column-wise per host.

How to save settings from riemann-dash

You need to have a JSON file to save to. You can just add the path to a config file when starting riemann-dash.

riemann-dash ./settings/config.rb

But what should that config file contain? On Ubuntu 15.04 there is an example config.rb file in

/var/lib/gems/2.1.0/gems/riemann-dash-0.2.12/examples

and it would nice to just copy that, but that does not work as a whole. But the local config file is only part of the config. You can just include the changes from the default that you want.

Make a copy of config.rb and delete all lines except "config.store[:ws_config]". Write something like this:

config.store[:ws_config] = "/path/writable/by/riemann-dash/config/dir/config.json"

Riemann-dash will save its settings to that JSON file. Which file should be in a directory writable by the user that runs riemann-dash of course. I'd advise to version that config file with e.g. git, since it is easy to overwrite config changes that you actually wanted to keep.

 

 

 


The latest deb package of Riemann

published Nov 06, 2015 04:10   by admin ( last modified Nov 06, 2015 04:11 )

Summary: As of 2015-11-06, this I belive is the current deb:

https://aphyr.com/riemann/riemann_0.2.10_all.deb

If you want to install Riemann on Ubuntu or Debian a deb package would be nice. The Riemann - Quickstart  says:

You can also install Riemann via the Debian or RPM packages

Fine, but there are no links to them! There is a blog post from 2104 by James Turnbull,  An Introduction to Riemann, that provides a link to:

https://aphyr.com/riemann/riemann_0.2.8_all.deb

But that blog post is from 2014.  The aphyr server has disabled directory views so you can't see what else is on the server.

The Riemann - Quickstart points to:

https://aphyr.com/riemann/riemann-0.2.10.tar.bz2

...and from that we may deduce that the deb should also be version 0.2.10. And that works!


How to always know which is the prefix key in tmux

published Nov 05, 2015 05:40   by admin ( last modified Nov 05, 2015 10:31 )

Put it in the status bar. First check what is already in the status bar by issuing:

tmux show-options -g

Look for " status-left" it may look like this:

status-left "[#S]"

If the prefix key is Ctrl-b, and the present setting for the left part of the status bar is

"[#S]"

Do:

tmux set -g status-left "[#S] Ctrl-b"

No you will always have a reminder what the prefix key is.


Interesting theory on culture & everything

published Oct 31, 2015 12:59   by admin ( last modified Oct 31, 2015 12:59 )
According to TMT, cultures are symbolic systems that act to provide life with meaning and value

Avoid death, basically.
 

Read more: Link - Terror management theory - Wikipedia, the free encyclopedia


Ubuntu 15.04: How to discover a new Wi-Fi network

published Oct 30, 2015 03:05   by admin ( last modified Oct 30, 2015 03:05 )

Ubuntu 15.04 does not seem to detect new Wi-Fi networks on a human time scale.

Instead: Disable Wi-Fi networking and enable it again.

Restarting the networking service makes no difference.

 


xpath selectors with JSON, what's available?

published Oct 28, 2015 03:42   by admin ( last modified Oct 28, 2015 03:42 )

Working with promise chains in Javascript as I do now, it itches in me to make only certain data available to chained promises, in the case where you would like to use a ready made promisified function that actually only expects part of the data that flows through your pipeline.

One way of configuring such a step ought to be to curry it, and in doing so supplying some kind of expression for what data it should process.

Xpath seems to be down this way, but what libraries are available for xpath expressions on JSON? Preferrably in Node.

 

I have found these so far:

json-path (Work in progress accroding to author) 1254 downloads/month as of today

JSONPath 1726 downloads per month as of today

Defiant.js - Defiantly named something else than Jsonpath. Not on npm site.

 


Ett läkemedel mot åldersförändring av hjärnan?

published Oct 27, 2015 11:27   by admin ( last modified Oct 27, 2015 11:27 )



Researchers found that a six week course of the drug, montelukast, improved memory and learning in older rodents, with their performance in cognitive tests nearly matching that of much younger animals.


Read more: Link - Asthma drug could rejuvenate ageing brains, study suggests | Science | The Guardian


When Cairo-dock opens new windows for Google Chrome

published Oct 24, 2015 02:15   by admin ( last modified Sep 01, 2016 10:59 )

Yesterday, Cairo-dock and Google Chrome started to act weirdly on my Ubuntu 15.04. Whenever clicking the Google Chrome icon in the Cairo-dock launcher, Cairo-dock would make a new icon for the opened instance, and if clicking the launcher icon again, launch yet another window of Google Chrome.

The solution turned out to be to edit the parameters for Google Chrome in Cairo-dock:

1. Expand the extra parameters section

2. This field needs to get the value of the window class

3. An easy way to do that is to have the Google Chrome window open and visible behind the settings, click "Grab" and then position the cross-hair cursor over the Google Chrome Window, and click. The class of the window "google-chrome" will be automatically filled in.

Henceforth Cairo-dock will not launch a new window, if a window by that class name is already open and instead switch to that window.


Adding setup info to code blocks in asciidoc, part 1

published Oct 23, 2015 08:15   by admin ( last modified Oct 23, 2015 08:57 )

Note: No solutions to this problem listed, in this part 1. Just pondering how stuff might work..

Starting to think about whether it is possible to add extra information to a code block in asciidoc/asciidoctor. Code blocks can already have a source entry, such as this:

[source,apache]
----
<VirtualHost *:80>
...
</VirtualHost>
----

Here, two values "source" and "apache" are associated with the code block, and hence pygments will know how that this block is source code and should be rendered in apache configuration file syntax.

Now, I would like to add information on setup code to run, before running the code in a code block. This should work for different languages, not just say javascript or python, like for instance write out the code and the setup code to a JSON file that can be processed further. Let's say there is a piece of python code that reads:

[source, python]
----
fab = bar.foo(baz="bletch")
fab.send()
----

It is pretty clear that that code will not run by itself. So it would be nice to have some setup code specification, that could be used to produce a test suite from the code. Something like this:

[source,python, setup=flum_setup]
----
fab = bar.foo(baz="bletch")
fab.send()
----

where flum_setup could be a name that a test framework can use to look up what needs to be in place before testing that the piece of code works.

Loking at Sphinx, a documentation system for python, you can do this in reStructuredText, an alternative to asciidoc:

.. testsetup:: [group]

A setup code block. This code is not shown in the output for other builders, but executed before the doctests of the group(s) it belongs to.

sphinx.ext.doctest – Test snippets in the documentation — Sphinx 1.3.1+ documentation

Looking at asciidoc it seems like a lot is controlled from .conf files, that contain sections and name-value pairs, where values are written in some syntax with elements of regular expressions. So, how do you define what can get written into the block metadata (the inside brackets stuff preceding the block)?

This link seems to be a start:

Chapter 32. Block Element Definitions It contains info on something called "options", defined as "A comma delimited list of element specific option names.". It seems to look something like this in a source file:

[options="foo,fab,bletch"]

There is also something called posattrs where you can do something like this in a conf document:

posattrs=attribution,citetitle,favorite_dish

and these below values would get assigned to the predefined variables in a block:

["Mr foo", "fab farming", "flum pudding"]

Ok if/when i figure that out, it would be time to define back-end that writes the code blocks and their metadata to JSON.

Actually, looking back at the source code of sphinx.ext.doctest (sphinx/doctest.py at master · sphinx-doc/sphinx), maybe it would be quicker to just clone that extension, and make it write to JSON instead of executing the code blocks in python. In that way the syntax could be used with any language. And in that case I'd abandon asciidoc (short love affair) and start using reStructuredText.

 


Things slowing down my computer, part I

published Oct 21, 2015 02:00   by admin ( last modified Oct 21, 2015 02:01 )

Latest things to slow down my computer to a crawl

  • A tab with something called omniwallet or omnilayer. Slowed down my computer immensely in both Firefox and Chrome.
  • Pulseaudio - solved by restarting
  • Svd.se - A swedish news site's front page

And completely stopping any interaction with the screen:

  • The nvidia drivers, or any driver, for my nvidia GT750M. Solved by disabling the card and now running on some motherboard stuff.

Will Electrolysis make it easier to find misbehaving tabs in Firefox?

published Oct 21, 2015 01:10   by admin ( last modified Oct 21, 2015 01:20 )

Sometimes the javascript or something else in a Firefox tab slows the computer to a crawl. In Google Chrome there is a task manager where you can see the resource consumption of each tab. Maybe Electrolysis will bring something similar to Firefox. It seems to be available in nightly builds.

 

The two major advantages of this model are security and performance. Security improvements are accomplished through sandboxing, performance improvements are born out of the fact that multiple processes better leverage available client computing power.


Read more: Link - Electrolysis - MozillaWiki


An index in postgresql can be on conversion (encoding/decoding) of a value

published Oct 19, 2015 02:33   by admin ( last modified Oct 19, 2015 02:33 )

I needed to do a join between two tables where the key was basically the same, but stored in different formats. In one it was stored as a hex value in a text field, and in the other in a bytea field.

In one table there would be about 360'000 rows and in the other about 75 million. How can I efficiently do a join when I need to convert one of the values in the join criterion? It turns out that in postgresql you can not only make indexes for the values of a column, but you can also make an index for a certain conversion of the value. So if the sql would contain something like this:

 INNER JOIN table2 ON table1.txid = encode(table2.txid, 'HEX')

I can create an index like so:

 CREATE INDEX ON table2 (encode(txid, 'HEX'))

Moving all ports in a buildout up an offset amount

published Oct 16, 2015 05:35   by admin ( last modified Oct 18, 2015 12:47 )

Use z3c.recipe.filetemplate with its interpreted-option setting. This will give you the opportunity to do arithmetic on the port numbers for use both inside the buildout and in rendered files.

I have a relatively complex buildout that builds a combination of servers written in Python, C, C++ and Node.js, and then runs all of them with supervisord.

The servers need to know about each other's host names, ports, user names and passwords. Buildout works well for this, just define all the pertinent data inside a buildout config file and supply the config data as command line options in supervisor for those servers who can parse that,  and write out configuration files for the servers that prefer to get their settings from config files. In this way all settings are inside of buildout and by changing one value, i.e. the host name of the PostgreSQL server, all servers now know about this change and everything continues to work.

But a new challenge has occurred: I need to run more than one instance of this buildout on the same machine. I now need a port offset, that moves all the half-dozen or so ports up by a specific amount, so that the second buildout doesn't try to put its servers on the same ports as the first buildout.

In order to do this I switched out the templating system I was using to z3c.recipe.filetemplate . z3c.recipe.filetemplate can do calculations on settings, if you put the settings you need to calculate under a special "interpreted-options" category. Well actually it is python code. It looks something like this:

[buildout]
parts = config


[config]
recipe=z3c.recipe.filetemplate
source-directory = etc/templates

files = etc/config/test.txt
port_offset = 100
myserver_port_base = 1024
interpreted-options =
                     myserver_port
port_offset = 10
myserver_port = str(int(options['myserver_port_base']) + int(options['port_offset']))

In the above example, port_base and port_offset are defined in the usual buildout way. However myserver_port is declared to be an interpreted option, and that means that when it gets defined, python expressions are valid inside of its definition. options refers to the name space of the buildout part.

myserver_port is now a defined variable in the buildout, reachable as ${myserver_port} in the templates but also available as ${config:myserver_port} from anywhere else in the buildout (such as in a supervisord section).

source-directory above refers to where the template for test.txt is to be found. If test.txt is to be written to etc/config/test.txt, then the template should be:

etc/templates/etc/config/test.txt.in

Note the repetition of the path etc/config inside of the source directory.

z3c.recipe.filetemplate can handle multiple input and output files in one fell swoop:

[buildout]
parts = config


[config]
recipe=z3c.recipe.filetemplate
source-directory = etc/templates

files = 
        etc/config/test.txt
        conf/another_config.yaml
        etc/config/and_one_more.cfg
        mymodules/apythonmodule.py
port_base = 1065
port_offset = 100
myserver_port_base = 1024
interpreted-options =
                     myserver_port
port_offset = 10
myserver_port = str(int(options['myserver_port_base']) + int(options['port_offset']))

 

In the above example 4 files are defined an hence we get 4 files created. Their respective templates must be under etc/templates with their respective paths and have the suffix ".in".

 


Time zones in javascript

published Oct 14, 2015 02:35   by admin ( last modified Oct 14, 2015 03:18 )

Handling timestamps in the past is not an easy thing once you leave UTC. Dates and times are inherently difficult to deal with in any programming language, time zones complicate it further and daylight savings is the icing on the cake.

It seems web browsers have some limited time zone support, i.e. they can adjust to the time zone they think they are in, but cannot do any time zone calculations for other time zones. The only way to adjust time zone then seems to be to adjust the time zone on the OS level. You are then at the mercy of the time zone settings and whatever time zone data is available on the operating system level.

In order to get the browser to handle multiple time zones one can use an extra library and a time zone picker widget. One of the most used time zone javascript libs, moment-timezone, another one is walltime-js.

With walltime.js, you assemble together the time zone data files you need. These come from what is the de facto authoritative source for this kind of sorcery, the Olson files (tz database). You need to have the npm package grunt-cli installed in order to download these time zone info files into walltime.js.

From the page Timezone Picker you can put together a user interface for selecting a time zone

This code snippet can be used together with your own copy of the Timezone picker page, to set a cookie with the selected timezone locale, and to display the value of the cookie in a div.

  <script type="text/javascript">
     function setTZ(value) {
            document.cookie = "TZ="+value+expires+"; path=/";
        }

      function getTZ() {
            var nameEQ = "TZ=";
            var ca = document.cookie.split(';');
            for(var i=0;i < ca.length;i++) {
                var c = ca[i];
                while (c.charAt(0)==' ') c = c.substring(1,c.length);
                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
            }
            return null;
        }

    function displayTz(timezoneName, countryName, offset){
          setTZ(timezoneName)
          $('.indicatedTimezoneName').text(getTZ()) // Show time zone
    }

    $(document).ready(function() {
      // Set up the picker to update target timezone and country select lists.
      $('#timezone-image').timezonePicker({
        target: '#edit-date-default-timezone',
        countryTarget: '#edit-site-default-country',
        changeHandler: displayTz, // called whenever a time zone is selected in any way
        timezone: 'Europe/Tallin' // default
      });

      // Optionally an auto-detect button to trigger JavaScript geolocation.
      $('#timezone-detect').click(function() {
        $('#timezone-image').timezonePicker('detectLocation');
      });

    });
  </script>

<div class="indicatedTimezoneName">Time zone info goes here</div>

 

 


Links of early October 2015

published Oct 10, 2015 12:25   by admin ( last modified Oct 15, 2015 03:19 )
Javascript date handling
Moment.js | Docs
datejs
Moment Timezone | Home
Moment Timezone | Docs
Time · mbostock/d3 Wiki
dosx/timezone-picker
Plone
Live Support Channel — Plone CMS: Open Source Content Management
-Plone Hotfix 20151006 — Plone CMS: Open Source Content Management
Javascript
javascript - At underscore js, Can I get multiple columns with pluck method after input where method as linq select projection - Stack Overflow
ESLint - Pluggable JavaScript linter
JavaScript’s Apply, Call, and Bind Methods are Essential for JavaScript Professionals | JavaScript is Sexy
JavaScript Nested function - Stack Overflow
How can I pretty-print JSON using JavaScript? - Stack Overflow
lodash documentation
Node.js Express
Using template engines with Express
Git
How do you merge selective files with git-merge? - Stack Overflow
Git Tip: How to "Merge" Specific Files from Another Branch [jasonrudolph.com]
Javascript testing
Intern: Software testing for humans
Buster.JS overview — Buster.JS 0.7 documentation
List of unit testing frameworks - Wikipedia, the free encyclopedia
coderwall.com : establishing geek cred since 1305712800
Jasmine: Behavior-Driven JavaScript
Cookbook | QUnit
QUnit
Sinon.JS - Documentation
Javascript testing frameworks — jorgenmodin.net
node.js
Mocha - the fun, simple, flexible JavaScript test framework
The Node Way - Testing Essentials
jhnns/rewire
mfncooper/mockery
Node.js Handbook - Testing Essentials | FredKSchott
Nightwatch.js | Node.js powered End-to-End testing framework
Vows « Asynchronous BDD for Node
testing framework node.js promise chains - Google Search
dareid/chakram
Eradicating Non-Determinism in Tests
StrongLoop | Testing and Documenting Node.js APIs with Mocha and Acquit
acquit
Home - Chai
Using Tests to Document a Node.js Module
How To Use Mocha With Node.js For Test-Driven Development to Avoid Pain and Ship Products Faster
cloudhead/hijs
Screen sharing
resolution - Ubuntu 14.04 - Add Fake Display when No Monitor is Plugged In - Ask Ubuntu
[ubuntu] HOWTO: headless, custom xorg resolution/modeline with vnc access to display 0 console
bash - Ubuntu environment setting for GUI session (or making the same with terminal) - Super User
Supervisor & buildout
superlance 0.11 : Python Package Index
mr.developer 1.33 : Python Package Index
plone.recipe.command 1.1 : Python Package Index
memmon Overview — superlance 1.0.0-dev documentation
Installing Django, Solr, Varnish and Supervisord with Buildout | Blog En
Knots
Andy's Most Useful Knots
LPT: The bowline knot may be the most useful knot, because it it secure and can be tied and untied easily. You can do it in 4 simple steps. : LifeProTips
Munter Mule | How to tie the Munter Mule | Climbing Knots
Software arcitecture
The Architecture of Open Source Applications
The Architecture of Open Source Applications (Volume 2): Scalable Web Architecture and Distributed Systems
The Architecture of Open Source Applications (Volume 2): MediaWiki
Asynchronous programming
Implementing Actors in JavaScript
benlau/nactor · GitHub
mental/webactors · GitHub
AndrewBelt/hack.chat
events - How is Node.js evented system different than the actor pattern of Akka? - Stack Overflow
Embracing Async With Deferreds and Promises - Sebastian's Blog
Reactive programming - Wikipedia, the free encyclopedia
JavaScript Promises: There and back again - HTML5 Rocks
Does async/await solve a real problem?
chopachom/syncio
We have a problem with promises
Promise anti patterns · petkaantonov/bluebird Wiki
Taming the asynchronous beast with ES7
JSX in Depth | React
petkaantonov/bluebird
javascript asynchronous styles - Google Search
Testing Asynchronous JavaScript
Javascript Promises - Being Agile
You're Missing the Point of Promises
domenic/chai-as-promised
javascript - How do you properly promisify request? - Stack Overflow
node request promise - Google Search
Passing multiple arguments in promises | Better world by better software
JavaScript with Promises - Daniel Parker - Google Books
Resolving JavaScript Objects Containing Promises - Will Anderson
javascript - asynchronous or promised condition for array filter - Stack Overflow
Patterns for Asynchronous Programming with Promises | Joe Zim's JavaScript Blog
monet.js - For when you have no choice but to use JavaScript
prequest
promise-useful-utils/API.md at master · fanatid/promise-useful-utils
JavaScript with Promises - Daniel Parker - Google Books
Resolving JavaScript Objects Containing Promises - Will Anderson
javascript - asynchronous or promised condition for array filter - Stack Overflow
Ecmascript 6 & higher and typescript
 
Sign in or Register | edX
TagClass - jsdoc-toolkit - @class - A documentation generator for JavaScript. - Google Project Hosting
Language Safety Score Mark 2 - Deliberate Software
Programming Language Safety Score - Deliberate Software
ECMAScript 6: New Features: Overview and Comparison
ES6 | Node.js
ECMAScript - Wikipedia, the free encyclopedia
ES7 async functions - JakeArchibald.com
Use ECMAScript 6 Today - Tuts+ Code Article
Which TypeScript IDE - Steve Fenton
Using TypeScript in Visual Studio Code - TypeScript - Site Home - MSDN Blogs
ES6 | Node.js
lukehoban/es6features
 
 

I think I may have fixed my linux laptop crashing

published Oct 10, 2015 08:55   by admin ( last modified Oct 10, 2015 08:59 )

Disable the graphics card!

Background

Crashing on average once a day is not cool for a linux laptop. It has taken me a long time to figure out what the problem is, because the logs that I can find on my computer have not been that helpful. However there are few things that should be able to crash you Linux computer. But one of them apparantly is the graphics driver. Well, it does not actually crash your computer, but it makes it inaccesible. I noticed things kept on running and playing. For a while the computer seemed more happy with the open source dirver, but alas, that joy did not last. So I decided to try the old use-different-drivers-and-see-what-works again. But then a small detail caught my eye: The Nvidia X server settings applet has the option to completely shut off the graphics card!

So now I am running on the Intel built-in graphics thingamajig. I don't mind; I'm, not a gamer. Hope this stability lasts.

And picked up this protip from the Internet. If your screen freezes, but you can still move the pointer, the problem is the graphics card system.


Configurable console logging inside a promise chain with _.curry

published Oct 09, 2015 12:15   by admin ( last modified Oct 09, 2015 12:20 )

When using promise chains in Javascript, it is easy to think (at least for me) that you can only stick something non-configurable inside of it:

P.resolve(4).then(afunc).tap(console.dir).then...

But in fact with the help of the _.curry function from underscore/lodash you can curry functions, i.e. wrap them so that they can step-wise be configured with their parameters but only fire once all parameters are defined.

With help of the colors library one can define a console logging function with configurable color and message string and nice formatting, like so:

function log(logColor, message, data) {
    console.log(message)
    console.log(colors[logColor](JSON.stringify(data, null, 2)))
}

And we can now configure that logging from inside of our promise chain like this:

P.resolve(4).then(afunc).tap(_.curry(log)('red','Inside the 4 chain')).then...

Above we call the log function with two of the three parameters. But since the last parameter data is missing, the curried function will first be executed when the parameter list is complete, which means the promise chain will trigger it.


Start a promise chain in Bluebird Q-style

published Oct 03, 2015 04:12   by admin ( last modified Oct 03, 2015 04:12 )

You can start a promise chain in the javascript library Q with a data item, like so:

Q([foo:'bar}).then( ...

How do you do that in the Bluebird javascript library?

One way is like this:

Promise.resolve([foo:'bar}).then( ...
One of the simplest is calling Promise.resolve() on nothing:

Read more: Link - javascript - Define empty Bluebird promise like in Q - Stack Overflow