var CD_INITIALIZE = Buffer.from([ 0x1b, '@']);
var CD_KICK = Buffer.from([0x1b, 0x07, 0x0b, 0x37, 0x07]);
var CD_FONT = Buffer.from([0x1b, 0x1e, 0x46, 0x00]);
var CD_BOLD = Buffer.from([0x1b, 0x45 ]);
var CD_NORMAL = Buffer.from([0x1b, 0x46 ]);
var CD_CUT = Buffer.from([0x1b, 0x64, 0x30]);
//var deviceName = '_192_168_1_106';
var deviceName = 'Star_TSP143__STR_T_001_';
var message = "\nDaffodil 10.00\nTulips 23.00\n"
var shopHeader = "Flowers\nBy\nDavid";
const printer = require('printer');
printRaw( CD_INITIALIZE, deviceName );
printRaw( CD_FONT, deviceName );
printRaw( CD_BOLD, deviceName );
printText( shopHeader , deviceName );
printRaw( CD_NORMAL, deviceName );
printText( message , deviceName );
printRaw( CD_CUT, deviceName );
function printRaw( data, printerName ) {
printer.printDirect({
data: data,
printer: printerName,
type: 'RAW',
success: function( jobId ) {
console.log("Print RAW completed OK");
},
error: function( err ) {
console.log("Print RAW error [" + err + "]");
}
});
};
function printText( data, printerName ) {
printer.printDirect({
data: data,
printer: printerName,
type: 'TEXT',
success: function( jobId ) {
console.log("Print TEXT completed OK");
},
error: function( err ) {
console.log("Print TEXT error [" + err + "]");
}
});
};
I've released the alpha version of spreadsheet files importer cli: sxi
. More details may be found on the package readme:
https://github.com/Siemienik/XToolset/blob/master/packages/xlsx-import-cli/README.md
(xlsx-import-cli is part of XToolset - set of high level api tools for XLSX files).
Any feedback welcomed, any stars loved :heart: .
@echo off
set STS_HOME=d:\TerminalServer
set NODE_HOME=d:\Node
del %STS_HOME%/log/sts.log
start /b %NODE_HOME%\node "%STS_HOME%\terminalServer.js" > %STS_HOME%/log/sts.log
I'm trying to port this js to java
if (cells[i0] & W && distance[i1 = i0 - 1] === undefined) distance[i1] = d, frontier1.push(i1);
i1 is reassigned during the array reference -- what does the value of i1 in distance[i1] take?
the new val or old val?
Also,
Cells[i0] and W are both numbers, so "cells[i0] & W" performs a bitwise AND, then the "&&" evaluates the truthy of this, where only the number 1 is true -- is this correct?
set
the hash of a crypto.Hash object?
Hi, everyone! I don't mean to annoy you. Would you help me answering a few (9) simple questions about your dev env setup?
https://docs.google.com/forms/d/e/1FAIpQLSd7E-S207EQ7YwsC6rDzW8fxAgyCqTiRRRULysqZQbWNH_biA/viewform?usp=sf_link
Very much appreciated!
Also, let me know if by any chance this is agains the rules.
Hi All,
Can someone please help me to write a synchronized function in Node.
What I want, when multiple request trying to access same function it should be locked for one until the data has not been processed within that function.
Here is the my code:
nodejs/help#3177
Hi,i am trying to get only those emails which are received as email reply send by my system.for more specific i am sending email with attachment .and receiver replies to that email with attachment.
I want history of email in my system which shows which attachment is received against which email. for example if i have send email to pearson B.Pearson B will reply to that email.i want history of this.
I am able to send and receive email.But the issue is that i am getting all email fetched betwwen a and b(I want only those email which is send as reply of particular email).Below i gave given code to fetch email.
var mailListener = new MailListener({
username: "******",
password: "******",
host: "imap-mail.outlook.com",
port: 993, // imap port
tls: true,
connTimeout: 10000, // Default by node-imap
authTimeout: 5000, // Default by node-imap,
tlsOptions: { rejectUnauthorized: false },
mailbox: "INBOX", // mailbox to monitor
searchFilter: [ 'UNSEEN', ['FROM', req.params.email] ], // the search filter being used after an IDLE notification has been retrieved ,
markSeen: false, // all fetched email willbe marked as seen and not fetched next time
fetchUnreadOnStart: true, // use it only if you want to get all unread email on lib start. Default is `false`,
mailParserOptions: {streamAttachments: true}, // options to be passed to mailParser lib.
attachments: true, // download attachments as they are encountered to the project directory
attachmentOptions: { directory: "attachments/" } // specify a download directory for attachments
});
mailListener.start();
mailListener.on("server:connected", function(){
console.log("imapConnected");
});
mailListener.on("error", function(err){
console.log('hello');
});
mailListener.on("mail", function(mail, seqno, attributes){
console.log(seqno)
let attachments = [];
var attachment = mail.attachments;
if(attachment) {
for(var i = 0, len = attachment.length; i < len; ++i){
attachments.push(attachment[i].fileName);
}
}
passDatatoPage(mail, attachments);
mailListener.stop();
})
mailListener.on("attachment", function(attachment){
let filepath = './public/attachment/receive/';
let output = fs.createWriteStream(filepath + attachment.fileName);
attachment.stream.pipe(output).on("end", function () {
console.log("All the data in the file has been read");
}).on("close", function (err) {
console.log("Stream has been cloesd.");
});
});
function passDatatoPage(mail, attachments) {
var sender = mail.to[0].address;
var senderName = mail.from[0].name;
var reciver = mail.from[0].address;
const date = moment(mail.date).format('LL');
var subject = mail.subject;
var message = mail.text;
//console.log(attachments);
var result = attachments.map(function(val) {
return val;
}).join(',');
var attachmentArr = result.split(',');
console.log(attachmentArr)
res.render('email-reply', { title: 'Email Reply', to: sender, senderName: senderName, from: reciver, date: date, subject: subject, msg: message, attachments: attachmentArr});
}
});
May I know what is wrong with my code? please provide possible solution in this code or provide way how i achive my task. Thanks in advance.
Hello!
I have a very (?) strange issue here.
If I do:
var buf = Buffer.from('fhqwhgads', 'utf8');
console.log("Testing: " + buf)
I get: Testing: fhqwhgads
while, if I do:
console.log(Buffer.from('fhqwhgads', 'utf8'));
then I get the correct output: <Buffer 66 68 71 77 68 67 61 64 73>
Any ideas?
Thanks!
buf.toString()
? Because that is what you propably get when concenating with string