Want to create a calculated item with last("X") / last("Y")
.
When Y = 0
, the result should be 0.
last("X") * (1 - count("Y",#1,0)) / (last("Y") + count("Y",#1,0))
Want to create a calculated item with last("X") / last("Y")
.
When Y = 0
, the result should be 0.
last("X") * (1 - count("Y",#1,0)) / (last("Y") + count("Y",#1,0))
[Unit] | |
Description=My service | |
[Service] | |
ExecStart=/usr/local/bin/my-service \ | |
-argument value \ | |
-otherargument othervalue | |
# Setuid/Setgid | |
User=nobody |
package main | |
import ( | |
"log" | |
"syscall" | |
"unsafe" | |
) | |
var ( | |
kernel32 = syscall.NewLazyDLL("kernel32.dll") |
angular.module('myApp').directive('myChart', function () { | |
var draw_line_chart = function(scope) { ... } | |
var draw_bar_chart = function(scope) { ... } | |
var setup_chart_interactions = function(scope) { ... } | |
// other helper functions ... | |
return { | |
templateUrl: '/views/my-chart.html', | |
restrict: 'E', |
var cluster = require('cluster'); | |
var PORT = +process.env.PORT || 1337; | |
if (cluster.isMaster) { | |
// In real life, you'd probably use more than just 2 workers, | |
// and perhaps not put the master and worker in the same file. | |
cluster.fork(); | |
cluster.fork(); | |
cluster.on('disconnect', function(worker) { |
The question: how can we use ES6 modules in Node.js, where modules-as-functions is very common? That is, given a future in which V8 supports ES6 modules:
export
syntax, without breaking consumers that do require("function-module")()
?import
syntax, while not demanding that the module author rewrites his code to ES6 export
?@wycats showed me a solution. It involves hooking into the loader API to do some rewriting, and using a distinguished name for the single export.
This is me eating crow for lots of false statements I've made all over Twitter today. Here it goes.
rialabs.directive('riaSelect', function(){ /* This direct will be used as an HTML attribute: ria-select="{}" */ | |
/* http://docs.angularjs.org/guide/directive */ | |
return { | |
restrict: 'A', /* Limitates the use as an HTML attrbute */ | |
require: 'ngModel', /* Requires the model to be used in this directive */ | |
compile: function(tElement, tAttrs){ /* In the compile function, the <select> element is transformed by the plugin. */ | |
var el = jQuery(tElement); /* tElement is a plain <select> */ | |
el.select2(); /* Uses the plugin select2() */ |